diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.h b/runtime/command_stream/aub_command_stream_receiver_hw.h index 3b3c1356d1..7ed0265091 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.h +++ b/runtime/command_stream/aub_command_stream_receiver_hw.h @@ -93,5 +93,9 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw { uint32_t getGUCWorkQueueItemHeader(EngineType engineType); uint64_t getPPGTTAdditionalBits(GraphicsAllocation *gfxAllocation); void getGTTData(void *memory, AubGTTData &data); + + CommandStreamReceiverType getType() override { + return CommandStreamReceiverType::CSR_AUB; + } }; } // namespace OCLRT diff --git a/runtime/command_stream/command_stream_receiver.h b/runtime/command_stream/command_stream_receiver.h index 0fd2a4218a..3619943457 100644 --- a/runtime/command_stream/command_stream_receiver.h +++ b/runtime/command_stream/command_stream_receiver.h @@ -27,6 +27,7 @@ #include "runtime/helpers/completion_stamp.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/address_patch.h" +#include "runtime/helpers/options.h" #include "runtime/indirect_heap/indirect_heap.h" #include "runtime/helpers/flat_batch_buffer_helper.h" #include "runtime/command_stream/csr_definitions.h" @@ -133,6 +134,8 @@ class CommandStreamReceiver { void allocateHeapMemory(IndirectHeap::Type heapType, size_t minRequiredSize, IndirectHeap *&indirectHeap); void releaseIndirectHeap(IndirectHeap::Type heapType); + virtual enum CommandStreamReceiverType getType() = 0; + protected: void setDisableL3Cache(bool val) { disableL3Cache = val; diff --git a/runtime/command_stream/command_stream_receiver_hw.h b/runtime/command_stream/command_stream_receiver_hw.h index 4a090555e3..21745f82a1 100644 --- a/runtime/command_stream/command_stream_receiver_hw.h +++ b/runtime/command_stream/command_stream_receiver_hw.h @@ -81,6 +81,10 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { void resetKmdNotifyHelper(KmdNotifyHelper *newHelper); + CommandStreamReceiverType getType() override { + return CommandStreamReceiverType::CSR_HW; + } + protected: void programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags); void programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config); diff --git a/runtime/command_stream/tbx_command_stream_receiver_hw.h b/runtime/command_stream/tbx_command_stream_receiver_hw.h index a2b7c3fadd..f39882954a 100644 --- a/runtime/command_stream/tbx_command_stream_receiver_hw.h +++ b/runtime/command_stream/tbx_command_stream_receiver_hw.h @@ -93,5 +93,9 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverHw { PDPE ggtt; // remap CPU VA -> GGTT VA AddressMapper gttRemap; + + CommandStreamReceiverType getType() override { + return CommandStreamReceiverType::CSR_TBX; + } }; } // namespace OCLRT diff --git a/runtime/device/device.cpp b/runtime/device/device.cpp index a3c65320aa..6acc77cfcd 100644 --- a/runtime/device/device.cpp +++ b/runtime/device/device.cpp @@ -273,7 +273,11 @@ unique_ptr_if_unused Device::release() { } bool Device::isSimulation() { - return hwInfo.capabilityTable.isSimulation(hwInfo.pPlatform->usDeviceID); + bool simulation = hwInfo.capabilityTable.isSimulation(hwInfo.pPlatform->usDeviceID); + if (commandStreamReceiver->getType() != CommandStreamReceiverType::CSR_HW) { + simulation = true; + } + return simulation; } double Device::getPlatformHostTimerResolution() const { diff --git a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp index 5622423fef..807ad3768f 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp @@ -31,6 +31,8 @@ #include "unit_tests/mocks/mock_gmm.h" #include "unit_tests/mocks/mock_csr.h" +#include + using namespace OCLRT; using ::testing::Invoke; @@ -94,6 +96,13 @@ TEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCreat const_cast(hwInfo.pPlatform)->eRenderCoreFamily = family; } +TEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenTypeIsCheckedThenAubCsrIsReturned) { + HardwareInfo hwInfo = *platformDevices[0]; + std::unique_ptr aubCsr(AUBCommandStreamReceiver::create(hwInfo, "", true)); + EXPECT_NE(nullptr, aubCsr); + EXPECT_EQ(CommandStreamReceiverType::CSR_AUB, aubCsr->getType()); +} + HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenItIsCreatedWithDefaultSettingsThenItHasBatchedDispatchModeEnabled) { DebugManager.flags.CsrDispatchMode.set(0); std::unique_ptr> aubCsr(new MockAubCsr(*platformDevices[0], true)); diff --git a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp index 74100560ed..9c3efa95b7 100644 --- a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp @@ -54,6 +54,8 @@ #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/command_queue/gpgpu_walker.h" +#include + using namespace OCLRT; HWCMDTEST_F(IGFX_GEN8_CORE, UltCommandStreamReceiverTest, givenPreambleSentAndThreadArbitrationPolicyNotChangedWhenEstimatingPreambleCmdSizeThenReturnItsValue) { @@ -142,3 +144,12 @@ HWTEST_F(CommandStreamReceiverFlushTests, shouldAlignToCacheLineSize) { EXPECT_EQ(0u, commandStream.getUsed() % MemoryConstants::cacheLineSize); } + +typedef Test CommandStreamReceiverHwTest; + +HWTEST_F(CommandStreamReceiverHwTest, givenCsrHwWhenTypeIsCheckedThenCsrHwIsReturned) { + HardwareInfo hwInfo = *platformDevices[0]; + auto csr = std::unique_ptr(CommandStreamReceiverHw::create(hwInfo)); + + EXPECT_EQ(CommandStreamReceiverType::CSR_HW, csr->getType()); +} diff --git a/unit_tests/command_stream/tbx_command_stream_tests.cpp b/unit_tests/command_stream/tbx_command_stream_tests.cpp index a242a57447..09c3a81273 100644 --- a/unit_tests/command_stream/tbx_command_stream_tests.cpp +++ b/unit_tests/command_stream/tbx_command_stream_tests.cpp @@ -155,6 +155,13 @@ TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenItIsCreatedW const_cast(hwInfo.pPlatform)->eRenderCoreFamily = family; } +TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenTypeIsCheckedThenTbxCsrIsReturned) { + HardwareInfo hwInfo = *platformDevices[0]; + std::unique_ptr csr(TbxCommandStreamReceiver::create(hwInfo, false)); + EXPECT_NE(nullptr, csr); + EXPECT_EQ(CommandStreamReceiverType::CSR_TBX, csr->getType()); +} + HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsCalledForGraphicsAllocationThenItShouldPushAllocationForResidencyToMemoryManager) { TbxCommandStreamReceiverHw *tbxCsr = (TbxCommandStreamReceiverHw *)pCommandStreamReceiver; TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager(); diff --git a/unit_tests/device/device_tests.cpp b/unit_tests/device/device_tests.cpp index 11ebe077e5..76324d8906 100644 --- a/unit_tests/device/device_tests.cpp +++ b/unit_tests/device/device_tests.cpp @@ -150,3 +150,46 @@ TEST(DeviceCleanup, givenDeviceWhenItIsDestroyedThenFlushBatchedSubmissionsIsCal EXPECT_EQ(1, flushedBatchedSubmissionsCalledCount); } + +TEST(DeviceCreation, givenSelectedAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimulationReturnsTrue) { + DebugManagerStateRestore dbgRestorer; + DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB); + + overrideCommandStreamReceiverCreation = true; + auto mockDevice = std::unique_ptr(Device::create(nullptr)); + EXPECT_TRUE(mockDevice->isSimulation()); +} + +TEST(DeviceCreation, givenSelectedTbxCsrInDebugVarsWhenDeviceIsCreatedThenIsSimulationReturnsTrue) { + DebugManagerStateRestore dbgRestorer; + DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX); + + overrideCommandStreamReceiverCreation = true; + auto device = std::unique_ptr(Device::create(nullptr)); + EXPECT_TRUE(device->isSimulation()); +} + +TEST(DeviceCreation, givenSelectedTbxWithAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimulationReturnsTrue) { + DebugManagerStateRestore dbgRestorer; + DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX_WITH_AUB); + + overrideCommandStreamReceiverCreation = true; + auto device = std::unique_ptr(Device::create(nullptr)); + EXPECT_TRUE(device->isSimulation()); +} + +TEST(DeviceCreation, givenHwWithAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimulationReturnsFalse) { + DebugManagerStateRestore dbgRestorer; + DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_HW_WITH_AUB); + + auto device = std::unique_ptr(Device::create(nullptr)); + EXPECT_FALSE(device->isSimulation()); +} + +TEST(DeviceCreation, givenDefaultHwCsrInDebugVarsWhenDeviceIsCreatedThenIsSimulationReturnsFalse) { + int32_t defaultHwCsr = CommandStreamReceiverType::CSR_HW; + EXPECT_EQ(defaultHwCsr, DebugManager.flags.SetCommandStreamReceiver.get()); + + auto device = std::unique_ptr(Device::create(nullptr)); + EXPECT_FALSE(device->isSimulation()); +} diff --git a/unit_tests/kernel/kernel_tests.cpp b/unit_tests/kernel/kernel_tests.cpp index 040eb49d66..794b5780e1 100644 --- a/unit_tests/kernel/kernel_tests.cpp +++ b/unit_tests/kernel/kernel_tests.cpp @@ -459,6 +459,10 @@ class CommandStreamReceiverMock : public CommandStreamReceiver { void flushBatchedSubmissions() override {} + CommandStreamReceiverType getType() override { + return CommandStreamReceiverType::CSR_HW; + } + std::map residency; }; diff --git a/unit_tests/mocks/mock_csr.h b/unit_tests/mocks/mock_csr.h index 68e8eeb292..58e0632be7 100644 --- a/unit_tests/mocks/mock_csr.h +++ b/unit_tests/mocks/mock_csr.h @@ -249,6 +249,10 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { } void setOSInterface(OSInterface *osInterface); + + CommandStreamReceiverType getType() override { + return CommandStreamReceiverType::CSR_HW; + } }; #if defined(__clang__)