From 5d4aca361ff9f136588ae5962eb054f3d415f867 Mon Sep 17 00:00:00 2001 From: Lukasz Jobczyk Date: Wed, 31 Aug 2022 10:32:13 +0000 Subject: [PATCH] Wait on timestamps in Event::wait Signed-off-by: Lukasz Jobczyk --- opencl/source/event/event.cpp | 3 ++- opencl/test/unit_test/event/event_tests.cpp | 10 ++++++++++ opencl/test/unit_test/mocks/mock_command_queue.h | 7 +++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/opencl/source/event/event.cpp b/opencl/source/event/event.cpp index 956ec73a36..3f2bb60735 100644 --- a/opencl/source/event/event.cpp +++ b/opencl/source/event/event.cpp @@ -428,7 +428,8 @@ inline WaitStatus Event::wait(bool blocking, bool useQuickKmdSleep) { } Range states{&bcsState, bcsState.isValid() ? 1u : 0u}; - const auto waitStatus = cmdQueue->waitUntilComplete(taskCount.load(), states, flushStamp->peekStamp(), useQuickKmdSleep); + auto waitedOnTimestamps = cmdQueue->waitForTimestamps(states, taskCount.load()); + const auto waitStatus = cmdQueue->waitUntilComplete(taskCount.load(), states, flushStamp->peekStamp(), useQuickKmdSleep, true, waitedOnTimestamps); if (waitStatus == WaitStatus::GpuHang) { return WaitStatus::GpuHang; } diff --git a/opencl/test/unit_test/event/event_tests.cpp b/opencl/test/unit_test/event/event_tests.cpp index ef9e6fa011..caf1a01e34 100644 --- a/opencl/test/unit_test/event/event_tests.cpp +++ b/opencl/test/unit_test/event/event_tests.cpp @@ -909,6 +909,16 @@ TEST_F(InternalsEventTest, givenPassingEventWhenWaitingForEventsThenWaititingIsS EXPECT_NE(Event::executionAbortedDueToGpuHang, passingEvent.peekExecutionStatus()); } +TEST_F(InternalsEventTest, givenEventWhenWaitThenWaitForTimestampsCalled) { + MockCommandQueue cmdQ(mockContext, pClDevice, nullptr, false); + MockEvent event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0); + EXPECT_FALSE(cmdQ.waitForTimestampsCalled); + + event.wait(false, false); + + EXPECT_TRUE(cmdQ.waitForTimestampsCalled); +} + TEST_F(InternalsEventTest, GivenProfilingWHENMapOperationTHENTimesSet) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; MockCommandQueue *pCmdQ = new MockCommandQueue(mockContext, pClDevice, props, false); diff --git a/opencl/test/unit_test/mocks/mock_command_queue.h b/opencl/test/unit_test/mocks/mock_command_queue.h index 5d9ddbe2e4..d7a011ac70 100644 --- a/opencl/test/unit_test/mocks/mock_command_queue.h +++ b/opencl/test/unit_test/mocks/mock_command_queue.h @@ -212,10 +212,13 @@ class MockCommandQueue : public CommandQueue { bool obtainTimestampPacketForCacheFlush(bool isCacheFlushRequired) const override { return isCacheFlushRequired; } - bool waitForTimestamps(Range copyEnginesToWait, uint32_t taskCount) override { return false; }; + bool waitForTimestamps(Range copyEnginesToWait, uint32_t taskCount) override { + waitForTimestampsCalled = true; + return false; + }; bool releaseIndirectHeapCalled = false; - + bool waitForTimestampsCalled = false; cl_int writeBufferRetValue = CL_SUCCESS; uint32_t writeBufferCounter = 0; bool writeBufferBlocking = false;