diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index 809883abff..0db59dbb88 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp @@ -14,6 +14,7 @@ #include "shared/source/helpers/flush_stamp.h" #include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/timestamp_packet.h" +#include "shared/source/memory_manager/internal_allocation_storage.h" #include "shared/source/os_interface/os_context.h" #include "shared/source/utilities/tag_allocator.h" #include "shared/test/common/fixtures/device_fixture.h" @@ -76,6 +77,16 @@ struct MyMockCsr : UltCommandStreamReceiver { return {false, false}; } + bool expectMemory(const void *gfxAddress, const void *srcAddress, + size_t length, uint32_t compareOperation) override { + expectMemoryParameterization.wasCalled = true; + expectMemoryParameterization.gfxAddress = gfxAddress; + expectMemoryParameterization.srcAddress = srcAddress; + expectMemoryParameterization.length = length; + expectMemoryParameterization.compareOperation = compareOperation; + return true; + } + struct FlushParameterization { bool wasCalled = false; FlushStamp flushStampToReturn = 1; @@ -103,6 +114,14 @@ struct MyMockCsr : UltCommandStreamReceiver { bool wasCalled = false; const std::string *kernelName = nullptr; } checkAndActivateAubSubCaptureParameterization; + + struct ExpectMemoryParameterization { + bool wasCalled = false; + const void *gfxAddress = nullptr; + const void *srcAddress = nullptr; + size_t length = 0; + uint32_t compareOperation = AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual; + } expectMemoryParameterization; }; template @@ -261,6 +280,34 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenPoll EXPECT_TRUE(mockAubCsr->pollForCompletionCalled); } +HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenExpectMemoryIsCalledThenBothCommandStreamReceiversAreCalled) { + uint32_t compareOperation = AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual; + uint8_t buffer[0x10000]{}; + size_t length = sizeof(buffer); + + auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csrWithAubDump->getRootDeviceIndex(), false, length}, buffer); + ASSERT_NE(nullptr, gfxAllocation); + + csrWithAubDump->makeResidentHostPtrAllocation(gfxAllocation); + csrWithAubDump->expectMemory(reinterpret_cast(gfxAllocation->getGpuAddress()), buffer, length, compareOperation); + + EXPECT_TRUE(csrWithAubDump->expectMemoryParameterization.wasCalled); + EXPECT_EQ(reinterpret_cast(gfxAllocation->getGpuAddress()), csrWithAubDump->expectMemoryParameterization.gfxAddress); + EXPECT_EQ(buffer, csrWithAubDump->expectMemoryParameterization.srcAddress); + EXPECT_EQ(length, csrWithAubDump->expectMemoryParameterization.length); + EXPECT_EQ(compareOperation, csrWithAubDump->expectMemoryParameterization.compareOperation); + + if (createAubCSR) { + EXPECT_TRUE(csrWithAubDump->getAubMockCsr().expectMemoryParameterization.wasCalled); + EXPECT_EQ(reinterpret_cast(gfxAllocation->getGpuAddress()), csrWithAubDump->getAubMockCsr().expectMemoryParameterization.gfxAddress); + EXPECT_EQ(buffer, csrWithAubDump->getAubMockCsr().expectMemoryParameterization.srcAddress); + EXPECT_EQ(length, csrWithAubDump->getAubMockCsr().expectMemoryParameterization.length); + EXPECT_EQ(compareOperation, csrWithAubDump->getAubMockCsr().expectMemoryParameterization.compareOperation); + } + + memoryManager->freeGraphicsMemoryImpl(gfxAllocation); +} + HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenCreatingAubCsrThenInitializeTagAllocation) { auto executionEnvironment = pDevice->getExecutionEnvironment(); executionEnvironment->initializeMemoryManager(); diff --git a/shared/source/command_stream/command_stream_receiver_with_aub_dump.h b/shared/source/command_stream/command_stream_receiver_with_aub_dump.h index 4277fd1000..11d0645dcd 100644 --- a/shared/source/command_stream/command_stream_receiver_with_aub_dump.h +++ b/shared/source/command_stream/command_stream_receiver_with_aub_dump.h @@ -48,6 +48,9 @@ class CommandStreamReceiverWithAUBDump : public BaseCSR { void pollForCompletion() override; + bool expectMemory(const void *gfxAddress, const void *srcAddress, + size_t length, uint32_t compareOperation) override; + std::unique_ptr aubCSR; }; diff --git a/shared/source/command_stream/command_stream_receiver_with_aub_dump.inl b/shared/source/command_stream/command_stream_receiver_with_aub_dump.inl index ec631f5134..2faf7d640e 100644 --- a/shared/source/command_stream/command_stream_receiver_with_aub_dump.inl +++ b/shared/source/command_stream/command_stream_receiver_with_aub_dump.inl @@ -95,4 +95,14 @@ void CommandStreamReceiverWithAUBDump::pollForCompletion() { } BaseCSR::pollForCompletion(); } + +template +bool CommandStreamReceiverWithAUBDump::expectMemory(const void *gfxAddress, const void *srcAddress, + size_t length, uint32_t compareOperation) { + if (aubCSR) { + [[maybe_unused]] auto result = aubCSR->expectMemory(gfxAddress, srcAddress, length, compareOperation); + DEBUG_BREAK_IF(!result); + } + return BaseCSR::expectMemory(gfxAddress, srcAddress, length, compareOperation); +} } // namespace NEO