From ec0321068734553c80f2d29a43d338eda9ba1cfa Mon Sep 17 00:00:00 2001 From: Filip Hazubski Date: Mon, 14 Jan 2019 12:52:44 +0100 Subject: [PATCH] Update clEnqueueVerifyMemory - return success also for non aub CSRs Change-Id: Iac7fdcd58e4b76a325ef67fd266f183d779ca956 Signed-off-by: Filip Hazubski --- runtime/api/api.cpp | 8 ++---- .../aub_command_stream_receiver_hw.h | 2 +- .../aub_command_stream_receiver_hw.inl | 5 +--- .../command_stream_receiver.cpp | 3 +-- .../command_stream/command_stream_receiver.h | 2 +- unit_tests/api/cl_enqueue_verify_memory.inl | 25 +------------------ .../aub_command_stream_receiver_2_tests.cpp | 3 +-- 7 files changed, 8 insertions(+), 40 deletions(-) diff --git a/runtime/api/api.cpp b/runtime/api/api.cpp index 1a05a93e84..20627a0963 100644 --- a/runtime/api/api.cpp +++ b/runtime/api/api.cpp @@ -4272,11 +4272,7 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueVerifyMemory(cl_command_queue commandQu } auto &csr = pCommandQueue->getCommandStreamReceiver(); - if (csr.expectMemory(allocationPtr, expectedData, sizeOfComparison, comparisonMode)) { - retVal = CL_SUCCESS; - return retVal; - } - - retVal = CL_INVALID_VALUE; + csr.expectMemory(allocationPtr, expectedData, sizeOfComparison, comparisonMode); + retVal = CL_SUCCESS; return retVal; } diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.h b/runtime/command_stream/aub_command_stream_receiver_hw.h index 12926db31c..16fec57e6a 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.h +++ b/runtime/command_stream/aub_command_stream_receiver_hw.h @@ -54,7 +54,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw::expectMemoryNotEqual(void *gfxAddres } template -bool AUBCommandStreamReceiverHw::expectMemory(const void *gfxAddress, const void *srcAddress, +void AUBCommandStreamReceiverHw::expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) { if (hardwareContext) { hardwareContext->expectMemory(reinterpret_cast(gfxAddress), srcAddress, length, compareOperation); - return true; } PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset, uint64_t entryBits) { @@ -708,8 +707,6 @@ bool AUBCommandStreamReceiverHw::expectMemory(const void *gfxAddress, }; this->ppgtt->pageWalk(reinterpret_cast(gfxAddress), length, 0, PageTableEntry::nonValidBits, walker, MemoryBanks::BankNotSpecified); - - return true; } template diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index 9275bbf1b4..fcd27b0bcf 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -392,9 +392,8 @@ TagAllocator *CommandStreamReceiver::getTimestampPacketAllocato return timestampPacketAllocator.get(); } -bool CommandStreamReceiver::expectMemory(const void *gfxAddress, const void *srcAddress, +void CommandStreamReceiver::expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) { - return false; } } // namespace OCLRT diff --git a/runtime/command_stream/command_stream_receiver.h b/runtime/command_stream/command_stream_receiver.h index 60dffb469a..2053aff11e 100644 --- a/runtime/command_stream/command_stream_receiver.h +++ b/runtime/command_stream/command_stream_receiver.h @@ -168,7 +168,7 @@ class CommandStreamReceiver { TagAllocator *getEventPerfCountAllocator(); TagAllocator *getTimestampPacketAllocator(); - virtual bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation); + virtual void expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation); protected: void cleanupResources(); diff --git a/unit_tests/api/cl_enqueue_verify_memory.inl b/unit_tests/api/cl_enqueue_verify_memory.inl index 806ed34a88..d293d9712a 100644 --- a/unit_tests/api/cl_enqueue_verify_memory.inl +++ b/unit_tests/api/cl_enqueue_verify_memory.inl @@ -51,30 +51,7 @@ TEST_F(clEnqueueVerifyMemoryTests, givenInvalidCommandQueueWhenCallingVerifyMemo EXPECT_EQ(CL_INVALID_COMMAND_QUEUE, retval); } -TEST_F(clEnqueueVerifyMemoryTests, givenCommandQueueWithoutAubCsrWhenCallingVerifyMemoryThenErrorIsReturned) { +TEST_F(clEnqueueVerifyMemoryTests, givenCommandQueueWithoutAubCsrWhenCallingVerifyMemoryThenSuccessIsReturned) { cl_int retval = clEnqueueVerifyMemory(pCommandQueue, gpuAddress, expected, expectedSize, comparisonMode); - EXPECT_EQ(CL_INVALID_VALUE, retval); -} - -template -struct MockCsrWithExpectMemory : MockCsr { - MockCsrWithExpectMemory() = delete; - MockCsrWithExpectMemory(const HardwareInfo &hwInfoIn) = delete; - MockCsrWithExpectMemory(int32_t &execStamp, ExecutionEnvironment &executionEnvironment) - : MockCsr(execStamp, executionEnvironment) { - } - bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override { - return true; - } -}; - -HWTEST_F(clEnqueueVerifyMemoryTests, givenCommandQueueWithMockAubCsrWhenCallingVerifyMemoryThenSuccessIsReturned) { - std::unique_ptr mockDevice(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); - int32_t executionStamp = 0; - auto *mockCsr = new MockCsrWithExpectMemory(executionStamp, *mockDevice.get()->executionEnvironment); - mockDevice.get()->resetCommandStreamReceiver(mockCsr); - CommandQueue cmdQ(nullptr, mockDevice.get(), 0); - - cl_int retval = clEnqueueVerifyMemory(&cmdQ, gpuAddress, expected, expectedSize, comparisonMode); EXPECT_EQ(CL_SUCCESS, retval); } diff --git a/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp index 6e893fb8b6..485411840f 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp @@ -813,10 +813,9 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenAskedForMemoryExpectation public: using AUBCommandStreamReceiverHw::AUBCommandStreamReceiverHw; - bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override { + void expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override { inputCompareOperation = compareOperation; AUBCommandStreamReceiverHw::expectMemory(gfxAddress, srcAddress, length, compareOperation); - return true; } uint32_t inputCompareOperation = 0; };