diff --git a/runtime/aub/aub_center.cpp b/runtime/aub/aub_center.cpp index 7830844acd..af04f3212b 100644 --- a/runtime/aub/aub_center.cpp +++ b/runtime/aub/aub_center.cpp @@ -18,11 +18,14 @@ namespace OCLRT { extern aub_stream::AubManager *createAubManager(uint32_t productFamily, uint32_t devicesCount, uint64_t memoryBankSize, bool localMemorySupported, const std::string &aubFileName, uint32_t streamMode); -AubCenter::AubCenter(const HardwareInfo *pHwInfo, bool localMemoryEnabled, const std::string &aubFileName) { +AubCenter::AubCenter(const HardwareInfo *pHwInfo, bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType) { if (DebugManager.flags.UseAubStream.get()) { auto devicesCount = AubHelper::getDevicesCount(pHwInfo); auto memoryBankSize = AubHelper::getMemBankSize(); - uint32_t mode = getAubStreamMode(aubFileName, DebugManager.flags.SetCommandStreamReceiver.get()); + CommandStreamReceiverType type = static_cast(DebugManager.flags.SetCommandStreamReceiver.get() != CommandStreamReceiverType::CSR_HW + ? DebugManager.flags.SetCommandStreamReceiver.get() + : csrType); + aubStreamMode = getAubStreamMode(aubFileName, type); if (DebugManager.flags.AubDumpAddMmioRegistersList.get() != "unk") { aub_stream::injectMMIOList = AubHelper::getAdditionalMmioList(); @@ -30,7 +33,7 @@ AubCenter::AubCenter(const HardwareInfo *pHwInfo, bool localMemoryEnabled, const aub_stream::tbxServerIp = DebugManager.flags.TbxServer.get(); aub_stream::tbxServerPort = DebugManager.flags.TbxPort.get(); - aubManager.reset(createAubManager(pHwInfo->pPlatform->eProductFamily, devicesCount, memoryBankSize, localMemoryEnabled, aubFileName, mode)); + aubManager.reset(createAubManager(pHwInfo->pPlatform->eProductFamily, devicesCount, memoryBankSize, localMemoryEnabled, aubFileName, aubStreamMode)); } addressMapper = std::make_unique(); streamProvider = std::make_unique(); @@ -44,25 +47,21 @@ AubCenter::AubCenter() { uint32_t AubCenter::getAubStreamMode(const std::string &aubFileName, uint32_t csrType) { uint32_t mode = aub_stream::mode::aubFile; - if (csrType != CommandStreamReceiverType::CSR_HW) { - switch (csrType) { - case CommandStreamReceiverType::CSR_AUB: - mode = aub_stream::mode::aubFile; - break; - case CommandStreamReceiverType::CSR_TBX: - mode = aub_stream::mode::tbx; - break; - case CommandStreamReceiverType::CSR_TBX_WITH_AUB: - mode = aub_stream::mode::aubFileAndTbx; - break; - default: - break; - } - } else { - if (aubFileName.size() == 0) { - mode = aub_stream::mode::tbx; - } + switch (csrType) { + case CommandStreamReceiverType::CSR_HW_WITH_AUB: + case CommandStreamReceiverType::CSR_AUB: + mode = aub_stream::mode::aubFile; + break; + case CommandStreamReceiverType::CSR_TBX: + mode = aub_stream::mode::tbx; + break; + case CommandStreamReceiverType::CSR_TBX_WITH_AUB: + mode = aub_stream::mode::aubFileAndTbx; + break; + default: + break; } + return mode; } } // namespace OCLRT diff --git a/runtime/aub/aub_center.h b/runtime/aub/aub_center.h index 63a0a36351..d65f336a03 100644 --- a/runtime/aub/aub_center.h +++ b/runtime/aub/aub_center.h @@ -7,6 +7,7 @@ #pragma once #include "runtime/command_stream/aub_stream_provider.h" +#include "runtime/helpers/options.h" #include "runtime/memory_manager/address_mapper.h" #include "runtime/memory_manager/physical_address_allocator.h" #include "third_party/aub_stream/headers/aub_manager.h" @@ -16,7 +17,7 @@ struct HardwareInfo; class AubCenter { public: - AubCenter(const HardwareInfo *pHwInfo, bool localMemoryEnabled, const std::string &aubFileName); + AubCenter(const HardwareInfo *pHwInfo, bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType); AubCenter(); virtual ~AubCenter() = default; @@ -49,5 +50,6 @@ class AubCenter { std::unique_ptr streamProvider; std::unique_ptr aubManager; + uint32_t aubStreamMode = 0; }; } // namespace OCLRT diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index 261d69107c..282c6ad76d 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -40,7 +40,7 @@ AUBCommandStreamReceiverHw::AUBCommandStreamReceiverHw(const Hardware subCaptureManager(std::make_unique(fileName)), standalone(standalone) { - executionEnvironment.initAubCenter(&this->peekHwInfo(), this->localMemoryEnabled, fileName); + executionEnvironment.initAubCenter(&this->peekHwInfo(), this->localMemoryEnabled, fileName, this->getType()); auto aubCenter = executionEnvironment.aubCenter.get(); UNRECOVERABLE_IF(nullptr == aubCenter); diff --git a/runtime/command_stream/tbx_command_stream_receiver_hw.inl b/runtime/command_stream/tbx_command_stream_receiver_hw.inl index 0fb0766abe..5e00e1c47f 100644 --- a/runtime/command_stream/tbx_command_stream_receiver_hw.inl +++ b/runtime/command_stream/tbx_command_stream_receiver_hw.inl @@ -32,7 +32,7 @@ TbxCommandStreamReceiverHw::TbxCommandStreamReceiverHw(const Hardware : BaseClass(hwInfoIn, executionEnvironment) { physicalAddressAllocator.reset(this->createPhysicalAddressAllocator(&hwInfoIn)); - executionEnvironment.initAubCenter(&this->peekHwInfo(), this->localMemoryEnabled, ""); + executionEnvironment.initAubCenter(&this->peekHwInfo(), this->localMemoryEnabled, "", this->getType()); auto aubCenter = executionEnvironment.aubCenter.get(); UNRECOVERABLE_IF(nullptr == aubCenter); @@ -172,7 +172,7 @@ CommandStreamReceiver *TbxCommandStreamReceiverHw::create(const Hardw if (withAubDump) { auto &hwHelper = HwHelper::get(hwInfoIn.pPlatform->eRenderCoreFamily); auto localMemoryEnabled = hwHelper.getEnableLocalMemory(hwInfoIn); - executionEnvironment.initAubCenter(&hwInfoIn, localMemoryEnabled, baseName); + executionEnvironment.initAubCenter(&hwInfoIn, localMemoryEnabled, baseName, CommandStreamReceiverType::CSR_TBX_WITH_AUB); csr = new CommandStreamReceiverWithAUBDump>(hwInfoIn, baseName, executionEnvironment); } else { diff --git a/runtime/execution_environment/execution_environment.cpp b/runtime/execution_environment/execution_environment.cpp index 28858910f3..48ac622bd1 100644 --- a/runtime/execution_environment/execution_environment.cpp +++ b/runtime/execution_environment/execution_environment.cpp @@ -23,9 +23,9 @@ ExecutionEnvironment::ExecutionEnvironment() = default; ExecutionEnvironment::~ExecutionEnvironment() = default; extern CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo, ExecutionEnvironment &executionEnvironment); -void ExecutionEnvironment::initAubCenter(const HardwareInfo *pHwInfo, bool localMemoryEnabled, const std::string &aubFileName) { +void ExecutionEnvironment::initAubCenter(const HardwareInfo *pHwInfo, bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType) { if (!aubCenter) { - aubCenter.reset(new AubCenter(pHwInfo, localMemoryEnabled, aubFileName)); + aubCenter.reset(new AubCenter(pHwInfo, localMemoryEnabled, aubFileName, csrType)); } } void ExecutionEnvironment::initGmm(const HardwareInfo *hwInfo) { diff --git a/runtime/execution_environment/execution_environment.h b/runtime/execution_environment/execution_environment.h index b3713314e5..604f79991c 100644 --- a/runtime/execution_environment/execution_environment.h +++ b/runtime/execution_environment/execution_environment.h @@ -7,6 +7,8 @@ #pragma once #include "engine_node.h" + +#include "runtime/helpers/options.h" #include "runtime/os_interface/device_factory.h" #include "runtime/utilities/reference_tracked_object.h" @@ -38,7 +40,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject ExecutionEnvironment(); ~ExecutionEnvironment() override; - MOCKABLE_VIRTUAL void initAubCenter(const HardwareInfo *hwInfo, bool localMemoryEnabled, const std::string &aubFileName); + MOCKABLE_VIRTUAL void initAubCenter(const HardwareInfo *hwInfo, bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType); void initGmm(const HardwareInfo *hwInfo); bool initializeCommandStreamReceiver(const HardwareInfo *pHwInfo, uint32_t deviceIndex, uint32_t deviceCsrIndex); void initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory, uint32_t deviceIndex, uint32_t deviceCsrIndex); diff --git a/runtime/platform/platform.cpp b/runtime/platform/platform.cpp index 96f7dff33e..92b39f5f31 100644 --- a/runtime/platform/platform.cpp +++ b/runtime/platform/platform.cpp @@ -178,7 +178,7 @@ bool Platform::initialize() { CommandStreamReceiverType csrType = this->devices[0]->getDefaultEngine().commandStreamReceiver->getType(); if (csrType != CommandStreamReceiverType::CSR_HW) { auto enableLocalMemory = HwHelper::get(hwInfo->pPlatform->eRenderCoreFamily).getEnableLocalMemory(*hwInfo); - executionEnvironment->initAubCenter(&hwInfo[0], enableLocalMemory, "aubfile"); + executionEnvironment->initAubCenter(&hwInfo[0], enableLocalMemory, "aubfile", csrType); } this->fillGlobalDispatchTable(); diff --git a/unit_tests/aub/aub_center_tests.cpp b/unit_tests/aub/aub_center_tests.cpp index aa45582257..bb1c17f51d 100644 --- a/unit_tests/aub/aub_center_tests.cpp +++ b/unit_tests/aub/aub_center_tests.cpp @@ -22,7 +22,7 @@ TEST(AubCenter, GivenUseAubStreamDebugVariableNotSetWhenAubCenterIsCreatedThenAu DebugManagerStateRestore restorer; DebugManager.flags.UseAubStream.set(false); - MockAubCenter aubCenter(platformDevices[0], false, ""); + MockAubCenter aubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB); EXPECT_EQ(nullptr, aubCenter.aubManager.get()); } @@ -31,7 +31,7 @@ TEST(AubCenter, GivenUseAubStreamDebugVariableSetWhenAubCenterIsCreatedThenCreat DebugManager.flags.UseAubStream.set(false); MockAubManager *mockAubManager = new MockAubManager(platformDevices[0]->pPlatform->eProductFamily, 4, 8 * MB, true, "aub_file.aub", aub_stream::mode::aubFile); - MockAubCenter mockAubCenter(platformDevices[0], false, ""); + MockAubCenter mockAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB); mockAubCenter.aubManager = std::unique_ptr(mockAubManager); EXPECT_EQ(platformDevices[0]->pPlatform->eProductFamily, mockAubManager->mockAubManagerParams.productFamily); @@ -52,14 +52,14 @@ TEST(AubCenter, GivenDefaultSetCommandStreamReceiverFlagAndAubFileNameWhenGettin EXPECT_EQ(aub_stream::mode::aubFile, mode); } -TEST(AubCenter, GivenCsrHwAndEmptyAubFileNameWhenGettingAubStreamModeThenModeTbxIsReturned) { +TEST(AubCenter, GivenCsrHwAndEmptyAubFileNameWhenGettingAubStreamModeThenModeAubFileIsReturned) { DebugManagerStateRestore restorer; DebugManager.flags.UseAubStream.set(true); std::string aubFile(""); auto mode = AubCenter::getAubStreamMode(aubFile, CommandStreamReceiverType::CSR_HW); - EXPECT_EQ(aub_stream::mode::tbx, mode); + EXPECT_EQ(aub_stream::mode::aubFile, mode); } TEST(AubCenter, GivenCsrHwAndNotEmptyAubFileNameWhenGettingAubStreamModeThenModeAubFileIsReturned) { @@ -87,3 +87,38 @@ TEST(AubCenter, GivenCsrTypeWhenGettingAubStreamModeThenCorrectModeIsReturned) { mode = AubCenter::getAubStreamMode(aubFile, CommandStreamReceiverType::CSR_TBX_WITH_AUB); EXPECT_EQ(aub_stream::mode::aubFileAndTbx, mode); } + +TEST(AubCenter, GivenSetCommandStreamReceiverFlagEqualDefaultHwWhenAubManagerIsCreatedThenCsrTypeDefinesAubStreamMode) { + DebugManagerStateRestore restorer; + DebugManager.flags.UseAubStream.set(true); + + std::vector aubTypes = {CommandStreamReceiverType::CSR_HW, + CommandStreamReceiverType::CSR_HW_WITH_AUB, + CommandStreamReceiverType::CSR_AUB}; + + for (auto type : aubTypes) { + MockAubCenter aubCenter(platformDevices[0], true, "test", type); + EXPECT_EQ(aub_stream::mode::aubFile, aubCenter.aubStreamMode); + } + + MockAubCenter aubCenter2(platformDevices[0], true, "", CommandStreamReceiverType::CSR_TBX); + EXPECT_EQ(aub_stream::mode::tbx, aubCenter2.aubStreamMode); + + MockAubCenter aubCenter3(platformDevices[0], true, "", CommandStreamReceiverType::CSR_TBX_WITH_AUB); + EXPECT_EQ(aub_stream::mode::aubFileAndTbx, aubCenter3.aubStreamMode); +} + +TEST(AubCenter, GivenSetCommandStreamReceiverFlagSetWhenAubManagerIsCreatedThenDebugFlagDefinesAubStreamMode) { + DebugManagerStateRestore restorer; + DebugManager.flags.UseAubStream.set(true); + + DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX); + + MockAubCenter aubCenter(platformDevices[0], true, "", CommandStreamReceiverType::CSR_AUB); + EXPECT_EQ(aub_stream::mode::tbx, aubCenter.aubStreamMode); + + DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX_WITH_AUB); + + MockAubCenter aubCenter2(platformDevices[0], true, "", CommandStreamReceiverType::CSR_AUB); + EXPECT_EQ(aub_stream::mode::aubFileAndTbx, aubCenter2.aubStreamMode); +} 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 7367c7947a..157334393b 100644 --- a/unit_tests/aub/aub_center_using_aubstream_stubs_tests.cpp +++ b/unit_tests/aub/aub_center_using_aubstream_stubs_tests.cpp @@ -21,7 +21,7 @@ TEST(AubCenter, GivenUseAubStreamDebugVariableSetWhenAubCenterIsCreatedThenAubMa DebugManagerStateRestore restorer; DebugManager.flags.UseAubStream.set(true); - MockAubCenter aubCenter(platformDevices[0], false, ""); + MockAubCenter aubCenter(platformDevices[0], false, "test", CommandStreamReceiverType::CSR_AUB); EXPECT_EQ(nullptr, aubCenter.aubManager.get()); } @@ -32,7 +32,7 @@ TEST(AubCenter, GivenUseAubStreamAndTbxServerIpDebugVariableSetWhenAubCenterIsCr DebugManager.flags.TbxServer.set("10.10.10.10"); VariableBackup backup(&aub_stream::tbxServerIp); - MockAubCenter aubCenter(platformDevices[0], false, ""); + MockAubCenter aubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_TBX); EXPECT_STREQ("10.10.10.10", aub_stream::tbxServerIp.c_str()); } @@ -47,6 +47,6 @@ TEST(AubCenter, GivenUseAubStreamAndTbxServerPortDebugVariableSetWhenAubCenterIs uint16_t port = 1234u; EXPECT_NE(port, aub_stream::tbxServerPort); - MockAubCenter aubCenter(platformDevices[0], false, ""); + MockAubCenter aubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_TBX); EXPECT_EQ(port, aub_stream::tbxServerPort); } 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 d4eda54486..3e2f302344 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 @@ -175,7 +175,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWithAubMana HardwareInfo hwInfo = *platformDevices[0]; std::string fileName = "file_name.aub"; MockAubManager *mockManager = new MockAubManager(); - MockAubCenter *mockAubCenter = new MockAubCenter(&hwInfo, false, fileName); + MockAubCenter *mockAubCenter = new MockAubCenter(&hwInfo, false, fileName, CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::unique_ptr(mockManager); ExecutionEnvironment executionEnvironment; executionEnvironment.aubCenter = std::unique_ptr(mockAubCenter); @@ -193,7 +193,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenOsContextIsSetThenCreateH OsContext osContext(nullptr, 0, allEngineInstances[engineIndex], PreemptionMode::Disabled); std::string fileName = "file_name.aub"; MockAubManager *mockManager = new MockAubManager(); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName, CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::unique_ptr(mockManager); ExecutionEnvironment executionEnvironment; executionEnvironment.aubCenter = std::unique_ptr(mockAubCenter); @@ -213,7 +213,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenLowPriorityOsContextIsSet OsContext osContext(nullptr, 0, lowPriorityGpgpuEngine, PreemptionMode::Disabled); std::string fileName = "file_name.aub"; MockAubManager *mockManager = new MockAubManager(); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName, CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::unique_ptr(mockManager); ExecutionEnvironment executionEnvironment; executionEnvironment.aubCenter = std::unique_ptr(mockAubCenter); 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 b284be8e2e..d85f42095e 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 @@ -890,7 +890,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpA DebugManagerStateRestore dbgRestore; DebugManager.flags.AUBDumpBufferFormat.set("BIN"); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -917,7 +917,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpA HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpAllocationIsCalledButDumpFormatIsNotSpecifiedThenGraphicsAllocationShouldNotBeDumped) { DebugManagerStateRestore dbgRestore; - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -945,7 +945,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationNonWritableWhenDu DebugManagerStateRestore dbgRestore; DebugManager.flags.AUBDumpBufferFormat.set("BIN"); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -974,7 +974,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationNotDumpableWhenDu DebugManager.flags.AUBDumpAllocsOnEnqueueReadOnly.set(true); DebugManager.flags.AUBDumpBufferFormat.set("BIN"); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -1004,7 +1004,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationDumpableWhenDumpA DebugManager.flags.AUBDumpAllocsOnEnqueueReadOnly.set(true); DebugManager.flags.AUBDumpBufferFormat.set("BIN"); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); diff --git a/unit_tests/command_stream/aub_file_stream_tests.cpp b/unit_tests/command_stream/aub_file_stream_tests.cpp index c730a3c698..62072f953a 100644 --- a/unit_tests/command_stream/aub_file_stream_tests.cpp +++ b/unit_tests/command_stream/aub_file_stream_tests.cpp @@ -199,7 +199,7 @@ HWTEST_F(AubFileStreamTests, givenNoNewTaskSinceLastPollWhenDeletingAubCsrThenDo HWTEST_F(AubFileStreamTests, givenNewTasksAndHardwareContextPresentWhenCallingPollForCompletionThenCallPollForCompletion) { auto aubStream = std::make_unique(); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -219,7 +219,7 @@ HWTEST_F(AubFileStreamTests, givenNewTasksAndHardwareContextPresentWhenCallingPo HWTEST_F(AubFileStreamTests, givenNoNewTasksAndHardwareContextPresentWhenCallingPollForCompletionThenDontCallPollForCompletion) { auto aubStream = std::make_unique(); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -302,7 +302,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryNotEqu HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldCallTheExpectedHwContextFunctions) { auto aubStream = std::make_unique(); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -331,7 +331,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenI HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledWithZeroSizedBufferThenSubmitIsNotCalledOnHwContext) { auto aubStream = std::make_unique(); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -355,7 +355,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledWithZ } HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenMakeResidentIsCalledThenItShouldCallTheExpectedHwContextFunctions) { - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -371,7 +371,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenMakeResidentIsCall } HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryEqualIsCalledThenItShouldCallTheExpectedHwContextFunctions) { - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -387,7 +387,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryEqualI } HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryNotEqualIsCalledThenItShouldCallTheExpectedHwContextFunctions) { - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); diff --git a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index b5b185135d..13608e0b41 100644 --- a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp @@ -142,7 +142,7 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenAubManagerAvailaleWhen HardwareInfo hwInfo = *platformDevices[0]; std::string fileName = "file_name.aub"; MockAubManager *mockManager = new MockAubManager(); - MockAubCenter *mockAubCenter = new MockAubCenter(&hwInfo, false, fileName); + MockAubCenter *mockAubCenter = new MockAubCenter(&hwInfo, false, fileName, CommandStreamReceiverType::CSR_TBX_WITH_AUB); mockAubCenter->aubManager = std::unique_ptr(mockManager); ExecutionEnvironment executionEnvironment; executionEnvironment.aubCenter = std::unique_ptr(mockAubCenter); diff --git a/unit_tests/command_stream/tbx_command_stream_tests.cpp b/unit_tests/command_stream/tbx_command_stream_tests.cpp index 34f52692a1..bb432e0163 100644 --- a/unit_tests/command_stream/tbx_command_stream_tests.cpp +++ b/unit_tests/command_stream/tbx_command_stream_tests.cpp @@ -341,7 +341,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenItIsCreatedWith } HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledThenItShouldCallTheExpectedHwContextFunctions) { - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_TBX); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -371,7 +371,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverInBatchedModeWhenFl DebugManagerStateRestore dbgRestore; DebugManager.flags.CsrDispatchMode.set(static_cast(DispatchMode::BatchedDispatch)); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_TBX); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -393,7 +393,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverInBatchedModeWhenFl } HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledWithZeroSizedBufferThenSubmitIsNotCalledOnHwContext) { - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_TBX); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -415,7 +415,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledWi } HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsCalledThenItShouldCallTheExpectedHwContextFunctions) { - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_TBX); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -431,7 +431,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsC } HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeCoherentIsCalledThenItShouldCallTheExpectedHwContextFunctions) { - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_TBX); mockAubCenter->aubManager = std::make_unique(); pDevice->executionEnvironment->aubCenter.reset(mockAubCenter); @@ -449,7 +449,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeCoherentIsC HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenHardwareContextIsCreatedThenTbxStreamInCsrIsNotInitialized) { const HardwareInfo &hwInfo = *platformDevices[0]; MockAubManager *mockManager = new MockAubManager(); - MockAubCenter *mockAubCenter = new MockAubCenter(&hwInfo, false, ""); + MockAubCenter *mockAubCenter = new MockAubCenter(&hwInfo, false, "", CommandStreamReceiverType::CSR_TBX); mockAubCenter->aubManager = std::unique_ptr(mockManager); ExecutionEnvironment executionEnvironment; executionEnvironment.aubCenter = std::unique_ptr(mockAubCenter); @@ -461,14 +461,14 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenHardwareContextIsCreatedThenTbxSt HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenOsContextIsSetThenCreateHardwareContext) { OsContext osContext(nullptr, 0, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionMode::Disabled); - std::string fileName = "file_name.aub"; + std::string fileName = ""; MockAubManager *mockManager = new MockAubManager(); - MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName); + MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName, CommandStreamReceiverType::CSR_TBX); mockAubCenter->aubManager = std::unique_ptr(mockManager); ExecutionEnvironment executionEnvironment; executionEnvironment.aubCenter = std::unique_ptr(mockAubCenter); - std::unique_ptr> tbxCsr(reinterpret_cast *>(TbxCommandStreamReceiver::create(*platformDevices[0], fileName, true, executionEnvironment))); + std::unique_ptr> tbxCsr(reinterpret_cast *>(TbxCommandStreamReceiver::create(*platformDevices[0], fileName, false, executionEnvironment))); EXPECT_EQ(nullptr, tbxCsr->hardwareContextController.get()); tbxCsr->setupContext(osContext); diff --git a/unit_tests/execution_environment/execution_environment_tests.cpp b/unit_tests/execution_environment/execution_environment_tests.cpp index 53477294e3..a8d3ae938d 100644 --- a/unit_tests/execution_environment/execution_environment_tests.cpp +++ b/unit_tests/execution_environment/execution_environment_tests.cpp @@ -128,7 +128,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeIsCalledMultip TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsReceivesCorrectInputParams) { MockExecutionEnvironment executionEnvironment; - executionEnvironment.initAubCenter(platformDevices[0], true, "test.aub"); + executionEnvironment.initAubCenter(platformDevices[0], true, "test.aub", CommandStreamReceiverType::CSR_AUB); EXPECT_TRUE(executionEnvironment.initAubCenterCalled); EXPECT_TRUE(executionEnvironment.localMemoryEnabledReceived); EXPECT_STREQ(executionEnvironment.aubFileNameReceived.c_str(), "test.aub"); @@ -139,21 +139,21 @@ TEST(ExecutionEnvironment, givenUseAubStreamFalseWhenGetAubManagerIsCalledThenRe DebugManager.flags.UseAubStream.set(false); ExecutionEnvironment executionEnvironment; - executionEnvironment.initAubCenter(platformDevices[0], false, ""); + executionEnvironment.initAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB); auto aubManager = executionEnvironment.aubCenter->getAubManager(); EXPECT_EQ(nullptr, aubManager); } TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsInitalizedOnce) { ExecutionEnvironment executionEnvironment; - executionEnvironment.initAubCenter(platformDevices[0], false, ""); + executionEnvironment.initAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB); auto currentAubCenter = executionEnvironment.aubCenter.get(); EXPECT_NE(nullptr, currentAubCenter); auto currentAubStreamProvider = currentAubCenter->getStreamProvider(); EXPECT_NE(nullptr, currentAubStreamProvider); auto currentAubFileStream = currentAubStreamProvider->getStream(); EXPECT_NE(nullptr, currentAubFileStream); - executionEnvironment.initAubCenter(platformDevices[0], false, ""); + executionEnvironment.initAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB); EXPECT_EQ(currentAubCenter, executionEnvironment.aubCenter.get()); EXPECT_EQ(currentAubStreamProvider, executionEnvironment.aubCenter->getStreamProvider()); EXPECT_EQ(currentAubFileStream, executionEnvironment.aubCenter->getStreamProvider()->getStream()); @@ -193,7 +193,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe MemoryMangerMock(uint32_t &destructorId) : DestructorCounted(destructorId) {} }; struct AubCenterMock : public DestructorCounted { - AubCenterMock(uint32_t &destructorId) : DestructorCounted(destructorId, platformDevices[0], false, "") {} + AubCenterMock(uint32_t &destructorId) : DestructorCounted(destructorId, platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB) {} }; struct CommandStreamReceiverMock : public DestructorCounted { CommandStreamReceiverMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {} diff --git a/unit_tests/mocks/mock_aub_center.h b/unit_tests/mocks/mock_aub_center.h index 9c84f1e54c..59c7807303 100644 --- a/unit_tests/mocks/mock_aub_center.h +++ b/unit_tests/mocks/mock_aub_center.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -11,5 +11,7 @@ class MockAubCenter : public OCLRT::AubCenter { public: using AubCenter::AubCenter; using AubCenter::aubManager; + using AubCenter::aubStreamMode; + ~MockAubCenter() override = default; }; diff --git a/unit_tests/mocks/mock_execution_environment.h b/unit_tests/mocks/mock_execution_environment.h index 36cb0fb69c..75249af9e8 100644 --- a/unit_tests/mocks/mock_execution_environment.h +++ b/unit_tests/mocks/mock_execution_environment.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -8,14 +8,16 @@ #pragma once #include "runtime/execution_environment/execution_environment.h" +#include "runtime/helpers/options.h" + namespace OCLRT { struct MockExecutionEnvironment : ExecutionEnvironment { MockExecutionEnvironment() = default; - void initAubCenter(const HardwareInfo *hwInfo, bool localMemoryEnabled, const std::string &aubFileName) override { + void initAubCenter(const HardwareInfo *hwInfo, bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType) override { initAubCenterCalled = true; localMemoryEnabledReceived = localMemoryEnabled; aubFileNameReceived = aubFileName; - ExecutionEnvironment::initAubCenter(hwInfo, localMemoryEnabled, aubFileName); + ExecutionEnvironment::initAubCenter(hwInfo, localMemoryEnabled, aubFileName, csrType); } bool initAubCenterCalled = false; bool localMemoryEnabledReceived = false;