From 7f7f1b8ac99b0311499e4c3ffbb5328da6378e1a Mon Sep 17 00:00:00 2001 From: "Mrozek, Michal" Date: Mon, 8 Jul 2019 16:27:36 +0200 Subject: [PATCH] Optimize waiting scheme in user events scenarios. - do not wait on map/unmap if zero copy resource. - do not wait in marker commands at all. Change-Id: I74cdd8320d13602bf662eed412ed2fcad1504989 Signed-off-by: Mrozek, Michal --- runtime/helpers/task_information.cpp | 5 +--- .../command_queue/command_queue_hw_tests.cpp | 24 ++++++++++++++++++- unit_tests/mocks/mock_buffer.h | 1 + 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/runtime/helpers/task_information.cpp b/runtime/helpers/task_information.cpp index 83cd76f292..2d62ff1b9c 100644 --- a/runtime/helpers/task_information.cpp +++ b/runtime/helpers/task_information.cpp @@ -76,9 +76,8 @@ CompletionStamp &CommandMapUnmap::submit(uint32_t taskLevel, bool terminated) { dispatchFlags, cmdQ.getDevice()); - cmdQ.waitUntilComplete(completionStamp.taskCount, completionStamp.flushStamp, false); - if (!memObj.isMemObjZeroCopy()) { + cmdQ.waitUntilComplete(completionStamp.taskCount, completionStamp.flushStamp, false); if (op == MAP) { memObj.transferDataToHostPtr(copySize, copyOffset); } else if (!readOnly) { @@ -283,8 +282,6 @@ CompletionStamp &CommandMarker::submit(uint32_t taskLevel, bool terminated) { dispatchFlags, cmdQ.getDevice()); - cmdQ.waitUntilComplete(completionStamp.taskCount, completionStamp.flushStamp, false); - return completionStamp; } } // namespace NEO diff --git a/unit_tests/command_queue/command_queue_hw_tests.cpp b/unit_tests/command_queue/command_queue_hw_tests.cpp index 0ef110206a..5a0d8dfea3 100644 --- a/unit_tests/command_queue/command_queue_hw_tests.cpp +++ b/unit_tests/command_queue/command_queue_hw_tests.cpp @@ -177,7 +177,7 @@ HWTEST_F(CommandQueueHwTest, addMapUnmapToWaitlistEventsDoesntAddDependenciesInt buffer->decRefInternal(); } -HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedThenTaskCountIsBeingWaited) { +HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedThenTaskCountIsNotBeingWaited) { auto buffer = new MockBuffer; CommandQueueHw *pHwQ = reinterpret_cast *>(pCmdQ); @@ -194,6 +194,28 @@ HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedThenT EXPECT_NE(nullptr, pHwQ->virtualEvent); pHwQ->virtualEvent->setStatus(CL_COMPLETE); + EXPECT_EQ(std::numeric_limits::max(), pHwQ->latestTaskCountWaited); + buffer->decRefInternal(); +} + +HWTEST_F(CommandQueueHwTest, givenMapCommandWhenZeroStateCommandIsSubmittedOnNonZeroCopyBufferThenTaskCountIsBeingWaited) { + auto buffer = new MockBuffer; + buffer->isZeroCopy = false; + CommandQueueHw *pHwQ = reinterpret_cast *>(pCmdQ); + + MockEventBuilder eventBuilder; + MemObjSizeArray size = {{1, 1, 1}}; + MemObjOffsetArray offset = {{0, 0, 0}}; + pHwQ->enqueueBlockedMapUnmapOperation(nullptr, + 0, + MAP, + buffer, + size, offset, false, + eventBuilder); + + EXPECT_NE(nullptr, pHwQ->virtualEvent); + pHwQ->virtualEvent->setStatus(CL_COMPLETE); + EXPECT_EQ(1u, pHwQ->latestTaskCountWaited); buffer->decRefInternal(); } diff --git a/unit_tests/mocks/mock_buffer.h b/unit_tests/mocks/mock_buffer.h index b8fa51da4e..3d7b3ffa8b 100644 --- a/unit_tests/mocks/mock_buffer.h +++ b/unit_tests/mocks/mock_buffer.h @@ -29,6 +29,7 @@ class MockBuffer : public MockBufferStorage, public Buffer { public: using Buffer::magic; using Buffer::offset; + using MemObj::isZeroCopy; using MockBufferStorage::device; MockBuffer(GraphicsAllocation &alloc)