From c8b55e38a0dfc1428162c5c845f84c45c93eaf20 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Tue, 20 Dec 2022 11:23:46 +0000 Subject: [PATCH] Refactor: dont use global getters for Product/GfxCore helper in engine helpers Related-To: NEO-6853 Signed-off-by: Mateusz Jablonski --- .../sources/debugger/test_l0_debugger_2.cpp | 3 +- .../unit_tests/sources/device/test_device.cpp | 4 +- ...st_metric_ip_sampling_linux_pvc_prelim.cpp | 4 +- .../linux/mock_sysfs_scheduler_prelim.h | 3 +- opencl/source/command_queue/command_queue.cpp | 5 +- opencl/source/program/printf_handler.cpp | 2 +- .../command_queue/command_queue_tests.cpp | 16 ++--- .../test/unit_test/context/context_tests.cpp | 6 +- .../program/printf_handler_tests.cpp | 6 +- .../source/helpers/blit_commands_helper.cpp | 2 +- shared/source/helpers/engine_node_helper.cpp | 25 +++++--- shared/source/helpers/engine_node_helper.h | 9 +-- shared/source/os_interface/linux/drm_neo.cpp | 8 +-- .../source/os_interface/linux/engine_info.cpp | 21 ++++--- .../source/os_interface/linux/engine_info.h | 7 ++- .../helpers/engine_node_helper_tests.cpp | 63 +++++++++++-------- ...ngine_node_helper_tests_xehp_and_later.cpp | 39 ++++++------ .../helpers/hw_helper_tests_pvc_and_later.cpp | 9 +-- .../linux/drm_engine_info_prelim_tests.cpp | 14 ++--- .../linux/drm_engine_info_tests.cpp | 19 +++--- .../pvc/engine_node_helper_tests_pvc.cpp | 57 +++++++++-------- 21 files changed, 172 insertions(+), 150 deletions(-) diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_2.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_2.cpp index 42f830afbd..1b9ba79ae0 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_2.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_2.cpp @@ -477,7 +477,8 @@ HWTEST_P(L0DebuggerWithBlitterTest, givenDebuggingEnabledWhenCommandListIsExecut auto &selectorCopyEngine = neoDevice->getSelectorCopyEngine(); auto deviceBitfield = neoDevice->getDeviceBitfield(); - auto bcsEngine = neoDevice->tryGetEngine(EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false), EngineUsage::Regular); + auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironment(); + auto bcsEngine = neoDevice->tryGetEngine(EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false), EngineUsage::Regular); if (!bcsEngine) { GTEST_SKIP(); diff --git a/level_zero/core/test/unit_tests/sources/device/test_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_device.cpp index 2f6421d670..b3f151ef0f 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_device.cpp @@ -1243,7 +1243,7 @@ TEST_F(DeviceTest, whenCheckingIfStatelessCompressionIsSupportedThenReturnFalse) TEST_F(DeviceTest, givenNodeOrdinalFlagWhenCallAdjustCommandQueueDescThenDescOrdinalProperlySet) { DebugManagerStateRestore restore; - auto nodeOrdinal = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *defaultHwInfo); + auto nodeOrdinal = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, neoDevice->getRootDeviceEnvironment()); DebugManager.flags.NodeOrdinal.set(nodeOrdinal); auto deviceImp = static_cast *>(device); @@ -1286,7 +1286,7 @@ HWTEST_F(DeviceTest, givenNodeOrdinalFlagWhenCallAdjustCommandQueueDescThenDescO gfxCoreHelperFactoryBackup = &gfxCoreHelper; hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 2; - auto nodeOrdinal = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_CCS2, hwInfo); + auto nodeOrdinal = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_CCS2, neoDevice->getRootDeviceEnvironment()); DebugManager.flags.NodeOrdinal.set(nodeOrdinal); auto deviceImp = static_cast *>(device); diff --git a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_prelim.cpp b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_prelim.cpp index b5bab33312..6a33a90d51 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_prelim.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux_pvc_prelim.cpp @@ -78,7 +78,7 @@ class DrmPrelimMock : public DrmMock { queryItems[i].length = sizeof(drm_i915_query_engine_info); } - engineInfo = std::make_unique(this, customHwInfo.get(), 4, distances, queryItems, engines); + engineInfo = std::make_unique(this, 4, distances, queryItems, engines); return true; } @@ -97,7 +97,7 @@ class DrmPrelimMock : public DrmMock { queryItems[i].length = sizeof(drm_i915_query_engine_info); } - engineInfo = std::make_unique(this, customHwInfo.get(), 1, distances, queryItems, engines); + engineInfo = std::make_unique(this, 1, distances, queryItems, engines); return true; } diff --git a/level_zero/tools/test/unit_tests/sources/sysman/scheduler/linux/mock_sysfs_scheduler_prelim.h b/level_zero/tools/test/unit_tests/sources/sysman/scheduler/linux/mock_sysfs_scheduler_prelim.h index 6a3d92a906..0ec28183c6 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/scheduler/linux/mock_sysfs_scheduler_prelim.h +++ b/level_zero/tools/test/unit_tests/sources/sysman/scheduler/linux/mock_sysfs_scheduler_prelim.h @@ -153,8 +153,7 @@ struct MockSchedulerNeoDrm : public SchedulerNeoDrm { i915QueryEngineInfo[33].engine.engineClass = engineClassCompute; i915QueryEngineInfo[33].engine.engineInstance = 7; - NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); - this->engineInfo.reset(new EngineInfo(this, &hwInfo, tileCount, distanceInfos, queryItems, i915QueryEngineInfo)); + this->engineInfo.reset(new EngineInfo(this, tileCount, distanceInfos, queryItems, i915QueryEngineInfo)); return true; } diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index 77a19733c3..1a54b48df7 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -269,7 +269,7 @@ CommandStreamReceiver &CommandQueue::selectCsrForBuiltinOperation(const CsrSelec } if (preferredBCSType) { - preferredBcsEngineType = EngineHelpers::getBcsEngineType(device->getHardwareInfo(), device->getDeviceBitfield(), + preferredBcsEngineType = EngineHelpers::getBcsEngineType(device->getRootDeviceEnvironment(), device->getDeviceBitfield(), device->getSelectorCopyEngine(), false); } break; @@ -304,11 +304,10 @@ CommandStreamReceiver &CommandQueue::selectCsrForBuiltinOperation(const CsrSelec void CommandQueue::constructBcsEngine(bool internalUsage) { if (bcsAllowed && !bcsInitialized) { - auto &hwInfo = device->getHardwareInfo(); auto &gfxCoreHelper = device->getGfxCoreHelper(); auto &neoDevice = device->getNearestGenericSubDevice(0)->getDevice(); auto &selectorCopyEngine = neoDevice.getSelectorCopyEngine(); - auto bcsEngineType = EngineHelpers::getBcsEngineType(hwInfo, device->getDeviceBitfield(), selectorCopyEngine, internalUsage); + auto bcsEngineType = EngineHelpers::getBcsEngineType(device->getRootDeviceEnvironment(), device->getDeviceBitfield(), selectorCopyEngine, internalUsage); auto bcsIndex = EngineHelpers::getBcsIndex(bcsEngineType); auto engineUsage = (internalUsage && gfxCoreHelper.preferInternalBcsEngine()) ? EngineUsage::Internal : EngineUsage::Regular; bcsEngines[bcsIndex] = neoDevice.tryGetEngine(bcsEngineType, engineUsage); diff --git a/opencl/source/program/printf_handler.cpp b/opencl/source/program/printf_handler.cpp index 021a126b6b..cf0ae0e763 100644 --- a/opencl/source/program/printf_handler.cpp +++ b/opencl/source/program/printf_handler.cpp @@ -88,7 +88,7 @@ bool PrintfHandler::printEnqueueOutput() { if (productHelper.allowStatelessCompression(hwInfo) || productHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *printfSurface)) { printfOutputDecompressed = std::make_unique(printfOutputSize); printfOutputBuffer = printfOutputDecompressed.get(); - auto &bcsEngine = device.getEngine(EngineHelpers::getBcsEngineType(hwInfo, device.getDeviceBitfield(), device.getSelectorCopyEngine(), true), EngineUsage::Regular); + auto &bcsEngine = device.getEngine(EngineHelpers::getBcsEngineType(device.getRootDeviceEnvironment(), device.getDeviceBitfield(), device.getSelectorCopyEngine(), true), EngineUsage::Regular); BlitPropertiesContainer blitPropertiesContainer; blitPropertiesContainer.push_back( diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index 53d75c9234..7032f6f505 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -324,7 +324,7 @@ TEST(CommandQueue, whenCommandQueueWithInternalUsageIsCreatedThenInternalBcsEngi auto &gfxCoreHelper = GfxCoreHelper::get(hwInfo.platform.eRenderCoreFamily); auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); auto internalUsage = true; - auto expectedEngineType = EngineHelpers::linkCopyEnginesSupported(hwInfo, device->getDeviceBitfield()) + auto expectedEngineType = EngineHelpers::linkCopyEnginesSupported(device->getRootDeviceEnvironment(), device->getDeviceBitfield()) ? aub_stream::EngineType::ENGINE_BCS2 : aub_stream::EngineType::ENGINE_BCS; @@ -942,7 +942,8 @@ HWTEST_F(CommandQueueTests, givenEngineUsageHintSetWithInvalidValueWhenCreatingC HWTEST_F(CommandQueueTests, givenNodeOrdinalSetWithRenderEngineWhenCreatingCommandQueueWithPropertiesWhereComputeEngineSetThenProperEngineUsed) { DebugManagerStateRestore restore; - auto forcedEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *defaultHwInfo); + MockExecutionEnvironment executionEnvironment{}; + auto forcedEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *executionEnvironment.rootDeviceEnvironments[0]); DebugManager.flags.NodeOrdinal.set(static_cast(forcedEngine)); auto pDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); @@ -975,7 +976,8 @@ HWTEST_F(CommandQueueTests, givenNodeOrdinalSetWithRenderEngineWhenCreatingComma HWTEST_F(CommandQueueTests, givenNodeOrdinalSetWithCcsEngineWhenCreatingCommandQueueWithPropertiesAndRegularCcsEngineNotExistThenEngineNotForced) { DebugManagerStateRestore restore; - auto defaultEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *defaultHwInfo); + MockExecutionEnvironment executionEnvironment{}; + auto defaultEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *executionEnvironment.rootDeviceEnvironments[0]); DebugManager.flags.NodeOrdinal.set(static_cast(defaultEngine)); auto pDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); @@ -992,7 +994,7 @@ HWTEST_F(CommandQueueTests, givenNodeOrdinalSetWithCcsEngineWhenCreatingCommandQ }; RAIIGfxCoreHelperFactory overrideGfxCoreHelper{defaultHwInfo->platform.eRenderCoreFamily}; - auto forcedEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_CCS, *defaultHwInfo); + auto forcedEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_CCS, pDevice->getRootDeviceEnvironment()); DebugManager.flags.NodeOrdinal.set(static_cast(forcedEngine)); auto pCmdQ = CommandQueue::create( @@ -2739,9 +2741,9 @@ TEST_F(MultiTileFixture, givenTile1WhenQueueIsCreatedThenItContainsTile1Device) struct CopyOnlyQueueTests : ::testing::Test { void SetUp() override { - typeUsageRcs.first = EngineHelpers::remapEngineTypeToHwSpecific(typeUsageRcs.first, *defaultHwInfo); - auto device = MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get()); + typeUsageRcs.first = EngineHelpers::remapEngineTypeToHwSpecific(typeUsageRcs.first, device->getRootDeviceEnvironment()); + auto copyEngineGroup = std::find_if(device->regularEngineGroups.begin(), device->regularEngineGroups.end(), [](const auto &engineGroup) { return engineGroup.engineGroupType == EngineGroupType::Copy; }); @@ -2854,7 +2856,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, MultiEngineQueueHwTests, givenQueueFamilyPropertyWh auto retVal = CL_SUCCESS; const auto &ccsInstances = localHwInfo.gtSystemInfo.CCSInfo.Instances.Bits; std::vector commandQueueTestValues; - addTestValueIfAvailable(commandQueueTestValues, EngineGroupType::RenderCompute, 0, EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, device->getHardwareInfo()), true); + addTestValueIfAvailable(commandQueueTestValues, EngineGroupType::RenderCompute, 0, EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, device->getRootDeviceEnvironment()), true); addTestValueIfAvailable(commandQueueTestValues, EngineGroupType::Compute, 0, aub_stream::ENGINE_CCS, ccsFound); addTestValueIfAvailable(commandQueueTestValues, EngineGroupType::Compute, 1, aub_stream::ENGINE_CCS1, ccsInstances.CCS1Enabled); addTestValueIfAvailable(commandQueueTestValues, EngineGroupType::Compute, 2, aub_stream::ENGINE_CCS2, ccsInstances.CCS2Enabled); diff --git a/opencl/test/unit_test/context/context_tests.cpp b/opencl/test/unit_test/context/context_tests.cpp index 77dc630aa9..7739a14c9c 100644 --- a/opencl/test/unit_test/context/context_tests.cpp +++ b/opencl/test/unit_test/context/context_tests.cpp @@ -548,11 +548,11 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ContextCreateTests, givenGpuHangOnFlushBcsTaskAndLo auto &selectorCopyEngine = blitDevice->getSelectorCopyEngine(); auto deviceBitfield = blitDevice->getDeviceBitfield(); - const auto &hwInfo = testedDevice->getDevice().getHardwareInfo(); - auto &gfxCoreHelper = GfxCoreHelper::get(hwInfo.platform.eRenderCoreFamily); + auto &rootDeviceEnvironment = testedDevice->getRootDeviceEnvironment(); + auto &gfxCoreHelper = rootDeviceEnvironment.getHelper(); auto internalUsage = true; - auto bcsEngineType = EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, internalUsage); + auto bcsEngineType = EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, internalUsage); auto bcsEngineUsage = gfxCoreHelper.preferInternalBcsEngine() ? EngineUsage::Internal : EngineUsage::Regular; auto bcsEngine = blitDevice->tryGetEngine(bcsEngineType, bcsEngineUsage); ASSERT_NE(nullptr, bcsEngine); diff --git a/opencl/test/unit_test/program/printf_handler_tests.cpp b/opencl/test/unit_test/program/printf_handler_tests.cpp index be8b9c4252..7326e6b3df 100644 --- a/opencl/test/unit_test/program/printf_handler_tests.cpp +++ b/opencl/test/unit_test/program/printf_handler_tests.cpp @@ -143,7 +143,7 @@ HWTEST_F(PrintfHandlerTests, givenEnabledStatelessCompressionWhenPrintEnqueueOut EXPECT_TRUE(printfHandler->printEnqueueOutput()); - auto &bcsEngine = device->getEngine(EngineHelpers::getBcsEngineType(device->getHardwareInfo(), device->getDeviceBitfield(), device->getSelectorCopyEngine(), true), EngineUsage::Regular); + auto &bcsEngine = device->getEngine(EngineHelpers::getBcsEngineType(device->getRootDeviceEnvironment(), device->getDeviceBitfield(), device->getSelectorCopyEngine(), true), EngineUsage::Regular); auto bcsCsr = static_cast *>(bcsEngine.commandStreamReceiver); if (enable > 0) { @@ -180,7 +180,7 @@ HWTEST_F(PrintfHandlerTests, givenGpuHangOnFlushBcsStreamAndEnabledStatelessComp printfHandler->prepareDispatch(multiDispatchInfo); EXPECT_NE(nullptr, printfHandler->getSurface()); - auto &bcsEngine = device->getEngine(EngineHelpers::getBcsEngineType(device->getHardwareInfo(), device->getDeviceBitfield(), device->getSelectorCopyEngine(), true), EngineUsage::Regular); + auto &bcsEngine = device->getEngine(EngineHelpers::getBcsEngineType(device->getRootDeviceEnvironment(), device->getDeviceBitfield(), device->getSelectorCopyEngine(), true), EngineUsage::Regular); auto bcsCsr = static_cast *>(bcsEngine.commandStreamReceiver); bcsCsr->callBaseFlushBcsTask = false; bcsCsr->flushBcsTaskReturnValue = CompletionStamp::gpuHang; @@ -227,7 +227,7 @@ HWTEST_F(PrintfHandlerTests, givenDisallowedLocalMemoryCpuAccessWhenPrintEnqueue printfHandler->printEnqueueOutput(); - auto &bcsEngine = device->getEngine(EngineHelpers::getBcsEngineType(device->getHardwareInfo(), device->getDeviceBitfield(), device->getSelectorCopyEngine(), true), EngineUsage::Regular); + auto &bcsEngine = device->getEngine(EngineHelpers::getBcsEngineType(device->getRootDeviceEnvironment(), device->getDeviceBitfield(), device->getSelectorCopyEngine(), true), EngineUsage::Regular); auto bcsCsr = static_cast *>(bcsEngine.commandStreamReceiver); EXPECT_TRUE(bcsCsr->blitBufferCalled >= 1); diff --git a/shared/source/helpers/blit_commands_helper.cpp b/shared/source/helpers/blit_commands_helper.cpp index a323ea8a36..19267df3bc 100644 --- a/shared/source/helpers/blit_commands_helper.cpp +++ b/shared/source/helpers/blit_commands_helper.cpp @@ -193,7 +193,7 @@ BlitOperationResult BlitHelper::blitMemoryToAllocationBanks(const Device &device auto &selectorCopyEngine = pDeviceForBlit->getSelectorCopyEngine(); auto deviceBitfield = pDeviceForBlit->getDeviceBitfield(); auto internalUsage = true; - auto bcsEngineType = EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, internalUsage); + auto bcsEngineType = EngineHelpers::getBcsEngineType(pDeviceForBlit->getRootDeviceEnvironment(), deviceBitfield, selectorCopyEngine, internalUsage); auto bcsEngineUsage = gfxCoreHelper.preferInternalBcsEngine() ? EngineUsage::Internal : EngineUsage::Regular; auto bcsEngine = pDeviceForBlit->tryGetEngine(bcsEngineType, bcsEngineUsage); if (!bcsEngine) { diff --git a/shared/source/helpers/engine_node_helper.cpp b/shared/source/helpers/engine_node_helper.cpp index 7298cc7897..aecd1e8ac7 100644 --- a/shared/source/helpers/engine_node_helper.cpp +++ b/shared/source/helpers/engine_node_helper.cpp @@ -88,7 +88,9 @@ bool isBcsVirtualEngineEnabled(aub_stream::EngineType engineType) { return useVirtualEnginesForBcs; } -aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield, SelectorCopyEngine &selectorCopyEngine, bool internalUsage) { +aub_stream::EngineType getBcsEngineType(const RootDeviceEnvironment &rootDeviceEnvironment, const DeviceBitfield &deviceBitfield, SelectorCopyEngine &selectorCopyEngine, bool internalUsage) { + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + auto &productHelper = rootDeviceEnvironment.getHelper(); if (DebugManager.flags.ForceBcsEngineIndex.get() != -1) { auto index = DebugManager.flags.ForceBcsEngineIndex.get(); UNRECOVERABLE_IF(index > 8); @@ -97,7 +99,7 @@ aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, const Device : static_cast(aub_stream::EngineType::ENGINE_BCS1 + index - 1); } - if (!linkCopyEnginesSupported(hwInfo, deviceBitfield)) { + if (!linkCopyEnginesSupported(rootDeviceEnvironment, deviceBitfield)) { return aub_stream::ENGINE_BCS; } @@ -109,7 +111,7 @@ aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, const Device return aub_stream::ENGINE_BCS3; } - auto enableSelector = ProductHelper::get(hwInfo.platform.eProductFamily)->isCopyEngineSelectorEnabled(hwInfo); + auto enableSelector = productHelper.isCopyEngineSelectorEnabled(hwInfo); if (DebugManager.flags.EnableCopyEngineSelector.get() != -1) { enableSelector = DebugManager.flags.EnableCopyEngineSelector.get(); @@ -118,7 +120,7 @@ aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, const Device if (enableSelector) { const bool isMainCopyEngineAlreadyUsed = selectorCopyEngine.isMainUsed.exchange(true); if (isMainCopyEngineAlreadyUsed) { - return selectLinkCopyEngine(hwInfo, deviceBitfield, selectorCopyEngine.selector); + return selectLinkCopyEngine(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine.selector); } } @@ -131,8 +133,9 @@ void releaseBcsEngineType(aub_stream::EngineType engineType, SelectorCopyEngine } } -aub_stream::EngineType remapEngineTypeToHwSpecific(aub_stream::EngineType inputType, const HardwareInfo &hwInfo) { - bool isExpectedProduct = GfxCoreHelper::get(hwInfo.platform.eRenderCoreFamily).isEngineTypeRemappingToHwSpecificRequired(); +aub_stream::EngineType remapEngineTypeToHwSpecific(aub_stream::EngineType inputType, const RootDeviceEnvironment &rootDeviceEnvironment) { + auto &gfxCoreHelper = rootDeviceEnvironment.getHelper(); + bool isExpectedProduct = gfxCoreHelper.isEngineTypeRemappingToHwSpecificRequired(); if (isExpectedProduct && inputType == aub_stream::EngineType::ENGINE_RCS) { return aub_stream::EngineType::ENGINE_CCCS; @@ -167,8 +170,9 @@ bool isBcsEnabled(const HardwareInfo &hwInfo, aub_stream::EngineType engineType) return hwInfo.featureTable.ftrBcsInfo.test(getBcsIndex(engineType)); } -bool linkCopyEnginesSupported(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield) { - auto &gfxCoreHelper = GfxCoreHelper::get(hwInfo.platform.eRenderCoreFamily); +bool linkCopyEnginesSupported(const RootDeviceEnvironment &rootDeviceEnvironment, const DeviceBitfield &deviceBitfield) { + auto &gfxCoreHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); const aub_stream::EngineType engine1 = gfxCoreHelper.isSubDeviceEngineSupported(hwInfo, deviceBitfield, aub_stream::ENGINE_BCS1) ? aub_stream::ENGINE_BCS1 : aub_stream::ENGINE_BCS4; @@ -177,8 +181,9 @@ bool linkCopyEnginesSupported(const HardwareInfo &hwInfo, const DeviceBitfield & return isBcsEnabled(hwInfo, engine1) || isBcsEnabled(hwInfo, engine2); } -aub_stream::EngineType selectLinkCopyEngine(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield, std::atomic &selectorCopyEngine) { - auto &gfxCoreHelper = GfxCoreHelper::get(hwInfo.platform.eRenderCoreFamily); +aub_stream::EngineType selectLinkCopyEngine(const RootDeviceEnvironment &rootDeviceEnvironment, const DeviceBitfield &deviceBitfield, std::atomic &selectorCopyEngine) { + auto &gfxCoreHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); auto enableCmdQRoundRobindBcsEngineAssign = false; if (DebugManager.flags.EnableCmdQRoundRobindBcsEngineAssign.get() != -1) { diff --git a/shared/source/helpers/engine_node_helper.h b/shared/source/helpers/engine_node_helper.h index 4ad8a204a6..49048d638b 100644 --- a/shared/source/helpers/engine_node_helper.h +++ b/shared/source/helpers/engine_node_helper.h @@ -19,6 +19,7 @@ namespace NEO { enum PreemptionMode : uint32_t; struct HardwareInfo; struct SelectorCopyEngine; +struct RootDeviceEnvironment; enum class EngineUsage : uint32_t { Regular, @@ -48,9 +49,9 @@ namespace EngineHelpers { bool isCcs(aub_stream::EngineType engineType); bool isBcs(aub_stream::EngineType engineType); bool isBcsVirtualEngineEnabled(aub_stream::EngineType engineType); -aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield, SelectorCopyEngine &selectorCopyEngine, bool internalUsage); +aub_stream::EngineType getBcsEngineType(const RootDeviceEnvironment &rootDeviceEnvironment, const DeviceBitfield &deviceBitfield, SelectorCopyEngine &selectorCopyEngine, bool internalUsage); void releaseBcsEngineType(aub_stream::EngineType engineType, SelectorCopyEngine &selectorCopyEngine); -aub_stream::EngineType remapEngineTypeToHwSpecific(aub_stream::EngineType inputType, const HardwareInfo &hwInfo); +aub_stream::EngineType remapEngineTypeToHwSpecific(aub_stream::EngineType inputType, const RootDeviceEnvironment &rootDeviceEnvironment); uint32_t getBcsIndex(aub_stream::EngineType engineType); aub_stream::EngineType mapBcsIndexToEngineType(uint32_t index, bool includeMainCopyEngine); aub_stream::EngineType mapCcsIndexToEngineType(uint32_t index); @@ -66,9 +67,9 @@ constexpr bool isLinkBcs(aub_stream::EngineType engineType) { inline constexpr uint32_t numLinkedCopyEngines = 8u; inline constexpr size_t oddLinkedCopyEnginesMask = 0b010101010; -bool linkCopyEnginesSupported(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield); +bool linkCopyEnginesSupported(const RootDeviceEnvironment &rootDeviceEnvironment, const DeviceBitfield &deviceBitfield); -aub_stream::EngineType selectLinkCopyEngine(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield, std::atomic &selectorCopyEngine); +aub_stream::EngineType selectLinkCopyEngine(const RootDeviceEnvironment &rootDeviceEnvironment, const DeviceBitfield &deviceBitfield, std::atomic &selectorCopyEngine); }; // namespace EngineHelpers } // namespace NEO diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index e3ba9589ef..6deeab0908 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -1002,7 +1002,7 @@ bool Drm::queryEngineInfo(bool isSysmanEnabled) { auto memInfo = memoryInfo.get(); if (!memInfo) { - this->engineInfo.reset(new EngineInfo(this, hwInfo, engines)); + this->engineInfo.reset(new EngineInfo(this, engines)); return true; } @@ -1035,7 +1035,7 @@ bool Drm::queryEngineInfo(bool isSysmanEnabled) { } if (tileCount == 0u) { - this->engineInfo.reset(new EngineInfo(this, hwInfo, engines)); + this->engineInfo.reset(new EngineInfo(this, engines)); return true; } @@ -1049,7 +1049,7 @@ bool Drm::queryEngineInfo(bool isSysmanEnabled) { [](const QueryItem &item) { return item.length == -EINVAL; }); if (queryUnsupported) { DEBUG_BREAK_IF(tileCount != 1); - this->engineInfo.reset(new EngineInfo(this, hwInfo, engines)); + this->engineInfo.reset(new EngineInfo(this, engines)); return true; } @@ -1060,7 +1060,7 @@ bool Drm::queryEngineInfo(bool isSysmanEnabled) { multiTileArchInfo.TileCount = tileCount; multiTileArchInfo.TileMask = static_cast(maxNBitValue(tileCount)); - this->engineInfo.reset(new EngineInfo(this, hwInfo, tileCount, distanceInfos, queryItems, engines)); + this->engineInfo.reset(new EngineInfo(this, tileCount, distanceInfos, queryItems, engines)); return true; } diff --git a/shared/source/os_interface/linux/engine_info.cpp b/shared/source/os_interface/linux/engine_info.cpp index dbd3a70936..ab45bb9bb2 100644 --- a/shared/source/os_interface/linux/engine_info.cpp +++ b/shared/source/os_interface/linux/engine_info.cpp @@ -7,6 +7,7 @@ #include "shared/source/os_interface/linux/engine_info.h" +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/bit_helpers.h" #include "shared/source/helpers/constants.h" #include "shared/source/helpers/debug_helpers.h" @@ -48,8 +49,7 @@ void assignLinkCopyEngine(std::vector &tileToEn } } // namespace -EngineInfo::EngineInfo(Drm *drm, HardwareInfo *hwInfo, const std::vector &engineInfos) - : engines(engineInfos), tileToEngineToInstanceMap(1) { +EngineInfo::EngineInfo(Drm *drm, const std::vector &engineInfos) : engines(engineInfos), tileToEngineToInstanceMap(1) { auto computeEngines = 0u; BcsInfoMask bcsInfoMask = 0; uint32_t numHostLinkCopyEngines = 0; @@ -57,11 +57,12 @@ EngineInfo::EngineInfo(Drm *drm, HardwareInfo *hwInfo, const std::vectorgetIoctlHelper(); + auto &rootDeviceEnvironment = drm->getRootDeviceEnvironment(); for (const auto &engineInfo : engineInfos) { auto &engine = engineInfo.engine; tileToEngineMap.emplace(0, engine); if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)) { - tileToEngineToInstanceMap[0][EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *hwInfo)] = engine; + tileToEngineToInstanceMap[0][EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, rootDeviceEnvironment)] = engine; } else if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)) { assignCopyEngine(EngineInfo::getBaseCopyEngineType(ioctlHelper, engineInfo.capabilities), 0, engine, bcsInfoMask, numHostLinkCopyEngines, numScaleUpLinkCopyEngines); @@ -70,15 +71,16 @@ EngineInfo::EngineInfo(Drm *drm, HardwareInfo *hwInfo, const std::vector &distanceInfos, const std::vector &queryItems, const std::vector &engineInfos) +EngineInfo::EngineInfo(Drm *drm, uint32_t tileCount, const std::vector &distanceInfos, const std::vector &queryItems, const std::vector &engineInfos) : engines(engineInfos), tileToEngineToInstanceMap(tileCount) { auto tile = 0u; auto computeEnginesPerTile = 0u; auto copyEnginesPerTile = 0u; auto ioctlHelper = drm->getIoctlHelper(); + auto &rootDeviceEnvironment = drm->getRootDeviceEnvironment(); for (auto i = 0u; i < distanceInfos.size(); i++) { if (i > 0u && distanceInfos[i].region.memoryInstance != distanceInfos[i - 1u].region.memoryInstance) { tile++; @@ -91,7 +93,7 @@ EngineInfo::EngineInfo(Drm *drm, HardwareInfo *hwInfo, uint32_t tileCount, const auto engine = distanceInfos[i].engine; tileToEngineMap.emplace(tile, engine); if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)) { - tileToEngineToInstanceMap[tile][EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *hwInfo)] = engine; + tileToEngineToInstanceMap[tile][EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, rootDeviceEnvironment)] = engine; } else if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)) { tileToEngineToInstanceMap[tile][DrmEngineMappingHelper::engineMapping[copyEnginesPerTile]] = engine; copyEnginesPerTile++; @@ -102,7 +104,7 @@ EngineInfo::EngineInfo(Drm *drm, HardwareInfo *hwInfo, uint32_t tileCount, const } BcsInfoMask bcsInfoMask = maxNBitValue(copyEnginesPerTile); - setSupportedEnginesInfo(hwInfo, computeEnginesPerTile, bcsInfoMask); + setSupportedEnginesInfo(rootDeviceEnvironment, computeEnginesPerTile, bcsInfoMask); } const EngineClassInstance *EngineInfo::getEngineInstance(uint32_t tile, aub_stream::EngineType engineType) const { @@ -117,7 +119,8 @@ const EngineClassInstance *EngineInfo::getEngineInstance(uint32_t tile, aub_stre return &iter->second; } -void EngineInfo::setSupportedEnginesInfo(HardwareInfo *hwInfo, uint32_t numComputeEngines, const BcsInfoMask &bcsInfoMask) { +void EngineInfo::setSupportedEnginesInfo(const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t numComputeEngines, const BcsInfoMask &bcsInfoMask) { + auto hwInfo = rootDeviceEnvironment.getMutableHardwareInfo(); auto &ccsInfo = hwInfo->gtSystemInfo.CCSInfo; if (numComputeEngines > 0u) { @@ -127,7 +130,7 @@ void EngineInfo::setSupportedEnginesInfo(HardwareInfo *hwInfo, uint32_t numCompu ccsInfo.NumberOfCCSEnabled = numComputeEngines; ccsInfo.Instances.CCSEnableMask = static_cast(maxNBitValue(numComputeEngines)); } else { - hwInfo->capabilityTable.defaultEngineType = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *hwInfo); + hwInfo->capabilityTable.defaultEngineType = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, rootDeviceEnvironment); hwInfo->featureTable.flags.ftrCCSNode = false; ccsInfo.IsValid = false; diff --git a/shared/source/os_interface/linux/engine_info.h b/shared/source/os_interface/linux/engine_info.h index 8d610b5c91..2986d2308f 100644 --- a/shared/source/os_interface/linux/engine_info.h +++ b/shared/source/os_interface/linux/engine_info.h @@ -17,6 +17,7 @@ #include namespace NEO { +struct RootDeviceEnvironment; struct HardwareInfo; class Drm; @@ -24,8 +25,8 @@ struct EngineInfo { public: using EngineToInstanceMap = std::map; - EngineInfo(Drm *drm, HardwareInfo *hwInfo, const std::vector &engineInfos); - EngineInfo(Drm *drm, HardwareInfo *hwInfo, uint32_t tileCount, const std::vector &distanceInfos, const std::vector &queryItems, const std::vector &engineInfos); + EngineInfo(Drm *drm, const std::vector &engineInfos); + EngineInfo(Drm *drm, uint32_t tileCount, const std::vector &distanceInfos, const std::vector &queryItems, const std::vector &engineInfos); ~EngineInfo() = default; @@ -36,7 +37,7 @@ struct EngineInfo { protected: static aub_stream::EngineType getBaseCopyEngineType(IoctlHelper *ioctlHelper, uint64_t capabilities); - static void setSupportedEnginesInfo(HardwareInfo *hwInfo, uint32_t numComputeEngines, const BcsInfoMask &bcsInfoMask); + static void setSupportedEnginesInfo(const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t numComputeEngines, const BcsInfoMask &bcsInfoMask); void assignCopyEngine(aub_stream::EngineType baseEngineType, uint32_t tileId, const EngineClassInstance &engine, BcsInfoMask &bcsInfoMask, uint32_t &numHostLinkCopyEngines, uint32_t &numScaleUpLinkCopyEngines); diff --git a/shared/test/unit_test/helpers/engine_node_helper_tests.cpp b/shared/test/unit_test/helpers/engine_node_helper_tests.cpp index 720a20d3d8..76ec357d74 100644 --- a/shared/test/unit_test/helpers/engine_node_helper_tests.cpp +++ b/shared/test/unit_test/helpers/engine_node_helper_tests.cpp @@ -9,6 +9,7 @@ #include "shared/source/helpers/engine_node_helper.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/test_macros/test.h" using namespace NEO; @@ -77,65 +78,73 @@ TEST(EngineNodeHelperTest, givenLinkCopyEnginesSupportedWhenGettingBcsEngineType DebugManagerStateRestore restorer; DebugManager.flags.EnableCopyEngineSelector.set(1); SelectorCopyEngine selectorCopyEngine{}; - HardwareInfo hwInfo = *::defaultHwInfo; + MockExecutionEnvironment executionEnvironment{}; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); DeviceBitfield deviceBitfield = 0b11; hwInfo.featureTable.ftrBcsInfo = 0b111; - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); } TEST(EngineNodeHelperTest, givenMainBcsEngineIsReleasedWhenGettingBcsEngineTypeThenItCanBeReturnedAgain) { DebugManagerStateRestore restorer; DebugManager.flags.EnableCopyEngineSelector.set(1); SelectorCopyEngine selectorCopyEngine{}; - HardwareInfo hwInfo = *::defaultHwInfo; + MockExecutionEnvironment executionEnvironment{}; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); DeviceBitfield deviceBitfield = 0b11; hwInfo.featureTable.ftrBcsInfo = 0b111; - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); EngineHelpers::releaseBcsEngineType(aub_stream::EngineType::ENGINE_BCS, selectorCopyEngine); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); } TEST(EngineNodeHelperTest, givenLinkBcsEngineIsReleasedWhenGettingBcsEngineTypeThenItDoesNotAffectFurtherSelections) { DebugManagerStateRestore restorer; DebugManager.flags.EnableCopyEngineSelector.set(1); SelectorCopyEngine selectorCopyEngine{}; - HardwareInfo hwInfo = *::defaultHwInfo; + MockExecutionEnvironment executionEnvironment{}; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); DeviceBitfield deviceBitfield = 0b11; hwInfo.featureTable.ftrBcsInfo = 0b111; - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); EngineHelpers::releaseBcsEngineType(aub_stream::EngineType::ENGINE_BCS1, selectorCopyEngine); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); } TEST(EngineNodeHelperTest, givenLinkCopyEnginesAndInternalUsageEnabledWhenGettingBcsEngineThenUseBcs2only) { DebugManagerStateRestore restorer; DebugManager.flags.EnableCopyEngineSelector.set(1); SelectorCopyEngine selectorCopyEngine{}; - HardwareInfo hwInfo = *::defaultHwInfo; + MockExecutionEnvironment executionEnvironment{}; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); DeviceBitfield deviceBitfield = 0b11; hwInfo.featureTable.ftrBcsInfo = 0b111; auto isInternalUsage = true; - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS3, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, isInternalUsage)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS3, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, isInternalUsage)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS3, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, isInternalUsage)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS3, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, isInternalUsage)); } diff --git a/shared/test/unit_test/helpers/engine_node_helper_tests_xehp_and_later.cpp b/shared/test/unit_test/helpers/engine_node_helper_tests_xehp_and_later.cpp index 8f76e7c50a..f6c5497587 100644 --- a/shared/test/unit_test/helpers/engine_node_helper_tests_xehp_and_later.cpp +++ b/shared/test/unit_test/helpers/engine_node_helper_tests_xehp_and_later.cpp @@ -16,27 +16,27 @@ using namespace NEO; using EngineNodeHelperTestsXeHPAndLater = ::Test; HWCMDTEST_F(IGFX_XE_HP_CORE, EngineNodeHelperTestsXeHPAndLater, WhenGetBcsEngineTypeIsCalledThenBcsEngineIsReturned) { - const auto hwInfo = pDevice->getHardwareInfo(); + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, {}, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, {}, selectorCopyEngine, false)); } HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenDebugVariableSetWhenAskingForEngineTypeThenReturnTheSameAsVariableIndex, IsAtLeastXeHpCore) { DebugManagerStateRestore restore; DeviceBitfield deviceBitfield = 0b11; - const auto hwInfo = pDevice->getHardwareInfo(); + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); for (int32_t i = 0; i <= 9; i++) { DebugManager.flags.ForceBcsEngineIndex.set(i); if (i == 0) { - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); } else if (i <= 8) { - EXPECT_EQ(static_cast(aub_stream::EngineType::ENGINE_BCS1 + i - 1), EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(static_cast(aub_stream::EngineType::ENGINE_BCS1 + i - 1), EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); } else { - EXPECT_ANY_THROW(EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_ANY_THROW(EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); } } } @@ -45,19 +45,20 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenForceBCSForInternalCopyEngineW DebugManagerStateRestore restore; DebugManager.flags.ForceBCSForInternalCopyEngine.set(0u); - auto hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); + auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); hwInfo.featureTable.ftrBcsInfo = 0xff; auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); DeviceBitfield deviceBitfield = 0xff; { DebugManager.flags.ForceBCSForInternalCopyEngine.set(0u); - auto engineType = EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, true); + auto engineType = EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, true); EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, engineType); } { DebugManager.flags.ForceBCSForInternalCopyEngine.set(3u); - auto engineType = EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, true); + auto engineType = EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, true); EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS3, engineType); } } @@ -67,7 +68,7 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenEnableCmdQRoundRobindBcsEngine DebugManager.flags.EnableCmdQRoundRobindBcsEngineAssign.set(1u); DeviceBitfield deviceBitfield = 0b10; - auto hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); + auto &hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo.featureTable.ftrBcsInfo.set(7); auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); @@ -80,7 +81,7 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenEnableCmdQRoundRobindBcsEngine } } - auto engineType = EngineHelpers::selectLinkCopyEngine(hwInfo, deviceBitfield, selectorCopyEngine.selector); + auto engineType = EngineHelpers::selectLinkCopyEngine(pDevice->getRootDeviceEnvironment(), deviceBitfield, selectorCopyEngine.selector); EXPECT_EQ(engineType, static_cast(expectedEngineType)); expectedEngineType++; @@ -96,7 +97,7 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenEnableCmdQRoundRobindBcsEngine DebugManager.flags.EnableCmdQRoundRobindBcsEngineAssignStartingValue.set(0); DeviceBitfield deviceBitfield = 0b10; - auto hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); + auto &hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo.featureTable.ftrBcsInfo = 0x17f; auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); @@ -115,7 +116,7 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenEnableCmdQRoundRobindBcsEngine } } - auto engineType = EngineHelpers::selectLinkCopyEngine(hwInfo, deviceBitfield, selectorCopyEngine.selector); + auto engineType = EngineHelpers::selectLinkCopyEngine(pDevice->getRootDeviceEnvironment(), deviceBitfield, selectorCopyEngine.selector); EXPECT_EQ(engineType, static_cast(expectedEngineType)); if (expectedEngineType == aub_stream::EngineType::ENGINE_BCS) { @@ -136,7 +137,7 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenEnableCmdQRoundRobindBcsEngine DebugManager.flags.EnableCmdQRoundRobindBcsEngineAssignLimit.set(6); DeviceBitfield deviceBitfield = 0b10; - auto hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); + auto &hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo.featureTable.ftrBcsInfo = 0x17f; auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); @@ -155,7 +156,7 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenEnableCmdQRoundRobindBcsEngine } } - auto engineType = EngineHelpers::selectLinkCopyEngine(hwInfo, deviceBitfield, selectorCopyEngine.selector); + auto engineType = EngineHelpers::selectLinkCopyEngine(pDevice->getRootDeviceEnvironment(), deviceBitfield, selectorCopyEngine.selector); EXPECT_EQ(engineType, static_cast(expectedEngineType)); if (expectedEngineType == aub_stream::EngineType::ENGINE_BCS) { @@ -175,7 +176,7 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenEnableCmdQRoundRobindBcsEngine DebugManager.flags.EnableCmdQRoundRobindBcsEngineAssignLimit.set(6); DeviceBitfield deviceBitfield = 0b10; - auto hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); + auto &hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo.featureTable.ftrBcsInfo = 0x17f; auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); @@ -194,7 +195,7 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenEnableCmdQRoundRobindBcsEngine } } - auto engineType = EngineHelpers::selectLinkCopyEngine(hwInfo, deviceBitfield, selectorCopyEngine.selector); + auto engineType = EngineHelpers::selectLinkCopyEngine(pDevice->getRootDeviceEnvironment(), deviceBitfield, selectorCopyEngine.selector); EXPECT_EQ(engineType, static_cast(expectedEngineType)); if (expectedEngineType == aub_stream::EngineType::ENGINE_BCS) { @@ -215,7 +216,7 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenEnableCmdQRoundRobindBcsEngine DebugManager.flags.EnableCmdQRoundRobindBcsEngineAssignLimit.set(5); DeviceBitfield deviceBitfield = 0b10; - auto hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); + auto &hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); hwInfo.featureTable.ftrBcsInfo = 0x17f; auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); @@ -234,7 +235,7 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenEnableCmdQRoundRobindBcsEngine } } - auto engineType = EngineHelpers::selectLinkCopyEngine(hwInfo, deviceBitfield, selectorCopyEngine.selector); + auto engineType = EngineHelpers::selectLinkCopyEngine(pDevice->getRootDeviceEnvironment(), deviceBitfield, selectorCopyEngine.selector); EXPECT_EQ(engineType, static_cast(expectedEngineType)); if (expectedEngineType == aub_stream::EngineType::ENGINE_BCS) { diff --git a/shared/test/unit_test/helpers/hw_helper_tests_pvc_and_later.cpp b/shared/test/unit_test/helpers/hw_helper_tests_pvc_and_later.cpp index f0b36b88f9..26a506289f 100644 --- a/shared/test/unit_test/helpers/hw_helper_tests_pvc_and_later.cpp +++ b/shared/test/unit_test/helpers/hw_helper_tests_pvc_and_later.cpp @@ -39,11 +39,12 @@ HWTEST2_F(GfxCoreHelperTestPvcAndLater, givenRenderEngineWhenRemapCalledThenUseC auto &gfxCoreHelper = getHelper(); gfxCoreHelper.adjustDefaultEngineType(&hardwareInfo); + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); - EXPECT_EQ(aub_stream::EngineType::ENGINE_CCCS, EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, hardwareInfo)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_CCCS, EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_CCCS, hardwareInfo)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_CCS, EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_CCS, hardwareInfo)); - EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_BCS, hardwareInfo)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_CCCS, EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, rootDeviceEnvironment)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_CCCS, EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_CCCS, rootDeviceEnvironment)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_CCS, EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_CCS, rootDeviceEnvironment)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_BCS, rootDeviceEnvironment)); } HWTEST2_F(GfxCoreHelperTestPvcAndLater, GivenVariousValuesAndPvcAndLaterPlatformsWhenCallingCalculateAvailableThreadCountThenCorrectValueIsReturned, IsAtLeastXeHpcCore) { diff --git a/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp index 9154daea40..783b3e2090 100644 --- a/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp @@ -35,7 +35,7 @@ TEST(DrmTest, givenEngineQuerySupportedWhenQueryingEngineInfoThenEngineInfoIsIni EXPECT_EQ(haveLocalMemory ? 3u : 2u, drm->ioctlCallsCount); ASSERT_NE(nullptr, drm->engineInfo); - auto renderEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *hwInfo); + auto renderEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, drm->rootDeviceEnvironment); auto engineInfo = drm->engineInfo.get(); auto pEngine = engineInfo->getEngineInstance(0, renderEngine); @@ -156,12 +156,12 @@ static void givenEngineTypeWhenBindingDrmContextThenContextParamEngineIsSet(std: TEST(DrmTest, givenRcsEngineWhenBindingDrmContextThenContextParamEngineIsSet) { auto executionEnvironment = std::make_unique(); - executionEnvironment->rootDeviceEnvironments[0]->initGmm(); + auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0]; + rootDeviceEnvironment.initGmm(); - auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); - auto hwInfo = drm->rootDeviceEnvironment.getHardwareInfo(); + auto drm = std::make_unique(rootDeviceEnvironment); - auto renderEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *hwInfo); + auto renderEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, rootDeviceEnvironment); givenEngineTypeWhenBindingDrmContextThenContextParamEngineIsSet(drm, renderEngine, drm_i915_gem_engine_class::I915_ENGINE_CLASS_RENDER); } @@ -574,7 +574,7 @@ TEST(DrmTest, givenDisabledCcsSupportWhenQueryingThenResetHwInfoParams) { EXPECT_FALSE(hwInfo->gtSystemInfo.CCSInfo.IsValid); EXPECT_EQ(0u, hwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled); EXPECT_EQ(0u, hwInfo->gtSystemInfo.CCSInfo.Instances.CCSEnableMask); - EXPECT_EQ(EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *hwInfo), + EXPECT_EQ(EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, drm->rootDeviceEnvironment), hwInfo->capabilityTable.defaultEngineType); } @@ -746,7 +746,7 @@ TEST(DrmTest, givenSetParamEnginesFailsWhenBindingDrmContextThenCallUnrecoverabl EXPECT_EQ(haveLocalMemory ? 3u : 2u, drm->ioctlCallsCount); ASSERT_NE(nullptr, drm->engineInfo); - auto renderEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, *hwInfo); + auto renderEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, drm->rootDeviceEnvironment); drm->storedRetValForSetParamEngines = -1; auto drmContextId = 42u; diff --git a/shared/test/unit_test/os_interface/linux/drm_engine_info_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_engine_info_tests.cpp index 8dbea0c20d..376dd719b5 100644 --- a/shared/test/unit_test/os_interface/linux/drm_engine_info_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_engine_info_tests.cpp @@ -56,13 +56,13 @@ TEST(EngineInfoTest, whenCreateEngineInfoWithRcsThenCorrectHwInfoSet) { auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); auto ioctlHelper = drm->getIoctlHelper(); - auto hwInfo = *defaultHwInfo.get(); + auto &hwInfo = *drm->getRootDeviceEnvironment().getHardwareInfo(); std::vector engines(2); engines[0].engine = {static_cast(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 0}; engines[0].capabilities = 0; engines[1].engine = {static_cast(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)), 0}; engines[1].capabilities = 0; - auto engineInfo = std::make_unique(drm.get(), &hwInfo, engines); + auto engineInfo = std::make_unique(drm.get(), engines); auto ccsInfo = hwInfo.gtSystemInfo.CCSInfo; EXPECT_FALSE(ccsInfo.IsValid); @@ -76,14 +76,14 @@ TEST(EngineInfoTest, whenCreateEngineInfoWithCcsThenCorrectHwInfoSet) { auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); auto ioctlHelper = drm->getIoctlHelper(); - auto hwInfo = *defaultHwInfo.get(); + auto &hwInfo = *drm->getRootDeviceEnvironment().getHardwareInfo(); std::vector engines(2); uint16_t ccsClass = ioctlHelper->getDrmParamValue(DrmParam::EngineClassCompute); engines[0].engine = {ccsClass, 0}; engines[0].capabilities = 0; engines[1].engine = {static_cast(ioctlHelper->getDrmParamValue(DrmParam::EngineClassCopy)), 0}; engines[1].capabilities = 0; - auto engineInfo = std::make_unique(drm.get(), &hwInfo, engines); + auto engineInfo = std::make_unique(drm.get(), engines); auto ccsInfo = hwInfo.gtSystemInfo.CCSInfo; EXPECT_TRUE(ccsInfo.IsValid); @@ -97,7 +97,6 @@ TEST(EngineInfoTest, whenGetEngineInstanceAndTileThenCorrectValuesReturned) { auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); auto ioctlHelper = drm->getIoctlHelper(); - auto hwInfo = *defaultHwInfo.get(); std::vector engines(4); engines[0].engine = {static_cast(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 0}; engines[0].capabilities = 0; @@ -122,9 +121,9 @@ TEST(EngineInfoTest, whenGetEngineInstanceAndTileThenCorrectValuesReturned) { for (auto i = 0u; i < distances.size(); i++) { queryItems[i].length = sizeof(drm_i915_query_engine_info); } - auto engineInfo = std::make_unique(drm.get(), &hwInfo, 2, distances, queryItems, engines); + auto engineInfo = std::make_unique(drm.get(), 2, distances, queryItems, engines); - auto engineType = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, hwInfo); + auto engineType = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, drm->getRootDeviceEnvironment()); auto engine = engineInfo->getEngineInstance(0, engineType); EXPECT_EQ(engines[0].engine.engineClass, engine->engineClass); EXPECT_EQ(engines[0].engine.engineInstance, engine->engineInstance); @@ -147,7 +146,6 @@ TEST(EngineInfoTest, whenCreateEngineInfoAndInvalidQueryThenNoEnginesSet) { auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); auto ioctlHelper = drm->getIoctlHelper(); - auto hwInfo = *defaultHwInfo.get(); std::vector engines(4); engines[0].engine = {static_cast(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 0}; engines[0].capabilities = 0; @@ -172,7 +170,7 @@ TEST(EngineInfoTest, whenCreateEngineInfoAndInvalidQueryThenNoEnginesSet) { for (auto i = 0u; i < distances.size(); i++) { queryItems[i].length = -1; } - auto engineInfo = std::make_unique(drm.get(), &hwInfo, 2, distances, queryItems, engines); + auto engineInfo = std::make_unique(drm.get(), 2, distances, queryItems, engines); EXPECT_EQ(nullptr, engineInfo->getEngineInstance(0, aub_stream::EngineType::ENGINE_RCS)); } @@ -181,11 +179,10 @@ TEST(EngineInfoTest, whenEmptyEngineInfoCreatedThen0TileReturned) { auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); auto ioctlHelper = drm->getIoctlHelper(); - auto hwInfo = *defaultHwInfo.get(); std::vector distances; std::vector engines; std::vector queryItems; - auto engineInfo = std::make_unique(drm.get(), &hwInfo, 0, distances, queryItems, engines); + auto engineInfo = std::make_unique(drm.get(), 0, distances, queryItems, engines); EXPECT_EQ(0u, engineInfo->getEngineTileIndex({static_cast(ioctlHelper->getDrmParamValue(DrmParam::EngineClassRender)), 1})); } diff --git a/shared/test/unit_test/xe_hpc_core/pvc/engine_node_helper_tests_pvc.cpp b/shared/test/unit_test/xe_hpc_core/pvc/engine_node_helper_tests_pvc.cpp index f85cd53faf..a8f7f4669f 100644 --- a/shared/test/unit_test/xe_hpc_core/pvc/engine_node_helper_tests_pvc.cpp +++ b/shared/test/unit_test/xe_hpc_core/pvc/engine_node_helper_tests_pvc.cpp @@ -20,27 +20,28 @@ using EngineNodeHelperPvcTests = ::Test; PVCTEST_F(EngineNodeHelperPvcTests, WhenGetBcsEngineTypeIsCalledWithoutSelectorEnabledForPVCThenCorrectBcsEngineIsReturned) { using namespace aub_stream; - auto pHwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); + auto pHwInfo = rootDeviceEnvironment.getMutableHardwareInfo(); auto deviceBitfield = pDevice->getDeviceBitfield(); pHwInfo->featureTable.ftrBcsInfo = 1; auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); selectorCopyEngine.isMainUsed.store(true); - EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); pHwInfo->featureTable.ftrBcsInfo = 0b111; - EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); pHwInfo->featureTable.ftrBcsInfo = 0b11; - EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); pHwInfo->featureTable.ftrBcsInfo = 0b101; - EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); } PVCTEST_F(EngineNodeHelperPvcTests, WhenGetBcsEngineTypeIsCalledForPVCThenCorrectBcsEngineIsReturned) { @@ -48,27 +49,28 @@ PVCTEST_F(EngineNodeHelperPvcTests, WhenGetBcsEngineTypeIsCalledForPVCThenCorrec DebugManagerStateRestore restorer; DebugManager.flags.EnableCopyEngineSelector.set(1); - auto pHwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); + auto pHwInfo = rootDeviceEnvironment.getMutableHardwareInfo(); auto deviceBitfield = pDevice->getDeviceBitfield(); pHwInfo->featureTable.ftrBcsInfo = 1; auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); selectorCopyEngine.isMainUsed.store(true); - EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); pHwInfo->featureTable.ftrBcsInfo = 0b111; - EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); pHwInfo->featureTable.ftrBcsInfo = 0b11; - EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); pHwInfo->featureTable.ftrBcsInfo = 0b101; - EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); - EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); } PVCTEST_F(EngineNodeHelperPvcTests, givenPvcBaseDieA0AndTile1WhenGettingBcsEngineTypeThenDoNotUseBcs1) { @@ -76,22 +78,23 @@ PVCTEST_F(EngineNodeHelperPvcTests, givenPvcBaseDieA0AndTile1WhenGettingBcsEngin DebugManagerStateRestore restorer; DebugManager.flags.EnableCopyEngineSelector.set(1); - auto pHwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); + auto pHwInfo = rootDeviceEnvironment.getMutableHardwareInfo(); pHwInfo->featureTable.ftrBcsInfo = 0b11111; auto deviceBitfield = 0b10; auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); { auto internalUsage = true; - EXPECT_EQ(ENGINE_BCS3, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, internalUsage)); - EXPECT_EQ(ENGINE_BCS3, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, internalUsage)); + EXPECT_EQ(ENGINE_BCS3, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, internalUsage)); + EXPECT_EQ(ENGINE_BCS3, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, internalUsage)); } { auto internalUsage = false; - EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, internalUsage)); - EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, internalUsage)); - EXPECT_EQ(ENGINE_BCS4, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, internalUsage)); - EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(*pHwInfo, deviceBitfield, selectorCopyEngine, internalUsage)); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, internalUsage)); + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, internalUsage)); + EXPECT_EQ(ENGINE_BCS4, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, internalUsage)); + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, internalUsage)); } }