From 93fe8a47944050abff269bb0ab840a536dff03d6 Mon Sep 17 00:00:00 2001 From: "Jobczyk, Lukasz" Date: Wed, 20 Apr 2022 09:13:26 +0000 Subject: [PATCH] Optimize gpgpu csr's mutex lock in the enqueue blit Signed-off-by: Jobczyk, Lukasz --- opencl/source/command_queue/enqueue_common.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/opencl/source/command_queue/enqueue_common.h b/opencl/source/command_queue/enqueue_common.h index c118b584ff..b33f78d407 100644 --- a/opencl/source/command_queue/enqueue_common.h +++ b/opencl/source/command_queue/enqueue_common.h @@ -1087,6 +1087,7 @@ template template cl_int CommandQueueHw::enqueueBlit(const MultiDispatchInfo &multiDispatchInfo, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event, bool blocking, CommandStreamReceiver &bcsCsr) { auto bcsCommandStreamReceiverOwnership = bcsCsr.obtainUniqueOwnership(); + std::unique_lock commandStreamReceiverOwnership; EventsRequest eventsRequest(numEventsInWaitList, eventWaitList, event); EventBuilder eventBuilder; @@ -1096,7 +1097,6 @@ cl_int CommandQueueHw::enqueueBlit(const MultiDispatchInfo &multiDisp std::unique_ptr blockedCommandsData; TakeOwnershipWrapper> queueOwnership(*this); - auto commandStreamReceiverOwnership = getGpgpuCommandStreamReceiver().obtainUniqueOwnership(); auto blockQueue = false; auto taskLevel = 0u; @@ -1145,6 +1145,7 @@ cl_int CommandQueueHw::enqueueBlit(const MultiDispatchInfo &multiDisp LinearStream *gpgpuCommandStream = {}; size_t gpgpuCommandStreamStart = {}; if (gpgpuSubmission) { + commandStreamReceiverOwnership = getGpgpuCommandStreamReceiver().obtainUniqueOwnership(); gpgpuCommandStream = obtainCommandStream(csrDeps, true, blockQueue, multiDispatchInfo, eventsRequest, blockedCommandsData, nullptr, 0, false); gpgpuCommandStreamStart = gpgpuCommandStream->getUsed(); } @@ -1156,6 +1157,10 @@ cl_int CommandQueueHw::enqueueBlit(const MultiDispatchInfo &multiDisp completionStamp = enqueueCommandWithoutKernel(nullptr, 0, gpgpuCommandStream, gpgpuCommandStreamStart, blocking, enqueueProperties, timestampPacketDependencies, eventsRequest, eventBuilder, taskLevel, csrDeps, &bcsCsr); + if (gpgpuSubmission) { + commandStreamReceiverOwnership.unlock(); + } + if (eventBuilder.getEvent()) { eventBuilder.getEvent()->flushStamp->replaceStampObject(this->flushStamp->getStampReference()); } @@ -1168,11 +1173,14 @@ cl_int CommandQueueHw::enqueueBlit(const MultiDispatchInfo &multiDisp if (blockQueue) { enqueueBlocked(cmdType, nullptr, 0, multiDispatchInfo, timestampPacketDependencies, blockedCommandsData, enqueueProperties, eventsRequest, eventBuilder, nullptr, &bcsCsr); + + if (gpgpuSubmission) { + commandStreamReceiverOwnership.unlock(); + } } timestampPacketDependencies.moveNodesToNewContainer(*deferredTimestampPackets); - commandStreamReceiverOwnership.unlock(); queueOwnership.unlock(); bcsCommandStreamReceiverOwnership.unlock();