2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-05-17 02:51:16 +08:00
|
|
|
* Copyright (C) 2018-2021 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-23 05:50:57 +08:00
|
|
|
#include "opencl/source/helpers/task_information.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
|
|
|
#include "shared/source/command_stream/csr_deps.h"
|
|
|
|
#include "shared/source/command_stream/linear_stream.h"
|
|
|
|
#include "shared/source/command_stream/preemption.h"
|
|
|
|
#include "shared/source/helpers/aligned_memory.h"
|
|
|
|
#include "shared/source/helpers/engine_node_helper.h"
|
|
|
|
#include "shared/source/helpers/string.h"
|
|
|
|
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
|
|
|
#include "shared/source/memory_manager/surface.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/built_ins/builtins_dispatch_builder.h"
|
2020-03-20 18:15:25 +08:00
|
|
|
#include "opencl/source/cl_device/cl_device.h"
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/command_queue/command_queue.h"
|
|
|
|
#include "opencl/source/command_queue/enqueue_common.h"
|
|
|
|
#include "opencl/source/device_queue/device_queue.h"
|
|
|
|
#include "opencl/source/gtpin/gtpin_notify.h"
|
2021-09-23 06:24:59 +08:00
|
|
|
#include "opencl/source/helpers/cl_preemption_helper.h"
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/helpers/enqueue_properties.h"
|
|
|
|
#include "opencl/source/helpers/task_information.inl"
|
|
|
|
#include "opencl/source/mem_obj/mem_obj.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2019-07-19 03:15:50 +08:00
|
|
|
template void KernelOperation::ResourceCleaner::operator()<LinearStream>(LinearStream *);
|
|
|
|
template void KernelOperation::ResourceCleaner::operator()<IndirectHeap>(IndirectHeap *);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-07-23 03:28:59 +08:00
|
|
|
CommandMapUnmap::CommandMapUnmap(MapOperationType operationType, MemObj &memObj, MemObjSizeArray ©Size, MemObjOffsetArray ©Offset, bool readOnly,
|
|
|
|
CommandQueue &commandQueue)
|
|
|
|
: Command(commandQueue), memObj(memObj), copySize(copySize), copyOffset(copyOffset), readOnly(readOnly), operationType(operationType) {
|
2018-01-05 18:33:30 +08:00
|
|
|
memObj.incRefInternal();
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
CompletionStamp &CommandMapUnmap::submit(uint32_t taskLevel, bool terminated) {
|
|
|
|
if (terminated) {
|
2019-07-05 16:02:27 +08:00
|
|
|
memObj.decRefInternal();
|
2017-12-21 07:45:38 +08:00
|
|
|
return completionStamp;
|
|
|
|
}
|
|
|
|
|
2019-07-23 03:28:59 +08:00
|
|
|
auto &commandStreamReceiver = commandQueue.getGpgpuCommandStreamReceiver();
|
|
|
|
auto commandStreamReceiverOwnership = commandStreamReceiver.obtainUniqueOwnership();
|
|
|
|
auto &queueCommandStream = commandQueue.getCS(0);
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t offset = queueCommandStream.getUsed();
|
2019-11-27 19:59:47 +08:00
|
|
|
MultiDispatchInfo multiDispatch;
|
|
|
|
Device &device = commandQueue.getDevice();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-09-13 18:00:30 +08:00
|
|
|
DispatchFlags dispatchFlags(
|
2019-09-25 17:30:19 +08:00
|
|
|
{}, //csrDependencies
|
2019-10-03 20:38:49 +08:00
|
|
|
nullptr, //barrierTimestampPacketNodes
|
2019-09-25 17:30:19 +08:00
|
|
|
{}, //pipelineSelectArgs
|
|
|
|
commandQueue.flushStamp->getStampReference(), //flushStampReference
|
|
|
|
commandQueue.getThrottle(), //throttle
|
2021-09-23 06:24:59 +08:00
|
|
|
ClPreemptionHelper::taskPreemptionMode(device, multiDispatch), //preemptionMode
|
2020-08-21 19:05:01 +08:00
|
|
|
GrfConfig::NotApplicable, //numGrfRequired
|
2020-08-20 17:48:10 +08:00
|
|
|
L3CachingSettings::NotApplicable, //l3CacheSettings
|
2019-11-12 20:59:37 +08:00
|
|
|
ThreadArbitrationPolicy::NotPresent, //threadArbitrationPolicy
|
2020-09-02 17:38:54 +08:00
|
|
|
AdditionalKernelExecInfo::NotApplicable, //additionalKernelExecInfo
|
2020-11-17 18:42:29 +08:00
|
|
|
KernelExecutionType::NotApplicable, //kernelExecutionType
|
2020-12-17 08:36:45 +08:00
|
|
|
MemoryCompressionState::NotApplicable, //memoryCompressionState
|
2019-09-25 17:30:19 +08:00
|
|
|
commandQueue.getSliceCount(), //sliceCount
|
|
|
|
true, //blocking
|
|
|
|
true, //dcFlush
|
|
|
|
false, //useSLM
|
|
|
|
true, //guardCommandBufferWithPipeControl
|
|
|
|
false, //GSBA32BitRequired
|
|
|
|
false, //requiresCoherency
|
|
|
|
commandQueue.getPriority() == QueuePriority::LOW, //lowPriority
|
|
|
|
false, //implicitFlush
|
|
|
|
commandQueue.getGpgpuCommandStreamReceiver().isNTo1SubmissionModelEnabled(), //outOfOrderExecutionAllowed
|
2020-01-29 21:15:10 +08:00
|
|
|
false, //epilogueRequired
|
2020-11-18 21:56:18 +08:00
|
|
|
false, //usePerDssBackedBuffer
|
2021-01-26 22:05:22 +08:00
|
|
|
false, //useSingleSubdevice
|
|
|
|
false, //useGlobalAtomics
|
2021-07-02 00:00:22 +08:00
|
|
|
false, //areMultipleSubDevicesInContext
|
2021-12-06 18:01:46 +08:00
|
|
|
false, //memoryMigrationRequired
|
|
|
|
false); //textureCacheFlush
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-06-16 19:19:11 +08:00
|
|
|
DEBUG_BREAK_IF(taskLevel >= CompletionStamp::notReady);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-07-23 03:28:59 +08:00
|
|
|
gtpinNotifyPreFlushTask(&commandQueue);
|
2018-02-08 23:00:20 +08:00
|
|
|
|
2019-07-23 03:28:59 +08:00
|
|
|
completionStamp = commandStreamReceiver.flushTask(queueCommandStream,
|
|
|
|
offset,
|
|
|
|
commandQueue.getIndirectHeap(IndirectHeap::DYNAMIC_STATE, 0u),
|
|
|
|
commandQueue.getIndirectHeap(IndirectHeap::INDIRECT_OBJECT, 0u),
|
|
|
|
commandQueue.getIndirectHeap(IndirectHeap::SURFACE_STATE, 0u),
|
|
|
|
taskLevel,
|
|
|
|
dispatchFlags,
|
|
|
|
commandQueue.getDevice());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-06-26 17:21:07 +08:00
|
|
|
commandQueue.updateLatestSentEnqueueType(EnqueueProperties::Operation::DependencyResolveOnGpu);
|
|
|
|
|
2018-02-09 03:55:31 +08:00
|
|
|
if (!memObj.isMemObjZeroCopy()) {
|
2021-09-10 00:57:09 +08:00
|
|
|
commandQueue.waitUntilComplete(completionStamp.taskCount, {}, completionStamp.flushStamp, false);
|
2019-07-23 03:28:59 +08:00
|
|
|
if (operationType == MAP) {
|
2018-02-18 05:26:28 +08:00
|
|
|
memObj.transferDataToHostPtr(copySize, copyOffset);
|
|
|
|
} else if (!readOnly) {
|
2019-07-23 03:28:59 +08:00
|
|
|
DEBUG_BREAK_IF(operationType != UNMAP);
|
2018-02-18 05:26:28 +08:00
|
|
|
memObj.transferDataFromHostPtr(copySize, copyOffset);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-05 16:02:27 +08:00
|
|
|
memObj.decRefInternal();
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
return completionStamp;
|
|
|
|
}
|
|
|
|
|
2019-07-23 02:55:09 +08:00
|
|
|
CommandComputeKernel::CommandComputeKernel(CommandQueue &commandQueue, std::unique_ptr<KernelOperation> &kernelOperation, std::vector<Surface *> &surfaces,
|
2021-10-21 20:37:31 +08:00
|
|
|
bool flushDC, bool usesSLM, bool ndRangeKernel, std::unique_ptr<PrintfHandler> &&printfHandler,
|
2018-03-02 05:43:04 +08:00
|
|
|
PreemptionMode preemptionMode, Kernel *kernel, uint32_t kernelCount)
|
2019-07-23 03:28:59 +08:00
|
|
|
: Command(commandQueue, kernelOperation), flushDC(flushDC), slmUsed(usesSLM),
|
2018-09-20 01:34:33 +08:00
|
|
|
NDRangeKernel(ndRangeKernel), printfHandler(std::move(printfHandler)), kernel(kernel),
|
|
|
|
kernelCount(kernelCount), preemptionMode(preemptionMode) {
|
2017-12-21 07:45:38 +08:00
|
|
|
for (auto surface : surfaces) {
|
|
|
|
this->surfaces.push_back(surface);
|
|
|
|
}
|
2018-05-11 20:03:03 +08:00
|
|
|
UNRECOVERABLE_IF(nullptr == this->kernel);
|
|
|
|
kernel->incRefInternal();
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CommandComputeKernel::~CommandComputeKernel() {
|
2018-05-11 20:03:03 +08:00
|
|
|
kernel->decRefInternal();
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CompletionStamp &CommandComputeKernel::submit(uint32_t taskLevel, bool terminated) {
|
|
|
|
if (terminated) {
|
2019-07-19 14:06:40 +08:00
|
|
|
for (auto surface : surfaces) {
|
|
|
|
delete surface;
|
|
|
|
}
|
|
|
|
surfaces.clear();
|
2017-12-21 07:45:38 +08:00
|
|
|
return completionStamp;
|
|
|
|
}
|
2019-07-15 20:28:09 +08:00
|
|
|
auto &commandStreamReceiver = commandQueue.getGpgpuCommandStreamReceiver();
|
2018-05-11 20:03:03 +08:00
|
|
|
bool executionModelKernel = kernel->isParentKernel;
|
2017-12-21 07:45:38 +08:00
|
|
|
auto devQueue = commandQueue.getContext().getDefaultDeviceQueue();
|
2021-09-18 01:09:06 +08:00
|
|
|
auto bcsCsrForAuxTranslation = commandQueue.getBcsForAuxTranslation();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-06 20:55:04 +08:00
|
|
|
auto commandStreamReceiverOwnership = commandStreamReceiver.obtainUniqueOwnership();
|
2020-01-13 20:15:03 +08:00
|
|
|
bool isCcsUsed = EngineHelpers::isCcs(commandQueue.getGpgpuEngine().osContext->getEngineType());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
if (executionModelKernel) {
|
|
|
|
while (!devQueue->isEMCriticalSectionFree())
|
|
|
|
;
|
|
|
|
|
|
|
|
devQueue->resetDeviceQueue();
|
|
|
|
devQueue->acquireEMCriticalSection();
|
|
|
|
}
|
|
|
|
|
2018-04-05 21:12:28 +08:00
|
|
|
IndirectHeap *dsh = kernelOperation->dsh.get();
|
|
|
|
IndirectHeap *ioh = kernelOperation->ioh.get();
|
|
|
|
IndirectHeap *ssh = kernelOperation->ssh.get();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
auto requiresCoherency = false;
|
2019-08-22 23:02:37 +08:00
|
|
|
auto anyUncacheableArgs = false;
|
2017-12-21 07:45:38 +08:00
|
|
|
for (auto &surface : surfaces) {
|
|
|
|
DEBUG_BREAK_IF(!surface);
|
|
|
|
surface->makeResident(commandStreamReceiver);
|
|
|
|
requiresCoherency |= surface->IsCoherent;
|
2019-08-22 23:02:37 +08:00
|
|
|
if (!surface->allowsL3Caching()) {
|
|
|
|
anyUncacheableArgs = true;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (printfHandler) {
|
|
|
|
printfHandler.get()->makeResident(commandStreamReceiver);
|
|
|
|
}
|
2019-09-04 15:33:21 +08:00
|
|
|
makeTimestampPacketsResident(commandStreamReceiver);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
if (executionModelKernel) {
|
|
|
|
uint32_t taskCount = commandStreamReceiver.peekTaskCount() + 1;
|
2019-08-23 19:50:46 +08:00
|
|
|
devQueue->setupExecutionModelDispatch(*ssh, *dsh, kernel, kernelCount,
|
2019-11-13 22:37:52 +08:00
|
|
|
commandStreamReceiver.getTagAllocation()->getGpuAddress(), taskCount, timestamp, isCcsUsed);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-02-19 23:32:00 +08:00
|
|
|
SchedulerKernel &scheduler = commandQueue.getContext().getSchedulerKernel();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
scheduler.setArgs(devQueue->getQueueBuffer(),
|
|
|
|
devQueue->getStackBuffer(),
|
|
|
|
devQueue->getEventPoolBuffer(),
|
|
|
|
devQueue->getSlbBuffer(),
|
2018-04-05 21:12:28 +08:00
|
|
|
dsh->getGraphicsAllocation(),
|
2017-12-21 07:45:38 +08:00
|
|
|
kernel->getKernelReflectionSurface(),
|
|
|
|
devQueue->getQueueStorageBuffer(),
|
2018-04-05 21:12:28 +08:00
|
|
|
ssh->getGraphicsAllocation(),
|
2017-12-21 07:45:38 +08:00
|
|
|
devQueue->getDebugQueue());
|
|
|
|
|
|
|
|
devQueue->dispatchScheduler(
|
2019-02-25 16:42:15 +08:00
|
|
|
*kernelOperation->commandStream,
|
2018-03-02 05:43:04 +08:00
|
|
|
scheduler,
|
2018-04-05 21:12:28 +08:00
|
|
|
preemptionMode,
|
|
|
|
ssh,
|
2019-11-13 22:37:52 +08:00
|
|
|
dsh,
|
|
|
|
isCcsUsed);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
scheduler.makeResident(commandStreamReceiver);
|
|
|
|
|
|
|
|
// Update SLM usage
|
2021-03-22 19:06:23 +08:00
|
|
|
slmUsed |= scheduler.getSlmTotalSize() > 0;
|
2018-03-27 15:24:26 +08:00
|
|
|
|
|
|
|
this->kernel->getProgram()->getBlockKernelManager()->makeInternalAllocationsResident(commandStreamReceiver);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-11-18 20:35:44 +08:00
|
|
|
if (kernelOperation->blitPropertiesContainer.size() > 0) {
|
2020-01-27 20:06:03 +08:00
|
|
|
CsrDependencies csrDeps;
|
2021-09-18 01:09:06 +08:00
|
|
|
eventsRequest.fillCsrDependenciesForTimestampPacketContainer(csrDeps, *bcsCsrForAuxTranslation, CsrDependencies::DependenciesType::All);
|
2020-01-27 20:06:03 +08:00
|
|
|
|
2019-11-18 20:35:44 +08:00
|
|
|
BlitProperties::setupDependenciesForAuxTranslation(kernelOperation->blitPropertiesContainer, *timestampPacketDependencies,
|
2020-01-27 20:06:03 +08:00
|
|
|
*currentTimestampPacketNodes, csrDeps,
|
2021-09-18 01:09:06 +08:00
|
|
|
commandQueue.getGpgpuCommandStreamReceiver(), *bcsCsrForAuxTranslation);
|
2019-11-18 20:35:44 +08:00
|
|
|
}
|
|
|
|
|
2021-11-24 00:23:18 +08:00
|
|
|
if (timestampPacketDependencies && commandQueue.isOOQEnabled()) {
|
|
|
|
commandQueue.setupBarrierTimestampForBcsEngines(commandQueue.getGpgpuCommandStreamReceiver().getOsContext().getEngineType(), *timestampPacketDependencies);
|
|
|
|
}
|
|
|
|
|
2021-03-22 23:26:03 +08:00
|
|
|
const auto &kernelDescriptor = kernel->getKernelInfo().kernelDescriptor;
|
2020-12-07 22:41:52 +08:00
|
|
|
|
2021-08-02 18:44:48 +08:00
|
|
|
auto memoryCompressionState = commandStreamReceiver.getMemoryCompressionState(kernel->isAuxTranslationRequired(), commandQueue.getDevice().getHardwareInfo());
|
2020-12-17 08:36:45 +08:00
|
|
|
|
2019-09-13 18:00:30 +08:00
|
|
|
DispatchFlags dispatchFlags(
|
2021-03-22 23:26:03 +08:00
|
|
|
{}, //csrDependencies
|
|
|
|
nullptr, //barrierTimestampPacketNodes
|
|
|
|
{false, kernel->isVmeKernel()}, //pipelineSelectArgs
|
|
|
|
commandQueue.flushStamp->getStampReference(), //flushStampReference
|
|
|
|
commandQueue.getThrottle(), //throttle
|
|
|
|
preemptionMode, //preemptionMode
|
|
|
|
kernelDescriptor.kernelAttributes.numGrfRequired, //numGrfRequired
|
|
|
|
L3CachingSettings::l3CacheOn, //l3CacheSettings
|
|
|
|
kernel->getThreadArbitrationPolicy(), //threadArbitrationPolicy
|
|
|
|
kernel->getAdditionalKernelExecInfo(), //additionalKernelExecInfo
|
|
|
|
kernel->getExecutionType(), //kernelExecutionType
|
|
|
|
memoryCompressionState, //memoryCompressionState
|
|
|
|
commandQueue.getSliceCount(), //sliceCount
|
|
|
|
true, //blocking
|
|
|
|
flushDC, //dcFlush
|
|
|
|
slmUsed, //useSLM
|
|
|
|
true, //guardCommandBufferWithPipeControl
|
|
|
|
NDRangeKernel, //GSBA32BitRequired
|
|
|
|
requiresCoherency, //requiresCoherency
|
|
|
|
commandQueue.getPriority() == QueuePriority::LOW, //lowPriority
|
|
|
|
false, //implicitFlush
|
|
|
|
commandQueue.getGpgpuCommandStreamReceiver().isNTo1SubmissionModelEnabled(), //outOfOrderExecutionAllowed
|
|
|
|
false, //epilogueRequired
|
|
|
|
kernel->requiresPerDssBackedBuffer(), //usePerDssBackedBuffer
|
|
|
|
kernel->isSingleSubdevicePreferred(), //useSingleSubdevice
|
|
|
|
kernel->getKernelInfo().kernelDescriptor.kernelAttributes.flags.useGlobalAtomics, //useGlobalAtomics
|
2021-07-02 00:00:22 +08:00
|
|
|
kernel->areMultipleSubDevicesInContext(), //areMultipleSubDevicesInContext
|
2021-12-06 18:01:46 +08:00
|
|
|
kernel->requiresMemoryMigration(), //memoryMigrationRequired
|
|
|
|
false); //textureCacheFlush
|
2019-09-13 18:00:30 +08:00
|
|
|
|
2021-06-14 23:33:53 +08:00
|
|
|
if (commandQueue.getContext().getRootDeviceIndices().size() > 1) {
|
|
|
|
eventsRequest.fillCsrDependenciesForTaskCountContainer(dispatchFlags.csrDependencies, commandStreamReceiver);
|
|
|
|
}
|
|
|
|
|
2021-11-24 00:23:18 +08:00
|
|
|
const bool isHandlingBarrier = commandQueue.getGpgpuCommandStreamReceiver().isStallingCommandsOnNextFlushRequired();
|
|
|
|
|
2019-11-18 20:35:44 +08:00
|
|
|
if (timestampPacketDependencies) {
|
2021-03-11 21:48:04 +08:00
|
|
|
eventsRequest.fillCsrDependenciesForTimestampPacketContainer(dispatchFlags.csrDependencies, commandStreamReceiver, CsrDependencies::DependenciesType::OutOfCsr);
|
2021-11-24 00:23:18 +08:00
|
|
|
if (isHandlingBarrier) {
|
|
|
|
commandQueue.fillCsrDependenciesWithLastBcsPackets(dispatchFlags.csrDependencies);
|
|
|
|
}
|
2019-11-18 20:35:44 +08:00
|
|
|
dispatchFlags.barrierTimestampPacketNodes = ×tampPacketDependencies->barrierNodes;
|
2018-09-20 01:34:33 +08:00
|
|
|
}
|
2019-09-10 22:13:11 +08:00
|
|
|
dispatchFlags.pipelineSelectArgs.specialPipelineSelectMode = kernel->requiresSpecialPipelineSelectMode();
|
2019-08-22 23:02:37 +08:00
|
|
|
if (anyUncacheableArgs) {
|
|
|
|
dispatchFlags.l3CacheSettings = L3CachingSettings::l3CacheOff;
|
2019-08-26 23:03:13 +08:00
|
|
|
} else if (!kernel->areStatelessWritesUsed()) {
|
|
|
|
dispatchFlags.l3CacheSettings = L3CachingSettings::l3AndL1On;
|
2019-08-22 23:02:37 +08:00
|
|
|
}
|
|
|
|
|
2019-10-28 11:23:14 +08:00
|
|
|
if (commandQueue.dispatchHints != 0) {
|
|
|
|
dispatchFlags.engineHints = commandQueue.dispatchHints;
|
|
|
|
dispatchFlags.epilogueRequired = true;
|
|
|
|
}
|
|
|
|
|
2020-06-16 19:19:11 +08:00
|
|
|
DEBUG_BREAK_IF(taskLevel >= CompletionStamp::notReady);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-02-08 23:00:20 +08:00
|
|
|
gtpinNotifyPreFlushTask(&commandQueue);
|
|
|
|
|
2021-07-02 00:00:22 +08:00
|
|
|
if (kernel->requiresMemoryMigration()) {
|
|
|
|
for (auto &arg : kernel->getMemObjectsToMigrate()) {
|
|
|
|
MigrationController::handleMigration(commandQueue.getContext(), commandStreamReceiver, arg.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-18 22:23:15 +08:00
|
|
|
completionStamp = commandStreamReceiver.flushTask(*kernelOperation->commandStream,
|
|
|
|
0,
|
2017-12-21 07:45:38 +08:00
|
|
|
*dsh,
|
|
|
|
*ioh,
|
2018-04-05 21:12:28 +08:00
|
|
|
*ssh,
|
2017-12-21 07:45:38 +08:00
|
|
|
taskLevel,
|
2018-08-01 16:01:41 +08:00
|
|
|
dispatchFlags,
|
|
|
|
commandQueue.getDevice());
|
2018-12-04 21:18:17 +08:00
|
|
|
|
2021-11-24 00:23:18 +08:00
|
|
|
if (isHandlingBarrier) {
|
|
|
|
commandQueue.clearLastBcsPackets();
|
|
|
|
}
|
|
|
|
|
2020-06-19 22:33:53 +08:00
|
|
|
if (kernelOperation->blitPropertiesContainer.size() > 0) {
|
2021-09-10 00:57:09 +08:00
|
|
|
const auto newTaskCount = bcsCsrForAuxTranslation->blitBuffer(kernelOperation->blitPropertiesContainer, false, commandQueue.isProfilingEnabled(), commandQueue.getDevice());
|
|
|
|
commandQueue.updateBcsTaskCount(bcsCsrForAuxTranslation->getOsContext().getEngineType(), newTaskCount);
|
2020-06-19 22:33:53 +08:00
|
|
|
}
|
2020-06-26 17:21:07 +08:00
|
|
|
commandQueue.updateLatestSentEnqueueType(EnqueueProperties::Operation::GpuKernel);
|
2020-06-19 22:33:53 +08:00
|
|
|
|
2020-02-19 23:32:40 +08:00
|
|
|
if (gtpinIsGTPinInitialized()) {
|
|
|
|
gtpinNotifyFlushTask(completionStamp.taskCount);
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
if (printfHandler) {
|
2021-09-10 00:57:09 +08:00
|
|
|
commandQueue.waitUntilComplete(completionStamp.taskCount, {}, completionStamp.flushStamp, false);
|
2017-12-21 07:45:38 +08:00
|
|
|
printfHandler.get()->printEnqueueOutput();
|
|
|
|
}
|
|
|
|
|
2019-07-19 14:06:40 +08:00
|
|
|
for (auto surface : surfaces) {
|
|
|
|
delete surface;
|
|
|
|
}
|
|
|
|
surfaces.clear();
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
return completionStamp;
|
|
|
|
}
|
|
|
|
|
2019-11-16 18:59:18 +08:00
|
|
|
void CommandWithoutKernel::dispatchBlitOperation() {
|
2021-08-26 23:31:09 +08:00
|
|
|
auto bcsCsr = kernelOperation->bcsCsr;
|
2019-11-30 00:34:18 +08:00
|
|
|
UNRECOVERABLE_IF(bcsCsr == nullptr);
|
2019-09-04 15:33:21 +08:00
|
|
|
|
2019-11-07 16:15:53 +08:00
|
|
|
UNRECOVERABLE_IF(kernelOperation->blitPropertiesContainer.size() != 1);
|
|
|
|
auto &blitProperties = *kernelOperation->blitPropertiesContainer.begin();
|
2021-03-11 21:48:04 +08:00
|
|
|
eventsRequest.fillCsrDependenciesForTimestampPacketContainer(blitProperties.csrDependencies, *bcsCsr, CsrDependencies::DependenciesType::All);
|
|
|
|
blitProperties.csrDependencies.timestampPacketContainer.push_back(×tampPacketDependencies->cacheFlushNodes);
|
|
|
|
blitProperties.csrDependencies.timestampPacketContainer.push_back(×tampPacketDependencies->previousEnqueueNodes);
|
|
|
|
blitProperties.csrDependencies.timestampPacketContainer.push_back(×tampPacketDependencies->barrierNodes);
|
2019-11-13 00:56:10 +08:00
|
|
|
blitProperties.outputTimestampPacket = currentTimestampPacketNodes->peekNodes()[0];
|
2019-09-04 15:33:21 +08:00
|
|
|
|
2021-06-14 23:33:53 +08:00
|
|
|
if (commandQueue.getContext().getRootDeviceIndices().size() > 1) {
|
|
|
|
eventsRequest.fillCsrDependenciesForTaskCountContainer(blitProperties.csrDependencies, *bcsCsr);
|
|
|
|
}
|
|
|
|
|
2021-09-18 01:09:06 +08:00
|
|
|
const auto newTaskCount = bcsCsr->blitBuffer(kernelOperation->blitPropertiesContainer, false, commandQueue.isProfilingEnabled(), commandQueue.getDevice());
|
|
|
|
commandQueue.updateBcsTaskCount(bcsCsr->getOsContext().getEngineType(), newTaskCount);
|
2021-11-24 00:23:18 +08:00
|
|
|
commandQueue.setLastBcsPacket(bcsCsr->getOsContext().getEngineType());
|
2019-09-04 15:33:21 +08:00
|
|
|
}
|
|
|
|
|
2019-09-02 18:49:36 +08:00
|
|
|
CompletionStamp &CommandWithoutKernel::submit(uint32_t taskLevel, bool terminated) {
|
2019-07-23 03:28:59 +08:00
|
|
|
if (terminated) {
|
|
|
|
return completionStamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto &commandStreamReceiver = commandQueue.getGpgpuCommandStreamReceiver();
|
2019-07-23 02:55:09 +08:00
|
|
|
|
|
|
|
if (!kernelOperation) {
|
|
|
|
completionStamp.taskCount = commandStreamReceiver.peekTaskCount();
|
|
|
|
completionStamp.taskLevel = commandStreamReceiver.peekTaskLevel();
|
|
|
|
completionStamp.flushStamp = commandStreamReceiver.obtainCurrentFlushStamp();
|
|
|
|
|
|
|
|
return completionStamp;
|
|
|
|
}
|
|
|
|
|
2021-06-14 23:33:53 +08:00
|
|
|
auto barrierNodes = timestampPacketDependencies ? ×tampPacketDependencies->barrierNodes : nullptr;
|
2019-07-23 02:55:09 +08:00
|
|
|
auto lockCSR = commandStreamReceiver.obtainUniqueOwnership();
|
|
|
|
|
2020-06-26 17:21:07 +08:00
|
|
|
auto enqueueOperationType = EnqueueProperties::Operation::DependencyResolveOnGpu;
|
|
|
|
|
2019-09-04 15:33:21 +08:00
|
|
|
if (kernelOperation->blitEnqueue) {
|
2020-06-26 17:21:07 +08:00
|
|
|
enqueueOperationType = EnqueueProperties::Operation::Blit;
|
|
|
|
|
2021-06-14 23:33:53 +08:00
|
|
|
UNRECOVERABLE_IF(!barrierNodes);
|
2021-11-06 09:42:54 +08:00
|
|
|
if (commandStreamReceiver.isStallingCommandsOnNextFlushRequired()) {
|
2021-06-14 23:33:53 +08:00
|
|
|
barrierNodes->add(commandStreamReceiver.getTimestampPacketAllocator()->getTag());
|
2019-11-12 16:37:16 +08:00
|
|
|
}
|
2019-09-04 15:33:21 +08:00
|
|
|
}
|
|
|
|
|
2021-11-24 00:23:18 +08:00
|
|
|
if (timestampPacketDependencies && commandQueue.isOOQEnabled()) {
|
|
|
|
commandQueue.setupBarrierTimestampForBcsEngines(commandQueue.getGpgpuCommandStreamReceiver().getOsContext().getEngineType(), *timestampPacketDependencies);
|
|
|
|
}
|
|
|
|
|
2021-07-02 00:00:22 +08:00
|
|
|
auto rootDeviceIndex = commandStreamReceiver.getRootDeviceIndex();
|
2019-09-13 18:00:30 +08:00
|
|
|
DispatchFlags dispatchFlags(
|
2021-07-02 00:00:22 +08:00
|
|
|
{}, //csrDependencies
|
|
|
|
barrierNodes, //barrierTimestampPacketNodes
|
|
|
|
{}, //pipelineSelectArgs
|
|
|
|
commandQueue.flushStamp->getStampReference(), //flushStampReference
|
|
|
|
commandQueue.getThrottle(), //throttle
|
|
|
|
commandQueue.getDevice().getPreemptionMode(), //preemptionMode
|
|
|
|
GrfConfig::NotApplicable, //numGrfRequired
|
|
|
|
L3CachingSettings::NotApplicable, //l3CacheSettings
|
|
|
|
ThreadArbitrationPolicy::NotPresent, //threadArbitrationPolicy
|
|
|
|
AdditionalKernelExecInfo::NotApplicable, //additionalKernelExecInfo
|
|
|
|
KernelExecutionType::NotApplicable, //kernelExecutionType
|
|
|
|
MemoryCompressionState::NotApplicable, //memoryCompressionState
|
|
|
|
commandQueue.getSliceCount(), //sliceCount
|
|
|
|
true, //blocking
|
|
|
|
false, //dcFlush
|
|
|
|
false, //useSLM
|
|
|
|
true, //guardCommandBufferWithPipeControl
|
|
|
|
false, //GSBA32BitRequired
|
|
|
|
false, //requiresCoherency
|
|
|
|
commandQueue.getPriority() == QueuePriority::LOW, //lowPriority
|
|
|
|
false, //implicitFlush
|
|
|
|
commandStreamReceiver.isNTo1SubmissionModelEnabled(), //outOfOrderExecutionAllowed
|
|
|
|
false, //epilogueRequired
|
|
|
|
false, //usePerDssBackedBuffer
|
|
|
|
false, //useSingleSubdevice
|
|
|
|
false, //useGlobalAtomics
|
|
|
|
commandQueue.getContext().containsMultipleSubDevices(rootDeviceIndex), //areMultipleSubDevicesInContext
|
2021-12-06 18:01:46 +08:00
|
|
|
false, //memoryMigrationRequired
|
|
|
|
false); //textureCacheFlush
|
2019-07-23 02:55:09 +08:00
|
|
|
|
2021-06-14 23:33:53 +08:00
|
|
|
if (commandQueue.getContext().getRootDeviceIndices().size() > 1) {
|
|
|
|
eventsRequest.fillCsrDependenciesForTaskCountContainer(dispatchFlags.csrDependencies, commandStreamReceiver);
|
|
|
|
}
|
2019-07-23 02:55:09 +08:00
|
|
|
|
2021-11-24 00:23:18 +08:00
|
|
|
const bool isHandlingBarrier = commandQueue.getGpgpuCommandStreamReceiver().isStallingCommandsOnNextFlushRequired();
|
|
|
|
|
2021-06-22 21:16:27 +08:00
|
|
|
if (commandStreamReceiver.peekTimestampPacketWriteEnabled()) {
|
|
|
|
eventsRequest.fillCsrDependenciesForTimestampPacketContainer(dispatchFlags.csrDependencies, commandStreamReceiver, CsrDependencies::DependenciesType::OutOfCsr);
|
2021-11-24 00:23:18 +08:00
|
|
|
if (isHandlingBarrier) {
|
|
|
|
commandQueue.fillCsrDependenciesWithLastBcsPackets(dispatchFlags.csrDependencies);
|
|
|
|
}
|
2021-06-22 21:16:27 +08:00
|
|
|
makeTimestampPacketsResident(commandStreamReceiver);
|
|
|
|
}
|
2019-07-23 02:55:09 +08:00
|
|
|
|
|
|
|
gtpinNotifyPreFlushTask(&commandQueue);
|
|
|
|
|
|
|
|
completionStamp = commandStreamReceiver.flushTask(*kernelOperation->commandStream,
|
|
|
|
0,
|
|
|
|
commandQueue.getIndirectHeap(IndirectHeap::DYNAMIC_STATE, 0u),
|
|
|
|
commandQueue.getIndirectHeap(IndirectHeap::INDIRECT_OBJECT, 0u),
|
|
|
|
commandQueue.getIndirectHeap(IndirectHeap::SURFACE_STATE, 0u),
|
|
|
|
taskLevel,
|
|
|
|
dispatchFlags,
|
|
|
|
commandQueue.getDevice());
|
2019-07-23 03:28:59 +08:00
|
|
|
|
2021-11-24 00:23:18 +08:00
|
|
|
if (isHandlingBarrier) {
|
|
|
|
commandQueue.clearLastBcsPackets();
|
|
|
|
}
|
|
|
|
|
2020-06-19 22:33:53 +08:00
|
|
|
if (kernelOperation->blitEnqueue) {
|
|
|
|
dispatchBlitOperation();
|
|
|
|
}
|
|
|
|
|
2020-06-26 17:21:07 +08:00
|
|
|
commandQueue.updateLatestSentEnqueueType(enqueueOperationType);
|
|
|
|
|
2019-07-23 03:28:59 +08:00
|
|
|
return completionStamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Command::setEventsRequest(EventsRequest &eventsRequest) {
|
2019-01-11 16:00:11 +08:00
|
|
|
this->eventsRequest = eventsRequest;
|
|
|
|
if (eventsRequest.numEventsInWaitList > 0) {
|
|
|
|
eventsWaitlist.resize(eventsRequest.numEventsInWaitList);
|
|
|
|
auto size = eventsRequest.numEventsInWaitList * sizeof(cl_event);
|
|
|
|
memcpy_s(&eventsWaitlist[0], size, eventsRequest.eventWaitList, size);
|
|
|
|
this->eventsRequest.eventWaitList = &eventsWaitlist[0];
|
2021-06-14 23:33:53 +08:00
|
|
|
for (cl_uint i = 0; i < eventsRequest.numEventsInWaitList; i++) {
|
|
|
|
auto event = castToObjectOrAbort<Event>(eventsRequest.eventWaitList[i]);
|
|
|
|
event->incRefInternal();
|
|
|
|
}
|
2019-01-11 16:00:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-16 18:59:18 +08:00
|
|
|
void Command::setTimestampPacketNode(TimestampPacketContainer ¤t, TimestampPacketDependencies &&dependencies) {
|
2018-11-27 20:07:41 +08:00
|
|
|
currentTimestampPacketNodes = std::make_unique<TimestampPacketContainer>();
|
2018-10-03 05:37:30 +08:00
|
|
|
currentTimestampPacketNodes->assignAndIncrementNodesRefCounts(current);
|
|
|
|
|
2019-11-16 18:59:18 +08:00
|
|
|
timestampPacketDependencies = std::make_unique<TimestampPacketDependencies>();
|
|
|
|
*timestampPacketDependencies = std::move(dependencies);
|
2018-08-30 14:18:50 +08:00
|
|
|
}
|
|
|
|
|
2019-07-23 03:28:59 +08:00
|
|
|
Command::~Command() {
|
2021-06-22 01:39:40 +08:00
|
|
|
if (commandQueue.getDeferredTimestampPackets() && timestampPacketDependencies.get()) {
|
|
|
|
timestampPacketDependencies->moveNodesToNewContainer(*commandQueue.getDeferredTimestampPackets());
|
|
|
|
}
|
|
|
|
|
2021-06-14 23:33:53 +08:00
|
|
|
for (cl_event &eventFromWaitList : eventsWaitlist) {
|
|
|
|
auto event = castToObjectOrAbort<Event>(eventFromWaitList);
|
|
|
|
event->decRefInternal();
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2019-07-23 03:28:59 +08:00
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-09-04 15:33:21 +08:00
|
|
|
void Command::makeTimestampPacketsResident(CommandStreamReceiver &commandStreamReceiver) {
|
2019-09-04 17:34:23 +08:00
|
|
|
if (commandStreamReceiver.peekTimestampPacketWriteEnabled()) {
|
|
|
|
for (cl_event &eventFromWaitList : eventsWaitlist) {
|
|
|
|
auto event = castToObjectOrAbort<Event>(eventFromWaitList);
|
2021-06-14 23:33:53 +08:00
|
|
|
if (event->getTimestampPacketNodes() && event->getCommandQueue()->getClDevice().getRootDeviceIndex() == commandStreamReceiver.getRootDeviceIndex()) {
|
2019-09-04 17:34:23 +08:00
|
|
|
event->getTimestampPacketNodes()->makeResident(commandStreamReceiver);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-23 02:55:09 +08:00
|
|
|
if (currentTimestampPacketNodes) {
|
|
|
|
currentTimestampPacketNodes->makeResident(commandStreamReceiver);
|
|
|
|
}
|
2019-11-16 18:59:18 +08:00
|
|
|
if (timestampPacketDependencies) {
|
2020-02-27 20:29:15 +08:00
|
|
|
timestampPacketDependencies->cacheFlushNodes.makeResident(commandStreamReceiver);
|
2019-11-16 18:59:18 +08:00
|
|
|
timestampPacketDependencies->previousEnqueueNodes.makeResident(commandStreamReceiver);
|
2019-07-23 02:55:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-23 03:28:59 +08:00
|
|
|
Command::Command(CommandQueue &commandQueue) : commandQueue(commandQueue) {}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-07-23 03:28:59 +08:00
|
|
|
Command::Command(CommandQueue &commandQueue, std::unique_ptr<KernelOperation> &kernelOperation)
|
|
|
|
: commandQueue(commandQueue), kernelOperation(std::move(kernelOperation)) {}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|