2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-02-05 23:07:52 +08:00
|
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/blit_commands_helper.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/built_ins/aux_translation_builtin.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_barrier.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_copy_buffer.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_copy_buffer_rect.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_copy_buffer_to_image.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_copy_image.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_copy_image_to_buffer.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_fill_buffer.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_fill_image.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_kernel.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_marker.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_migrate_mem_objects.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_read_buffer.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_read_buffer_rect.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_read_image.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_svm.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_write_buffer.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_write_buffer_rect.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_write_image.h"
|
|
|
|
#include "opencl/source/command_queue/finish.h"
|
|
|
|
#include "opencl/source/command_queue/flush.h"
|
|
|
|
#include "opencl/source/command_queue/gpgpu_walker.h"
|
2018-08-23 00:41:52 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-08-23 00:41:52 +08:00
|
|
|
template <typename Family>
|
2020-07-10 22:04:01 +08:00
|
|
|
void CommandQueueHw<Family>::notifyEnqueueReadBuffer(Buffer *buffer, bool blockingRead, bool notifyBcsCsr) {
|
2019-01-28 00:36:42 +08:00
|
|
|
if (DebugManager.flags.AUBDumpAllocsOnEnqueueReadOnly.get()) {
|
2020-07-10 22:04:01 +08:00
|
|
|
buffer->getGraphicsAllocation(getDevice().getRootDeviceIndex())->setAllocDumpable(blockingRead, notifyBcsCsr);
|
2019-01-28 00:36:42 +08:00
|
|
|
buffer->forceDisallowCPUCopy = blockingRead;
|
|
|
|
}
|
2018-08-23 00:41:52 +08:00
|
|
|
}
|
|
|
|
template <typename Family>
|
2020-07-10 22:04:01 +08:00
|
|
|
void CommandQueueHw<Family>::notifyEnqueueReadImage(Image *image, bool blockingRead, bool notifyBcsCsr) {
|
2019-01-28 00:36:42 +08:00
|
|
|
if (DebugManager.flags.AUBDumpAllocsOnEnqueueReadOnly.get()) {
|
2020-07-10 22:04:01 +08:00
|
|
|
image->getGraphicsAllocation(getDevice().getRootDeviceIndex())->setAllocDumpable(blockingRead, notifyBcsCsr);
|
2019-01-28 00:36:42 +08:00
|
|
|
}
|
2018-08-23 00:41:52 +08:00
|
|
|
}
|
2019-05-10 16:46:54 +08:00
|
|
|
|
2020-08-31 19:10:29 +08:00
|
|
|
template <typename Family>
|
|
|
|
void CommandQueueHw<Family>::notifyEnqueueSVMMemcpy(GraphicsAllocation *gfxAllocation, bool blockingCopy, bool notifyBcsCsr) {
|
|
|
|
if (DebugManager.flags.AUBDumpAllocsOnEnqueueSVMMemcpyOnly.get()) {
|
|
|
|
gfxAllocation->setAllocDumpable(blockingCopy, notifyBcsCsr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-30 20:36:12 +08:00
|
|
|
template <typename Family>
|
|
|
|
cl_int CommandQueueHw<Family>::enqueueReadWriteBufferOnCpuWithMemoryTransfer(cl_command_type commandType, Buffer *buffer,
|
|
|
|
size_t offset, size_t size, void *ptr, cl_uint numEventsInWaitList,
|
|
|
|
const cl_event *eventWaitList, cl_event *event) {
|
|
|
|
cl_int retVal = CL_SUCCESS;
|
|
|
|
EventsRequest eventsRequest(numEventsInWaitList, eventWaitList, event);
|
|
|
|
|
2020-05-26 00:27:17 +08:00
|
|
|
TransferProperties transferProperties(buffer, commandType, 0, true, &offset, &size, ptr, true, getDevice().getRootDeviceIndex());
|
2019-05-30 20:36:12 +08:00
|
|
|
cpuDataTransferHandler(transferProperties, eventsRequest, retVal);
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
cl_int CommandQueueHw<Family>::enqueueReadWriteBufferOnCpuWithoutMemoryTransfer(cl_command_type commandType, Buffer *buffer,
|
|
|
|
size_t offset, size_t size, void *ptr, cl_uint numEventsInWaitList,
|
|
|
|
const cl_event *eventWaitList, cl_event *event) {
|
|
|
|
cl_int retVal = CL_SUCCESS;
|
|
|
|
EventsRequest eventsRequest(numEventsInWaitList, eventWaitList, event);
|
|
|
|
|
2020-05-26 00:27:17 +08:00
|
|
|
TransferProperties transferProperties(buffer, CL_COMMAND_MARKER, 0, true, &offset, &size, ptr, false, getDevice().getRootDeviceIndex());
|
2019-05-30 20:36:12 +08:00
|
|
|
cpuDataTransferHandler(transferProperties, eventsRequest, retVal);
|
|
|
|
if (event) {
|
|
|
|
auto pEvent = castToObjectOrAbort<Event>(*event);
|
|
|
|
pEvent->setCmdType(commandType);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context->isProvidingPerformanceHints()) {
|
|
|
|
context->providePerformanceHintForMemoryTransfer(commandType, false, static_cast<cl_mem>(buffer), ptr);
|
|
|
|
}
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
cl_int CommandQueueHw<Family>::enqueueMarkerForReadWriteOperation(MemObj *memObj, void *ptr, cl_command_type commandType, cl_bool blocking, cl_uint numEventsInWaitList,
|
|
|
|
const cl_event *eventWaitList, cl_event *event) {
|
|
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
|
|
NullSurface s;
|
|
|
|
Surface *surfaces[] = {&s};
|
|
|
|
enqueueHandler<CL_COMMAND_MARKER>(
|
|
|
|
surfaces,
|
|
|
|
blocking == CL_TRUE,
|
|
|
|
multiDispatchInfo,
|
|
|
|
numEventsInWaitList,
|
|
|
|
eventWaitList,
|
|
|
|
event);
|
|
|
|
if (event) {
|
|
|
|
auto pEvent = castToObjectOrAbort<Event>(*event);
|
|
|
|
pEvent->setCmdType(commandType);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context->isProvidingPerformanceHints()) {
|
|
|
|
context->providePerformanceHintForMemoryTransfer(commandType, false, static_cast<cl_mem>(memObj), ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return CL_SUCCESS;
|
|
|
|
}
|
2019-07-09 20:24:33 +08:00
|
|
|
|
|
|
|
template <typename Family>
|
2019-10-31 16:10:30 +08:00
|
|
|
void CommandQueueHw<Family>::dispatchAuxTranslationBuiltin(MultiDispatchInfo &multiDispatchInfo,
|
|
|
|
AuxTranslationDirection auxTranslationDirection) {
|
2019-10-31 17:19:52 +08:00
|
|
|
if (HwHelperHw<Family>::getAuxTranslationMode() != AuxTranslationMode::Builtin) {
|
2019-10-31 16:10:30 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-21 18:37:14 +08:00
|
|
|
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, getDevice());
|
2019-07-09 20:24:33 +08:00
|
|
|
auto &auxTranslationBuilder = static_cast<BuiltInOp<EBuiltInOps::AuxTranslation> &>(builder);
|
|
|
|
BuiltinOpParams dispatchParams;
|
|
|
|
|
|
|
|
dispatchParams.auxTranslationDirection = auxTranslationDirection;
|
|
|
|
|
|
|
|
auxTranslationBuilder.buildDispatchInfosForAuxTranslation<Family>(multiDispatchInfo, dispatchParams);
|
|
|
|
}
|
2019-10-10 00:20:12 +08:00
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
bool CommandQueueHw<Family>::forceStateless(size_t size) {
|
|
|
|
return size >= 4ull * MemoryConstants::gigaByte;
|
|
|
|
}
|
|
|
|
|
2020-02-28 16:07:07 +08:00
|
|
|
template <typename Family>
|
|
|
|
bool CommandQueueHw<Family>::isCacheFlushForBcsRequired() const {
|
2020-06-23 18:01:22 +08:00
|
|
|
if (DebugManager.flags.ForceCacheFlushForBcs.get() != -1) {
|
|
|
|
return !!DebugManager.flags.ForceCacheFlushForBcs.get();
|
|
|
|
}
|
2020-02-28 16:07:07 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-11-10 02:02:25 +08:00
|
|
|
template <typename Family>
|
|
|
|
void CommandQueueHw<Family>::setupBlitAuxTranslation(MultiDispatchInfo &multiDispatchInfo) {
|
|
|
|
multiDispatchInfo.begin()->dispatchInitCommands.registerMethod(
|
|
|
|
TimestampPacketHelper::programSemaphoreWithImplicitDependencyForAuxTranslation<Family, AuxTranslationDirection::AuxToNonAux>);
|
|
|
|
|
|
|
|
multiDispatchInfo.begin()->dispatchInitCommands.registerCommandsSizeEstimationMethod(
|
2020-03-09 20:48:30 +08:00
|
|
|
TimestampPacketHelper::getRequiredCmdStreamSizeForAuxTranslationNodeDependency<Family, AuxTranslationDirection::AuxToNonAux>);
|
2019-11-10 02:02:25 +08:00
|
|
|
|
|
|
|
multiDispatchInfo.rbegin()->dispatchEpilogueCommands.registerMethod(
|
|
|
|
TimestampPacketHelper::programSemaphoreWithImplicitDependencyForAuxTranslation<Family, AuxTranslationDirection::NonAuxToAux>);
|
|
|
|
|
|
|
|
multiDispatchInfo.rbegin()->dispatchEpilogueCommands.registerCommandsSizeEstimationMethod(
|
2020-03-09 20:48:30 +08:00
|
|
|
TimestampPacketHelper::getRequiredCmdStreamSizeForAuxTranslationNodeDependency<Family, AuxTranslationDirection::NonAuxToAux>);
|
2019-11-10 02:02:25 +08:00
|
|
|
}
|
|
|
|
|
2020-02-26 20:54:32 +08:00
|
|
|
template <typename Family>
|
2020-03-06 21:56:23 +08:00
|
|
|
bool CommandQueueHw<Family>::obtainTimestampPacketForCacheFlush(bool isCacheFlushRequired) const {
|
|
|
|
return isCacheFlushRequired;
|
2020-02-26 20:54:32 +08:00
|
|
|
}
|
|
|
|
|
2020-06-26 17:21:07 +08:00
|
|
|
template <typename Family>
|
|
|
|
bool CommandQueueHw<Family>::isGpgpuSubmissionForBcsRequired(bool queueBlocked) const {
|
|
|
|
if (queueBlocked) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-07-17 17:03:04 +08:00
|
|
|
bool required = (latestSentEnqueueType != EnqueueProperties::Operation::Blit) && (latestSentEnqueueType != EnqueueProperties::Operation::None);
|
2020-06-26 17:21:07 +08:00
|
|
|
|
|
|
|
if (DebugManager.flags.ForceGpgpuSubmissionForBcsEnqueue.get() == 1) {
|
|
|
|
required = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return required;
|
|
|
|
}
|
2020-08-26 17:26:44 +08:00
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
void CommandQueueHw<Family>::setupEvent(EventBuilder &eventBuilder, cl_event *outEvent, uint32_t cmdType) {
|
|
|
|
if (outEvent) {
|
|
|
|
eventBuilder.create<Event>(this, cmdType, CompletionStamp::notReady, 0);
|
|
|
|
auto eventObj = eventBuilder.getEvent();
|
|
|
|
*outEvent = eventObj;
|
|
|
|
|
|
|
|
if (eventObj->isProfilingEnabled()) {
|
|
|
|
TimeStampData queueTimeStamp;
|
|
|
|
|
|
|
|
getDevice().getOSTime()->getCpuGpuTime(&queueTimeStamp);
|
|
|
|
eventObj->setQueueTimeStamp(&queueTimeStamp);
|
|
|
|
|
|
|
|
if (isCommandWithoutKernel(cmdType)) {
|
|
|
|
eventObj->setCPUProfilingPath(true);
|
|
|
|
eventObj->setQueueTimeStamp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DBG_LOG(EventsDebugEnable, "enqueueHandler commandType", cmdType, "output Event", eventObj);
|
|
|
|
}
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|