From 9cefc84edc1bd30087599d9c8b0eb92aaef8742d Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Wed, 26 Aug 2020 15:44:12 +0200 Subject: [PATCH] Unify waiting method Change-Id: I8e17d097e00f7d14c7243cc7989dd333807d5b44 Signed-off-by: Bartosz Dunajski --- opencl/source/command_queue/command_queue.cpp | 14 +++++++++ opencl/source/command_queue/command_queue.h | 1 + opencl/source/command_queue/enqueue_common.h | 29 ++----------------- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index 25d8e8a09b..f3c002e649 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -33,6 +33,7 @@ #include "opencl/source/helpers/queue_helpers.h" #include "opencl/source/mem_obj/buffer.h" #include "opencl/source/mem_obj/image.h" +#include "opencl/source/program/printf_handler.h" #include "CL/cl_ext.h" @@ -698,4 +699,17 @@ void CommandQueue::aubCaptureHook(bool &blocking, bool &clearAllDependencies, co } } +void CommandQueue::waitUntilComplete(bool blockedQueue, PrintfHandler *printfHandler) { + if (blockedQueue) { + while (isQueueBlocked()) { + } + } + + waitUntilComplete(taskCount, bcsTaskCount, flushStamp->peekStamp(), false); + + if (printfHandler) { + printfHandler->printEnqueueOutput(); + } +} + } // namespace NEO diff --git a/opencl/source/command_queue/command_queue.h b/opencl/source/command_queue/command_queue.h index 908bebcbcf..eb5e2bc478 100644 --- a/opencl/source/command_queue/command_queue.h +++ b/opencl/source/command_queue/command_queue.h @@ -216,6 +216,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> { MOCKABLE_VIRTUAL bool isQueueBlocked(); MOCKABLE_VIRTUAL void waitUntilComplete(uint32_t gpgpuTaskCountToWait, uint32_t bcsTaskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep); + void waitUntilComplete(bool blockedQueue, PrintfHandler *printfHandler); static uint32_t getTaskLevelFromWaitList(uint32_t taskLevel, cl_uint numEventsInWaitList, diff --git a/opencl/source/command_queue/enqueue_common.h b/opencl/source/command_queue/enqueue_common.h index 9d4b70c7f8..d22658b0da 100644 --- a/opencl/source/command_queue/enqueue_common.h +++ b/opencl/source/command_queue/enqueue_common.h @@ -380,16 +380,7 @@ void CommandQueueHw::enqueueHandler(Surface **surfacesForResidency, commandStreamRecieverOwnership.unlock(); if (blocking) { - if (blockQueue) { - while (isQueueBlocked()) { - } - waitUntilComplete(taskCount, bcsTaskCount, flushStamp->peekStamp(), false); - } else { - waitUntilComplete(taskCount, bcsTaskCount, flushStamp->peekStamp(), false); - if (printfHandler) { - printfHandler->printEnqueueOutput(); - } - } + waitUntilComplete(blockQueue, printfHandler.get()); } } @@ -1127,17 +1118,7 @@ void CommandQueueHw::enqueueBlit(const MultiDispatchInfo &multiDispat if (!blockQueue) { csrDeps.makeResident(getGpgpuCommandStreamReceiver()); - completionStamp = enqueueCommandWithoutKernel( - nullptr, - 0, - commandStream, - commandStreamStart, - blocking, - enqueueProperties, - timestampPacketDependencies, - eventsRequest, - eventBuilder, - taskLevel); + completionStamp = enqueueCommandWithoutKernel(nullptr, 0, commandStream, commandStreamStart, blocking, enqueueProperties, timestampPacketDependencies, eventsRequest, eventBuilder, taskLevel); if (eventBuilder.getEvent()) { eventBuilder.getEvent()->flushStamp->replaceStampObject(this->flushStamp->getStampReference()); @@ -1160,11 +1141,7 @@ void CommandQueueHw::enqueueBlit(const MultiDispatchInfo &multiDispat commandStreamRecieverOwnership.unlock(); if (blocking) { - if (blockQueue) { - while (isQueueBlocked()) { - } - } - waitUntilComplete(taskCount, bcsTaskCount, flushStamp->peekStamp(), false); + waitUntilComplete(blockQueue, nullptr); } } } // namespace NEO