2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-13 20:15:03 +08:00
|
|
|
* Copyright (C) 2017-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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "runtime/helpers/task_information.h"
|
|
|
|
|
2020-01-22 23:22:30 +08:00
|
|
|
#include "core/command_stream/csr_deps.h"
|
2019-08-22 22:51:02 +08:00
|
|
|
#include "core/command_stream/linear_stream.h"
|
2019-11-27 19:59:47 +08:00
|
|
|
#include "core/command_stream/preemption.h"
|
2019-08-03 04:25:45 +08:00
|
|
|
#include "core/helpers/aligned_memory.h"
|
2019-12-11 19:29:46 +08:00
|
|
|
#include "core/helpers/engine_node_helper.h"
|
2019-06-19 15:21:29 +08:00
|
|
|
#include "core/helpers/string.h"
|
2020-01-21 18:00:03 +08:00
|
|
|
#include "core/memory_manager/internal_allocation_storage.h"
|
2020-02-05 23:07:52 +08:00
|
|
|
#include "core/memory_manager/surface.h"
|
2018-04-18 20:59:28 +08:00
|
|
|
#include "runtime/built_ins/builtins_dispatch_builder.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/command_queue/command_queue.h"
|
|
|
|
#include "runtime/command_queue/enqueue_common.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "runtime/command_stream/command_stream_receiver.h"
|
2020-01-27 20:59:19 +08:00
|
|
|
#include "runtime/device/cl_device.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/device_queue/device_queue.h"
|
2018-02-08 23:00:20 +08:00
|
|
|
#include "runtime/gtpin/gtpin_notify.h"
|
2019-11-07 16:15:53 +08:00
|
|
|
#include "runtime/helpers/enqueue_properties.h"
|
2019-07-19 03:15:50 +08:00
|
|
|
#include "runtime/helpers/task_information.inl"
|
2018-04-18 20:59:28 +08:00
|
|
|
#include "runtime/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
|
2019-11-27 19:59:47 +08:00
|
|
|
PreemptionHelper::taskPreemptionMode(device, multiDispatch), //preemptionMode
|
2019-09-25 17:30:19 +08:00
|
|
|
GrfConfig::DefaultGrfNumber, //numGrfRequired
|
|
|
|
L3CachingSettings::l3CacheOn, //l3CacheSettings
|
2019-11-12 20:59:37 +08:00
|
|
|
ThreadArbitrationPolicy::NotPresent, //threadArbitrationPolicy
|
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
|
|
|
|
false //usePerDssBackedBuffer
|
2019-09-13 18:00:30 +08:00
|
|
|
);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-23 18:57:37 +08:00
|
|
|
DEBUG_BREAK_IF(taskLevel >= CompletionStamp::levelNotReady);
|
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
|
|
|
|
2018-02-09 03:55:31 +08:00
|
|
|
if (!memObj.isMemObjZeroCopy()) {
|
2019-07-23 03:28:59 +08:00
|
|
|
commandQueue.waitUntilComplete(completionStamp.taskCount, completionStamp.flushStamp, false);
|
|
|
|
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,
|
2018-03-02 05:43:04 +08:00
|
|
|
bool flushDC, bool usesSLM, bool ndRangeKernel, std::unique_ptr<PrintfHandler> printfHandler,
|
|
|
|
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();
|
|
|
|
|
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
|
|
|
|
2018-08-22 19:57:21 +08:00
|
|
|
BuiltIns &builtIns = *this->kernel->getDevice().getExecutionEnvironment()->getBuiltIns();
|
2017-12-21 07:45:38 +08:00
|
|
|
SchedulerKernel &scheduler = builtIns.getSchedulerKernel(commandQueue.getContext());
|
|
|
|
|
|
|
|
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
|
|
|
|
slmUsed |= scheduler.slmTotalSize > 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) {
|
|
|
|
auto &bcsCsr = *commandQueue.getBcsCommandStreamReceiver();
|
2020-01-27 20:06:03 +08:00
|
|
|
CsrDependencies csrDeps;
|
|
|
|
eventsRequest.fillCsrDependencies(csrDeps, bcsCsr, CsrDependencies::DependenciesType::All);
|
|
|
|
|
2019-11-18 20:35:44 +08:00
|
|
|
BlitProperties::setupDependenciesForAuxTranslation(kernelOperation->blitPropertiesContainer, *timestampPacketDependencies,
|
2020-01-27 20:06:03 +08:00
|
|
|
*currentTimestampPacketNodes, csrDeps,
|
2019-11-18 20:35:44 +08:00
|
|
|
commandQueue.getGpgpuCommandStreamReceiver(), bcsCsr);
|
|
|
|
|
|
|
|
auto bcsTaskCount = bcsCsr.blitBuffer(kernelOperation->blitPropertiesContainer, false);
|
|
|
|
commandQueue.updateBcsTaskCount(bcsTaskCount);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{false, kernel->isVmeKernel()}, //pipelineSelectArgs
|
|
|
|
commandQueue.flushStamp->getStampReference(), //flushStampReference
|
|
|
|
commandQueue.getThrottle(), //throttle
|
|
|
|
preemptionMode, //preemptionMode
|
|
|
|
kernel->getKernelInfo().patchInfo.executionEnvironment->NumGRFRequired, //numGrfRequired
|
|
|
|
L3CachingSettings::l3CacheOn, //l3CacheSettings
|
2019-11-12 20:59:37 +08:00
|
|
|
kernel->getThreadArbitrationPolicy(), //threadArbitrationPolicy
|
2019-09-25 17:30:19 +08:00
|
|
|
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
|
2020-01-29 21:15:10 +08:00
|
|
|
false, //epilogueRequired
|
|
|
|
kernel->requiresPerDssBackedBuffer() //usePerDssBackedBuffer
|
2019-09-13 18:00:30 +08:00
|
|
|
);
|
|
|
|
|
2019-11-18 20:35:44 +08:00
|
|
|
if (timestampPacketDependencies) {
|
2020-01-22 23:22:30 +08:00
|
|
|
eventsRequest.fillCsrDependencies(dispatchFlags.csrDependencies, commandStreamReceiver, CsrDependencies::DependenciesType::OutOfCsr);
|
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-01-23 18:57:37 +08:00
|
|
|
DEBUG_BREAK_IF(taskLevel >= CompletionStamp::levelNotReady);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-02-08 23:00:20 +08:00
|
|
|
gtpinNotifyPreFlushTask(&commandQueue);
|
|
|
|
|
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
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
if (printfHandler) {
|
2019-07-08 19:57:04 +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() {
|
2019-09-04 15:33:21 +08:00
|
|
|
auto bcsCsr = commandQueue.getBcsCommandStreamReceiver();
|
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();
|
2020-01-22 23:22:30 +08:00
|
|
|
eventsRequest.fillCsrDependencies(blitProperties.csrDependencies, *bcsCsr, CsrDependencies::DependenciesType::All);
|
2019-11-16 18:59:18 +08:00
|
|
|
blitProperties.csrDependencies.push_back(×tampPacketDependencies->previousEnqueueNodes);
|
|
|
|
blitProperties.csrDependencies.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
|
|
|
|
2019-11-07 16:15:53 +08:00
|
|
|
auto bcsTaskCount = bcsCsr->blitBuffer(kernelOperation->blitPropertiesContainer, false);
|
2019-10-22 17:25:14 +08:00
|
|
|
|
|
|
|
commandQueue.updateBcsTaskCount(bcsTaskCount);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto lockCSR = commandStreamReceiver.obtainUniqueOwnership();
|
|
|
|
|
2019-09-04 15:33:21 +08:00
|
|
|
if (kernelOperation->blitEnqueue) {
|
2019-11-12 16:37:16 +08:00
|
|
|
if (commandStreamReceiver.isStallingPipeControlOnNextFlushRequired()) {
|
2019-11-16 18:59:18 +08:00
|
|
|
timestampPacketDependencies->barrierNodes.add(commandStreamReceiver.getTimestampPacketAllocator()->getTag());
|
2019-11-12 16:37:16 +08:00
|
|
|
}
|
2019-11-16 18:59:18 +08:00
|
|
|
dispatchBlitOperation();
|
2019-09-04 15:33:21 +08:00
|
|
|
}
|
|
|
|
|
2019-09-13 18:00:30 +08:00
|
|
|
DispatchFlags dispatchFlags(
|
|
|
|
{}, //csrDependencies
|
2019-11-16 18:59:18 +08:00
|
|
|
×tampPacketDependencies->barrierNodes, //barrierTimestampPacketNodes
|
2019-09-13 18:00:30 +08:00
|
|
|
{}, //pipelineSelectArgs
|
2019-09-25 17:30:19 +08:00
|
|
|
commandQueue.flushStamp->getStampReference(), //flushStampReference
|
2019-09-13 18:00:30 +08:00
|
|
|
commandQueue.getThrottle(), //throttle
|
|
|
|
commandQueue.getDevice().getPreemptionMode(), //preemptionMode
|
|
|
|
GrfConfig::DefaultGrfNumber, //numGrfRequired
|
|
|
|
L3CachingSettings::l3CacheOn, //l3CacheSettings
|
2019-11-12 20:59:37 +08:00
|
|
|
ThreadArbitrationPolicy::NotPresent, //threadArbitrationPolicy
|
2019-08-21 18:50:47 +08:00
|
|
|
commandQueue.getSliceCount(), //sliceCount
|
2019-09-13 18:00:30 +08:00
|
|
|
true, //blocking
|
|
|
|
false, //dcFlush
|
|
|
|
false, //useSLM
|
|
|
|
true, //guardCommandBufferWithPipeControl
|
|
|
|
false, //GSBA32BitRequired
|
|
|
|
false, //requiresCoherency
|
|
|
|
commandQueue.getPriority() == QueuePriority::LOW, //lowPriority
|
|
|
|
false, //implicitFlush
|
|
|
|
commandStreamReceiver.isNTo1SubmissionModelEnabled(), //outOfOrderExecutionAllowed
|
2020-01-29 21:15:10 +08:00
|
|
|
false, //epilogueRequired
|
|
|
|
false //usePerDssBackedBuffer
|
2019-09-13 18:00:30 +08:00
|
|
|
);
|
2019-07-23 02:55:09 +08:00
|
|
|
|
|
|
|
UNRECOVERABLE_IF(!commandStreamReceiver.peekTimestampPacketWriteEnabled());
|
|
|
|
|
2020-01-22 23:22:30 +08:00
|
|
|
eventsRequest.fillCsrDependencies(dispatchFlags.csrDependencies, commandStreamReceiver, CsrDependencies::DependenciesType::OutOfCsr);
|
2019-09-04 15:33:21 +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
|
|
|
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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() {
|
|
|
|
auto &commandStreamReceiver = commandQueue.getGpgpuCommandStreamReceiver();
|
|
|
|
if (commandStreamReceiver.peekTimestampPacketWriteEnabled()) {
|
|
|
|
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);
|
|
|
|
if (event->getTimestampPacketNodes()) {
|
|
|
|
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) {
|
|
|
|
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
|