diff --git a/runtime/aub/aub_center.cpp b/runtime/aub/aub_center.cpp index f3c85b2edd..ed2a4e7c00 100644 --- a/runtime/aub/aub_center.cpp +++ b/runtime/aub/aub_center.cpp @@ -14,8 +14,7 @@ #include "runtime/os_interface/debug_settings_manager.h" #include "third_party/aub_stream/headers/aub_manager.h" -#include "third_party/aub_stream/headers/modes.h" -#include "third_party/aub_stream/headers/options.h" +#include "third_party/aub_stream/headers/aubstream.h" namespace NEO { extern aub_stream::AubManager *createAubManager(uint32_t productFamily, uint32_t devicesCount, uint64_t memoryBankSize, bool localMemorySupported, uint32_t streamMode); diff --git a/runtime/aub/aub_helper_add_mmio.cpp b/runtime/aub/aub_helper_add_mmio.cpp index c59bf2f2bc..f3711f15a0 100644 --- a/runtime/aub/aub_helper_add_mmio.cpp +++ b/runtime/aub/aub_helper_add_mmio.cpp @@ -8,7 +8,7 @@ #include "runtime/aub/aub_helper.h" #include "runtime/os_interface/debug_settings_manager.h" -#include "third_party/aub_stream/headers/options.h" +#include "third_party/aub_stream/headers/aubstream.h" namespace NEO { diff --git a/runtime/aub_mem_dump/aub_stream_stubs.cpp b/runtime/aub_mem_dump/aub_stream_stubs.cpp index 190aa529a1..eb00834187 100644 --- a/runtime/aub_mem_dump/aub_stream_stubs.cpp +++ b/runtime/aub_mem_dump/aub_stream_stubs.cpp @@ -6,7 +6,7 @@ */ #include "third_party/aub_stream/headers/aub_manager.h" -#include "third_party/aub_stream/headers/options.h" +#include "third_party/aub_stream/headers/aubstream.h" namespace aub_stream_stubs { uint16_t tbxServerPort = 4321; diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index daa11c663c..125bd8f068 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -29,6 +29,7 @@ #include "driver_version.h" #include "hw_cmds.h" #include "third_party/aub_stream/headers/aub_manager.h" +#include "third_party/aub_stream/headers/aubstream.h" #include #include @@ -714,10 +715,19 @@ void AUBCommandStreamReceiverHw::dumpAllocation(GraphicsAllocation &g } if (hardwareContextController) { - if (AubAllocDump::DumpFormat::BUFFER_BIN == dumpFormat) { - auto gpuAddress = GmmHelper::decanonize(gfxAllocation.getGpuAddress()); - auto size = gfxAllocation.getUnderlyingBufferSize(); - hardwareContextController->dumpBufferBIN(gpuAddress, size); + auto gpuAddress = GmmHelper::decanonize(gfxAllocation.getGpuAddress()); + auto size = gfxAllocation.getUnderlyingBufferSize(); + auto compressed = GraphicsAllocation::AllocationType::BUFFER_COMPRESSED == gfxAllocation.getAllocationType(); + + switch (dumpFormat) { + case AubAllocDump::DumpFormat::BUFFER_BIN: + hardwareContextController->dumpBuffer(gpuAddress, size, aub_stream::dumpFormat::bin, compressed); + break; + case AubAllocDump::DumpFormat::BUFFER_TRE: + hardwareContextController->dumpBuffer(gpuAddress, size, aub_stream::dumpFormat::tre, compressed); + break; + default: + break; } return; } diff --git a/runtime/helpers/hardware_context_controller.cpp b/runtime/helpers/hardware_context_controller.cpp index 727c573a24..8387200648 100644 --- a/runtime/helpers/hardware_context_controller.cpp +++ b/runtime/helpers/hardware_context_controller.cpp @@ -56,6 +56,10 @@ void HardwareContextController::dumpBufferBIN(uint64_t gfxAddress, size_t size) hardwareContexts[0]->dumpBufferBIN(gfxAddress, size); } +void HardwareContextController::dumpBuffer(uint64_t gfxAddress, size_t size, uint32_t format, bool compressed) { + hardwareContexts[0]->dumpBuffer(gfxAddress, size, format, compressed); +} + void HardwareContextController::readMemory(uint64_t gfxAddress, void *memory, size_t size, uint32_t memoryBanks, size_t pageSize) { hardwareContexts[0]->readMemory(gfxAddress, memory, size, memoryBanks, pageSize); } diff --git a/runtime/helpers/hardware_context_controller.h b/runtime/helpers/hardware_context_controller.h index fcd21f899e..977d66e30f 100644 --- a/runtime/helpers/hardware_context_controller.h +++ b/runtime/helpers/hardware_context_controller.h @@ -27,6 +27,7 @@ class HardwareContextController { void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize); void dumpBufferBIN(uint64_t gfxAddress, size_t size); + void dumpBuffer(uint64_t gfxAddress, size_t size, uint32_t format, bool compressed); void readMemory(uint64_t gfxAddress, void *memory, size_t size, uint32_t memoryBanks, size_t pageSize); std::vector> hardwareContexts; diff --git a/third_party/aub_stream/headers/options.h b/third_party/aub_stream/headers/aubstream.h similarity index 63% rename from third_party/aub_stream/headers/options.h rename to third_party/aub_stream/headers/aubstream.h index 94c892b8bf..b3268ad3d4 100644 --- a/third_party/aub_stream/headers/options.h +++ b/third_party/aub_stream/headers/aubstream.h @@ -13,6 +13,18 @@ namespace aub_stream { +namespace dumpFormat { +constexpr uint32_t bin = 0; +constexpr uint32_t bmp = 1; +constexpr uint32_t tre = 2; +} // namespace dumpFormat + +namespace mode { +constexpr uint32_t aubFile = 0; +constexpr uint32_t tbx = 1; +constexpr uint32_t aubFileAndTbx = 2; +} // namespace mode + using MMIOPair = std::pair; using MMIOList = std::vector; diff --git a/third_party/aub_stream/headers/hardware_context.h b/third_party/aub_stream/headers/hardware_context.h index ee3e0067fb..31f223035c 100644 --- a/third_party/aub_stream/headers/hardware_context.h +++ b/third_party/aub_stream/headers/hardware_context.h @@ -20,6 +20,7 @@ struct HardwareContext { virtual void expectMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t compareOperation) = 0; virtual void readMemory(uint64_t gfxAddress, void *memory, size_t size, uint32_t memoryBanks, size_t pageSize) = 0; virtual void dumpBufferBIN(uint64_t gfxAddress, size_t size) = 0; + virtual void dumpBuffer(uint64_t gfxAddress, size_t size, uint32_t format, bool compressed) = 0; virtual ~HardwareContext() = default; }; diff --git a/third_party/aub_stream/headers/modes.h b/third_party/aub_stream/headers/modes.h deleted file mode 100644 index 7e77d75c73..0000000000 --- a/third_party/aub_stream/headers/modes.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#pragma once -#include - -namespace aub_stream { -namespace mode { -constexpr uint32_t aubFile = 0; -constexpr uint32_t tbx = 1; -constexpr uint32_t aubFileAndTbx = 2; -} // namespace mode -} // namespace aub_stream diff --git a/unit_tests/aub/aub_center_tests.cpp b/unit_tests/aub/aub_center_tests.cpp index 94b9e698f7..258402bfdc 100644 --- a/unit_tests/aub/aub_center_tests.cpp +++ b/unit_tests/aub/aub_center_tests.cpp @@ -14,7 +14,8 @@ #include "unit_tests/mocks/mock_aub_manager.h" #include "gtest/gtest.h" -#include "third_party/aub_stream/headers/modes.h" +#include "third_party/aub_stream/headers/aubstream.h" + using namespace NEO; TEST(AubCenter, GivenUseAubStreamDebugVariableNotSetWhenAubCenterIsCreatedThenAubCenterDoesNotCreateAubManager) { diff --git a/unit_tests/aub/aub_center_using_aubstream_stubs_tests.cpp b/unit_tests/aub/aub_center_using_aubstream_stubs_tests.cpp index 598ce4be06..ed8c701c1f 100644 --- a/unit_tests/aub/aub_center_using_aubstream_stubs_tests.cpp +++ b/unit_tests/aub/aub_center_using_aubstream_stubs_tests.cpp @@ -13,7 +13,8 @@ #include "unit_tests/mocks/mock_aub_center.h" #include "gtest/gtest.h" -#include "third_party/aub_stream/headers/options.h" +#include "third_party/aub_stream/headers/aubstream.h" + using namespace NEO; namespace aub_stream_stubs { diff --git a/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp index 30f7e3b06a..b844a98bf2 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/aub_mem_dump/aub_alloc_dump.h" #include "runtime/aub_mem_dump/page_table_entry_bits.h" #include "runtime/helpers/hardware_context_controller.h" #include "runtime/helpers/hw_helper.h" @@ -1154,14 +1155,19 @@ TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCa EXPECT_FALSE(mockHwContext0->dumpBufferBINCalled); EXPECT_FALSE(mockHwContext1->dumpBufferBINCalled); + EXPECT_FALSE(mockHwContext0->dumpBufferCalled); + EXPECT_FALSE(mockHwContext1->dumpBufferCalled); EXPECT_FALSE(mockHwContext0->readMemoryCalled); EXPECT_FALSE(mockHwContext1->readMemoryCalled); hwContextContainer.dumpBufferBIN(1, 2); + hwContextContainer.dumpBuffer(1, 2, AubAllocDump::DumpFormat::BUFFER_BIN, false); hwContextContainer.readMemory(1, reinterpret_cast(0x123), 1, 2, 0); EXPECT_TRUE(mockHwContext0->dumpBufferBINCalled); EXPECT_FALSE(mockHwContext1->dumpBufferBINCalled); + EXPECT_TRUE(mockHwContext0->dumpBufferCalled); + EXPECT_FALSE(mockHwContext1->dumpBufferCalled); EXPECT_TRUE(mockHwContext0->readMemoryCalled); EXPECT_FALSE(mockHwContext1->readMemoryCalled); } 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 f79fa6aff5..453c21236e 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 @@ -26,7 +26,7 @@ #include "unit_tests/mocks/mock_mdi.h" #include "unit_tests/mocks/mock_os_context.h" -#include "third_party/aub_stream/headers/options.h" +#include "third_party/aub_stream/headers/aubstream.h" using namespace NEO; @@ -901,7 +901,33 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpA aubCsr.dumpAllocation(*gfxAllocation); - EXPECT_TRUE(mockHardwareContext->dumpBufferBINCalled); + EXPECT_TRUE(mockHardwareContext->dumpBufferCalled); + + memoryManager->freeGraphicsMemory(gfxAllocation); +} + +HWTEST_F(AubCommandStreamReceiverTests, givenCompressedGraphicsAllocationWritableWhenDumpAllocationIsCalledAndDumpFormatIsSpecifiedThenGraphicsAllocationShouldBeDumped) { + DebugManagerStateRestore dbgRestore; + DebugManager.flags.AUBDumpBufferFormat.set("TRE"); + + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); + mockAubCenter->aubManager = std::make_unique(); + + pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); + MockAubCsr aubCsr("", true, *pDevice->executionEnvironment); + MockOsContext osContext(0, 1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled, false); + aubCsr.setupContext(osContext); + + auto mockHardwareContext = static_cast(aubCsr.hardwareContextController->hardwareContexts[0].get()); + + auto memoryManager = pDevice->getMemoryManager(); + auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED}); + gfxAllocation->setMemObjectsAllocationWithWritableFlags(true); + EXPECT_TRUE(AubAllocDump::isWritableBuffer(*gfxAllocation)); + + aubCsr.dumpAllocation(*gfxAllocation); + + EXPECT_TRUE(mockHardwareContext->dumpBufferCalled); memoryManager->freeGraphicsMemory(gfxAllocation); } @@ -927,7 +953,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpA aubCsr.dumpAllocation(*gfxAllocation); - EXPECT_FALSE(mockHardwareContext->dumpBufferBINCalled); + EXPECT_FALSE(mockHardwareContext->dumpBufferCalled); memoryManager->freeGraphicsMemory(gfxAllocation); } @@ -954,7 +980,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationNonWritableWhenDu aubCsr.dumpAllocation(*gfxAllocation); - EXPECT_FALSE(mockHardwareContext->dumpBufferBINCalled); + EXPECT_FALSE(mockHardwareContext->dumpBufferCalled); memoryManager->freeGraphicsMemory(gfxAllocation); } @@ -983,7 +1009,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationNotDumpableWhenDu aubCsr.dumpAllocation(*gfxAllocation); EXPECT_FALSE(gfxAllocation->isAllocDumpable()); - EXPECT_FALSE(mockHardwareContext->dumpBufferBINCalled); + EXPECT_FALSE(mockHardwareContext->dumpBufferCalled); memoryManager->freeGraphicsMemory(gfxAllocation); } @@ -1012,7 +1038,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationDumpableWhenDumpA aubCsr.dumpAllocation(*gfxAllocation); EXPECT_FALSE(gfxAllocation->isAllocDumpable()); - EXPECT_TRUE(mockHardwareContext->dumpBufferBINCalled); + EXPECT_TRUE(mockHardwareContext->dumpBufferCalled); memoryManager->freeGraphicsMemory(gfxAllocation); } diff --git a/unit_tests/mocks/mock_aub_manager.h b/unit_tests/mocks/mock_aub_manager.h index abedf7ce6d..cc5a8733b2 100644 --- a/unit_tests/mocks/mock_aub_manager.h +++ b/unit_tests/mocks/mock_aub_manager.h @@ -20,6 +20,7 @@ struct MockHardwareContext : public aub_stream::HardwareContext { void expectMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t compareOperation) override { expectMemoryCalled = true; } void readMemory(uint64_t gfxAddress, void *memory, size_t size, uint32_t memoryBank, size_t pageSize) override { readMemoryCalled = true; } void dumpBufferBIN(uint64_t gfxAddress, size_t size) override { dumpBufferBINCalled = true; } + void dumpBuffer(uint64_t gfxAddress, size_t size, uint32_t format, bool compressed) override { dumpBufferCalled = true; } bool initializeCalled = false; bool pollForCompletionCalled = false; @@ -29,6 +30,7 @@ struct MockHardwareContext : public aub_stream::HardwareContext { bool expectMemoryCalled = false; bool readMemoryCalled = false; bool dumpBufferBINCalled = false; + bool dumpBufferCalled = false; const uint32_t deviceIndex; };