From 4dde9393ada9e4c50b292fc969bd7e084229690b Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Wed, 8 Dec 2021 13:57:37 +0000 Subject: [PATCH] Extend engine checkers to support more engine types Signed-off-by: Bartosz Dunajski --- ...ngine_node_helper_tests_xehp_and_later.cpp | 21 ++++ .../os_interface/linux/CMakeLists.txt | 2 +- .../os_interface/linux/drm_mapper_tests.cpp | 27 +++- .../os_interface/windows/CMakeLists.txt | 2 +- .../windows/wddm_mapper_tests.cpp | 44 ++++--- .../test/unit_test/test_files/igdrcl.config | 3 +- .../debug_settings/debug_variables_base.inl | 1 + shared/source/helpers/engine_node_helper.cpp | 118 +++++++++++++++++- shared/source/helpers/engine_node_helper.h | 12 +- .../helpers/engine_node_helper_extra.cpp | 30 +---- .../source/os_interface/linux/CMakeLists.txt | 2 +- .../os_interface/linux/drm_engine_mapper.cpp | 7 +- .../os_interface/windows/CMakeLists.txt | 2 +- .../windows/wddm_engine_mapper.cpp | 7 +- shared/source/sku_info/definitions/sku_info.h | 5 - shared/source/sku_info/sku_info_base.h | 4 + .../helpers/engine_node_helper_tests.cpp | 95 +++++++++++++- 17 files changed, 308 insertions(+), 74 deletions(-) diff --git a/opencl/test/unit_test/helpers/engine_node_helper_tests_xehp_and_later.cpp b/opencl/test/unit_test/helpers/engine_node_helper_tests_xehp_and_later.cpp index 48a0a476c6..39de03e4d5 100644 --- a/opencl/test/unit_test/helpers/engine_node_helper_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/helpers/engine_node_helper_tests_xehp_and_later.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/helpers/engine_node_helper.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "opencl/test/unit_test/fixtures/cl_device_fixture.h" #include "test.h" @@ -19,3 +20,23 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, EngineNodeHelperTestsXeHPAndLater, WhenGetBcsEngine auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, {}, selectorCopyEngine, false)); } + +HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenDebugVariableSetWhenAskingForEngineTypeThenReturnTheSameAsVariableIndex, IsAtLeastXeHpCore) { + DebugManagerStateRestore restore; + DeviceBitfield deviceBitfield = 0b11; + + const auto hwInfo = pDevice->getHardwareInfo(); + 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)); + } else if (i <= 8) { + EXPECT_EQ(static_cast(aub_stream::EngineType::ENGINE_BCS1 + i - 1), EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); + } else { + EXPECT_ANY_THROW(EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, false)); + } + } +} \ No newline at end of file diff --git a/opencl/test/unit_test/os_interface/linux/CMakeLists.txt b/opencl/test/unit_test/os_interface/linux/CMakeLists.txt index 7fa31d254e..a6083e1d02 100644 --- a/opencl/test/unit_test/os_interface/linux/CMakeLists.txt +++ b/opencl/test/unit_test/os_interface/linux/CMakeLists.txt @@ -20,7 +20,7 @@ set(IGDRCL_SRCS_tests_os_interface_linux ${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_tests_2.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_debug_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker_tests.cpp - ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_mapper_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/drm_mapper_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_engine_info_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_info_tests.cpp diff --git a/opencl/test/unit_test/os_interface/linux/drm_mapper_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_mapper_tests.cpp index 604ef8a5f6..8c81d9b8e5 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_mapper_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_mapper_tests.cpp @@ -13,14 +13,29 @@ using namespace NEO; -TEST(DrmMapperTests, GivenRcsWhenGettingEngineNodeMapThenExecRenderIsReturned) { - unsigned int expected = I915_EXEC_RENDER; - EXPECT_EQ(DrmEngineMapper::engineNodeMap(aub_stream::ENGINE_RCS), expected); +TEST(DrmMapperTests, GivenEngineWhenMappingNodeThenCorrectEngineReturned) { + unsigned int flagBcs = DrmEngineMapper::engineNodeMap(aub_stream::ENGINE_BCS); + unsigned int flagRcs = DrmEngineMapper::engineNodeMap(aub_stream::ENGINE_RCS); + unsigned int flagCcs = DrmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS); + unsigned int flagCccs = DrmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCCS); + unsigned int expectedBcs = I915_EXEC_BLT; + unsigned int expectedRcs = I915_EXEC_RENDER; + unsigned int expectedCcs = I915_EXEC_DEFAULT; + unsigned int expectedCccs = I915_EXEC_RENDER; + EXPECT_EQ(expectedBcs, flagBcs); + EXPECT_EQ(expectedRcs, flagRcs); + EXPECT_EQ(expectedCcs, flagCcs); + EXPECT_EQ(expectedCccs, flagCccs); } -TEST(DrmMapperTests, GivenBcsWhenGettingEngineNodeMapThenExecBltIsReturned) { - unsigned int expected = I915_EXEC_BLT; - EXPECT_EQ(DrmEngineMapper::engineNodeMap(aub_stream::ENGINE_BCS), expected); +TEST(DrmMapperTests, givenLinkCopyEngineWhenMapperCalledThenReturnDefaultBltEngine) { + const std::array bcsLinkEngines = {{aub_stream::ENGINE_BCS1, aub_stream::ENGINE_BCS2, aub_stream::ENGINE_BCS3, + aub_stream::ENGINE_BCS4, aub_stream::ENGINE_BCS5, aub_stream::ENGINE_BCS6, + aub_stream::ENGINE_BCS7, aub_stream::ENGINE_BCS8}}; + + for (auto engine : bcsLinkEngines) { + EXPECT_EQ(static_cast(I915_EXEC_BLT), DrmEngineMapper::engineNodeMap(engine)); + } } TEST(DrmMapperTests, GivenCcsWhenGettingEngineNodeMapThenReturnDefault) { diff --git a/opencl/test/unit_test/os_interface/windows/CMakeLists.txt b/opencl/test/unit_test/os_interface/windows/CMakeLists.txt index a499f2c748..388b1a6fd8 100644 --- a/opencl/test/unit_test/os_interface/windows/CMakeLists.txt +++ b/opencl/test/unit_test/os_interface/windows/CMakeLists.txt @@ -30,7 +30,7 @@ set(IGDRCL_SRCS_tests_os_interface_windows ${CMAKE_CURRENT_SOURCE_DIR}/wddm_kmdaf_listener_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_tests.h - ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}wddm_mapper_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_allocate_in_device_pool_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_controller_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_handler_tests.cpp diff --git a/opencl/test/unit_test/os_interface/windows/wddm_mapper_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_mapper_tests.cpp index 61a2fa5070..49bc8a8b69 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_mapper_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_mapper_tests.cpp @@ -12,21 +12,35 @@ using namespace NEO; TEST(WddmMapperTests, givenRcsEngineTypeWhenAskedForNodeOrdinalThenReturn3d) { - GPUNODE_ORDINAL rcsNode = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_RCS); - GPUNODE_ORDINAL bcsNode = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_BCS); - GPUNODE_ORDINAL ccsNode = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS); - GPUNODE_ORDINAL ccsNode1 = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS1); - GPUNODE_ORDINAL ccsNode2 = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS2); - GPUNODE_ORDINAL ccsNode3 = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS3); - GPUNODE_ORDINAL expectedRcsNode = GPUNODE_3D; - GPUNODE_ORDINAL expectedBcsNode = GPUNODE_BLT; - GPUNODE_ORDINAL expectedCcsNode = GPUNODE_CCS0; - EXPECT_EQ(expectedRcsNode, rcsNode); - EXPECT_EQ(expectedBcsNode, bcsNode); - EXPECT_EQ(expectedCcsNode, ccsNode); - EXPECT_EQ(expectedCcsNode, ccsNode1); - EXPECT_EQ(expectedCcsNode, ccsNode2); - EXPECT_EQ(expectedCcsNode, ccsNode3); + GPUNODE_ORDINAL gpuNodeBcs = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_BCS); + GPUNODE_ORDINAL gpuNodeRcs = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_RCS); + GPUNODE_ORDINAL gpuNodeCcs = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS); + GPUNODE_ORDINAL gpuNodeCcs1 = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS1); + GPUNODE_ORDINAL gpuNodeCcs2 = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS2); + GPUNODE_ORDINAL gpuNodeCcs3 = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCS3); + GPUNODE_ORDINAL gpuNodeCccs = WddmEngineMapper::engineNodeMap(aub_stream::ENGINE_CCCS); + + GPUNODE_ORDINAL expectedBcs = GPUNODE_BLT; + GPUNODE_ORDINAL expectedRcs = GPUNODE_3D; + GPUNODE_ORDINAL expectedCcs = GPUNODE_CCS0; + GPUNODE_ORDINAL expectedCccs = GPUNODE_3D; + EXPECT_EQ(expectedBcs, gpuNodeBcs); + EXPECT_EQ(expectedRcs, gpuNodeRcs); + EXPECT_EQ(expectedCcs, gpuNodeCcs); + EXPECT_EQ(expectedCcs, gpuNodeCcs1); + EXPECT_EQ(expectedCcs, gpuNodeCcs2); + EXPECT_EQ(expectedCcs, gpuNodeCcs3); + EXPECT_EQ(expectedCccs, gpuNodeCccs); +} + +TEST(WddmMapperTests, givenLinkCopyEngineWhenMapperCalledThenReturnDefaultBltEngine) { + const std::array bcsLinkEngines = {{aub_stream::ENGINE_BCS1, aub_stream::ENGINE_BCS2, aub_stream::ENGINE_BCS3, + aub_stream::ENGINE_BCS4, aub_stream::ENGINE_BCS5, aub_stream::ENGINE_BCS6, + aub_stream::ENGINE_BCS7, aub_stream::ENGINE_BCS8}}; + + for (auto engine : bcsLinkEngines) { + EXPECT_EQ(GPUNODE_BLT, WddmEngineMapper::engineNodeMap(engine)); + } } TEST(WddmMapperTests, givenNotSupportedEngineWhenAskedForNodeThenAbort) { diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index 2e54baba50..2be64cb3f8 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -360,4 +360,5 @@ DoNotReportTile1BscWaActive = -1 ForceTile0PlacementForTile1ResourcesWaActive = -1 ClosEnabled = -1 AddStatePrefetchCmdToMemoryPrefetchAPI = -1 -UpdateCrossThreadDataSize = 0 \ No newline at end of file +UpdateCrossThreadDataSize = 0 +ForceBcsEngineIndex = -1 \ No newline at end of file diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 74bd606e97..7a46605419 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -176,6 +176,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, ProgramGlobalFenceAsKernelInstructionInEUKernel, DECLARE_DEBUG_VARIABLE(int32_t, DoNotReportTile1BscWaActive, -1, "-1: default, 0: WA Disabled, 1: WA enabled") DECLARE_DEBUG_VARIABLE(int32_t, ForceTile0PlacementForTile1ResourcesWaActive, -1, "-1: default, 0: WA Disabled, 1: WA enabled") DECLARE_DEBUG_VARIABLE(int32_t, ClosEnabled, -1, "-1: default, 0: disabled, 1: enabled. Enable CLOS based cache reservation") +DECLARE_DEBUG_VARIABLE(int32_t, ForceBcsEngineIndex, -1, "-1: default, >=0 Copy Engine index") /*LOGGING FLAGS*/ DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level") diff --git a/shared/source/helpers/engine_node_helper.cpp b/shared/source/helpers/engine_node_helper.cpp index ac12cfc4a2..77e2ea1d12 100644 --- a/shared/source/helpers/engine_node_helper.cpp +++ b/shared/source/helpers/engine_node_helper.cpp @@ -7,6 +7,9 @@ #include "shared/source/helpers/engine_node_helper.h" +#include "shared/source/device/device.h" +#include "shared/source/helpers/hw_helper.h" + namespace NEO::EngineHelpers { std::string engineUsageToString(EngineUsage usage) { @@ -42,8 +45,26 @@ std::string engineTypeToString(aub_stream::EngineType engineType) { return "CCS2"; case aub_stream::EngineType::ENGINE_CCS3: return "CCS3"; + case aub_stream::EngineType::ENGINE_CCCS: + return "CCCS"; + case aub_stream::EngineType::ENGINE_BCS1: + return "BCS1"; + case aub_stream::EngineType::ENGINE_BCS2: + return "BCS2"; + case aub_stream::EngineType::ENGINE_BCS3: + return "BCS3"; + case aub_stream::EngineType::ENGINE_BCS4: + return "BCS4"; + case aub_stream::EngineType::ENGINE_BCS5: + return "BCS5"; + case aub_stream::EngineType::ENGINE_BCS6: + return "BCS6"; + case aub_stream::EngineType::ENGINE_BCS7: + return "BCS7"; + case aub_stream::EngineType::ENGINE_BCS8: + return "BCS8"; default: - return engineTypeToStringAdditional(engineType); + return "Unknown"; } } @@ -51,4 +72,99 @@ bool isCcs(aub_stream::EngineType engineType) { return engineType >= aub_stream::ENGINE_CCS && engineType <= aub_stream::ENGINE_CCS3; } +bool isBcs(aub_stream::EngineType engineType) { + return engineType == aub_stream::ENGINE_BCS || (engineType >= aub_stream::ENGINE_BCS1 && engineType <= aub_stream::ENGINE_BCS8); +} + +aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield, SelectorCopyEngine &selectorCopyEngine, bool internalUsage) { + if (DebugManager.flags.ForceBcsEngineIndex.get() != -1) { + auto index = DebugManager.flags.ForceBcsEngineIndex.get(); + UNRECOVERABLE_IF(index > 8); + + return (index == 0) ? aub_stream::EngineType::ENGINE_BCS + : static_cast(aub_stream::EngineType::ENGINE_BCS1 + index - 1); + } + + if (!linkCopyEnginesSupported(hwInfo, deviceBitfield)) { + return aub_stream::ENGINE_BCS; + } + + if (internalUsage) { + return selectLinkCopyEngine(hwInfo, deviceBitfield, selectorCopyEngine.selector); + } + + const bool isMainCopyEngineAlreadyUsed = selectorCopyEngine.isMainUsed.exchange(true); + if (isMainCopyEngineAlreadyUsed) { + return selectLinkCopyEngine(hwInfo, deviceBitfield, selectorCopyEngine.selector); + } + + return aub_stream::ENGINE_BCS; +} + +void releaseBcsEngineType(aub_stream::EngineType engineType, SelectorCopyEngine &selectorCopyEngine) { + if (engineType == aub_stream::EngineType::ENGINE_BCS) { + selectorCopyEngine.isMainUsed.store(false); + } +} + +aub_stream::EngineType remapEngineTypeToHwSpecific(aub_stream::EngineType inputType, const HardwareInfo &hwInfo) { + bool isExpectedProduct = HwHelper::get(hwInfo.platform.eRenderCoreFamily).isEngineTypeRemappingToHwSpecificRequired(); + + if (isExpectedProduct && inputType == aub_stream::EngineType::ENGINE_RCS) { + return aub_stream::EngineType::ENGINE_CCCS; + } + + return inputType; +} + +uint32_t getBcsIndex(aub_stream::EngineType engineType) { + UNRECOVERABLE_IF(!isBcs(engineType)); + if (engineType == aub_stream::ENGINE_BCS) { + return 0; + } else { + return 1 + engineType - aub_stream::ENGINE_BCS1; + } +} + +aub_stream::EngineType mapBcsIndexToEngineType(uint32_t index, bool includeMainCopyEngine) { + if (index == 0 && includeMainCopyEngine) { + return aub_stream::ENGINE_BCS; + } else { + auto offset = index; + if (includeMainCopyEngine) { + offset -= 1; + } + + return static_cast(offset + static_cast(aub_stream::ENGINE_BCS1)); + } +} + +bool isBcsEnabled(const HardwareInfo &hwInfo, aub_stream::EngineType engineType) { + return hwInfo.featureTable.ftrBcsInfo.test(getBcsIndex(engineType)); +} + +bool linkCopyEnginesSupported(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield) { + const aub_stream::EngineType engine1 = HwHelper::get(hwInfo.platform.eRenderCoreFamily).isSubDeviceEngineSupported(hwInfo, deviceBitfield, aub_stream::ENGINE_BCS1) + ? aub_stream::ENGINE_BCS1 + : aub_stream::ENGINE_BCS4; + const aub_stream::EngineType engine2 = aub_stream::ENGINE_BCS2; + + return isBcsEnabled(hwInfo, engine1) || isBcsEnabled(hwInfo, engine2); +} + +aub_stream::EngineType selectLinkCopyEngine(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield, std::atomic &selectorCopyEngine) { + const aub_stream::EngineType engine1 = HwHelper::get(hwInfo.platform.eRenderCoreFamily).isSubDeviceEngineSupported(hwInfo, deviceBitfield, aub_stream::ENGINE_BCS1) + ? aub_stream::ENGINE_BCS1 + : aub_stream::ENGINE_BCS4; + const aub_stream::EngineType engine2 = aub_stream::ENGINE_BCS2; + + if (isBcsEnabled(hwInfo, engine1) && isBcsEnabled(hwInfo, engine2)) { + // both BCS enabled, round robin + return selectorCopyEngine.fetch_xor(1u) ? engine1 : engine2; + } else { + // one BCS enabled + return isBcsEnabled(hwInfo, engine1) ? engine1 : engine2; + } +} + } // namespace NEO::EngineHelpers diff --git a/shared/source/helpers/engine_node_helper.h b/shared/source/helpers/engine_node_helper.h index e5bc2f5a0e..a5544bf6b2 100644 --- a/shared/source/helpers/engine_node_helper.h +++ b/shared/source/helpers/engine_node_helper.h @@ -55,10 +55,18 @@ aub_stream::EngineType remapEngineTypeToHwSpecific(aub_stream::EngineType inputT uint32_t getBcsIndex(aub_stream::EngineType engineType); aub_stream::EngineType mapBcsIndexToEngineType(uint32_t index, bool includeMainCopyEngine); aub_stream::EngineType mapCcsIndexToEngineType(uint32_t index); - std::string engineTypeToString(aub_stream::EngineType engineType); -std::string engineTypeToStringAdditional(aub_stream::EngineType engineType); std::string engineUsageToString(EngineUsage usage); +bool isBcsEnabled(const HardwareInfo &hwInfo, aub_stream::EngineType engineType); + +constexpr bool isLinkBcs(aub_stream::EngineType engineType) { + return engineType >= aub_stream::ENGINE_BCS1 && engineType <= aub_stream::ENGINE_BCS8; +} + +bool linkCopyEnginesSupported(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield); + +aub_stream::EngineType selectLinkCopyEngine(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield, std::atomic &selectorCopyEngine); + }; // namespace EngineHelpers } // namespace NEO diff --git a/shared/source/helpers/engine_node_helper_extra.cpp b/shared/source/helpers/engine_node_helper_extra.cpp index ffefce15a8..2fa7811a63 100644 --- a/shared/source/helpers/engine_node_helper_extra.cpp +++ b/shared/source/helpers/engine_node_helper_extra.cpp @@ -9,32 +9,8 @@ namespace NEO { namespace EngineHelpers { -bool isBcs(aub_stream::EngineType engineType) { - return engineType == aub_stream::ENGINE_BCS; +bool isBcsVirtualEngineEnabled() { + return false; } - -aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, const DeviceBitfield &deviceBitfield, SelectorCopyEngine &selectorCopyEngine, bool internalUsage) { - return aub_stream::EngineType::ENGINE_BCS; -} - -void releaseBcsEngineType(aub_stream::EngineType engineType, SelectorCopyEngine &selectorCopyEngine) {} - -std::string engineTypeToStringAdditional(aub_stream::EngineType engineType) { - return "Unknown"; -} - -aub_stream::EngineType remapEngineTypeToHwSpecific(aub_stream::EngineType inputType, const HardwareInfo &hwInfo) { - return inputType; -} - -uint32_t getBcsIndex(aub_stream::EngineType engineType) { - return 0; -} - -aub_stream::EngineType mapBcsIndexToEngineType(uint32_t index, bool includeMainCopyEngine) { - DEBUG_BREAK_IF(index != 0); - return aub_stream::ENGINE_BCS; -} - } // namespace EngineHelpers -} // namespace NEO +} // namespace NEO \ No newline at end of file diff --git a/shared/source/os_interface/linux/CMakeLists.txt b/shared/source/os_interface/linux/CMakeLists.txt index 745c9331bc..a9c4bb49fc 100644 --- a/shared/source/os_interface/linux/CMakeLists.txt +++ b/shared/source/os_interface/linux/CMakeLists.txt @@ -28,7 +28,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX ${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager.h - ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_engine_mapper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/drm_engine_mapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_engine_mapper.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_neo.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_neo.cpp diff --git a/shared/source/os_interface/linux/drm_engine_mapper.cpp b/shared/source/os_interface/linux/drm_engine_mapper.cpp index e4c6eff029..58ce9a075b 100644 --- a/shared/source/os_interface/linux/drm_engine_mapper.cpp +++ b/shared/source/os_interface/linux/drm_engine_mapper.cpp @@ -17,11 +17,10 @@ namespace NEO { unsigned int DrmEngineMapper::engineNodeMap(aub_stream::EngineType engineType) { if (EngineHelpers::isCcs(engineType)) { return I915_EXEC_DEFAULT; - } else if (aub_stream::ENGINE_RCS == engineType) { - return I915_EXEC_RENDER; - } else if (aub_stream::ENGINE_BCS == engineType) { + } else if (aub_stream::ENGINE_BCS == engineType || EngineHelpers::isLinkBcs(engineType)) { return I915_EXEC_BLT; } - UNRECOVERABLE_IF(true); + UNRECOVERABLE_IF(engineType != aub_stream::ENGINE_RCS && engineType != aub_stream::ENGINE_CCCS); + return I915_EXEC_RENDER; } } // namespace NEO diff --git a/shared/source/os_interface/windows/CMakeLists.txt b/shared/source/os_interface/windows/CMakeLists.txt index ce34904de1..d14df2860c 100644 --- a/shared/source/os_interface/windows/CMakeLists.txt +++ b/shared/source/os_interface/windows/CMakeLists.txt @@ -51,7 +51,7 @@ set(NEO_CORE_OS_INTERFACE_WDDM ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}wddm_additional_context_flags.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}wddm_allocation.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}wddm_apply_additional_map_gpu_va_fields.cpp - ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}wddm_engine_mapper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/wddm_engine_mapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/d3dkmthk_wrapper.h ${CMAKE_CURRENT_SOURCE_DIR}/dxgi_wrapper.h ${CMAKE_CURRENT_SOURCE_DIR}/deferrable_deletion_win.cpp diff --git a/shared/source/os_interface/windows/wddm_engine_mapper.cpp b/shared/source/os_interface/windows/wddm_engine_mapper.cpp index 4ed33bf7aa..2b867ba0b2 100644 --- a/shared/source/os_interface/windows/wddm_engine_mapper.cpp +++ b/shared/source/os_interface/windows/wddm_engine_mapper.cpp @@ -15,12 +15,11 @@ namespace NEO { GPUNODE_ORDINAL WddmEngineMapper::engineNodeMap(aub_stream::EngineType engineType) { if (EngineHelpers::isCcs(engineType)) { return GPUNODE_CCS0; - } else if (aub_stream::ENGINE_RCS == engineType) { - return GPUNODE_3D; - } else if (aub_stream::ENGINE_BCS == engineType) { + } else if (aub_stream::ENGINE_BCS == engineType || EngineHelpers::isLinkBcs(engineType)) { return GPUNODE_BLT; } - UNRECOVERABLE_IF(true); + UNRECOVERABLE_IF(engineType != aub_stream::ENGINE_RCS && engineType != aub_stream::ENGINE_CCCS); + return GPUNODE_3D; } } // namespace NEO diff --git a/shared/source/sku_info/definitions/sku_info.h b/shared/source/sku_info/definitions/sku_info.h index 9072eb72e9..961f2b52e0 100644 --- a/shared/source/sku_info/definitions/sku_info.h +++ b/shared/source/sku_info/definitions/sku_info.h @@ -9,13 +9,8 @@ #include "shared/source/helpers/hash.h" #include "shared/source/sku_info/sku_info_base.h" -#include - namespace NEO { -constexpr inline size_t bcsInfoMaskSize = 1u; -using BcsInfoMask = std::bitset; - struct FeatureTable : FeatureTableBase { BcsInfoMask ftrBcsInfo = 0; diff --git a/shared/source/sku_info/sku_info_base.h b/shared/source/sku_info/sku_info_base.h index 9be20ab275..e64ad15089 100644 --- a/shared/source/sku_info/sku_info_base.h +++ b/shared/source/sku_info/sku_info_base.h @@ -8,9 +8,13 @@ #pragma once #include +#include #include namespace NEO { +constexpr size_t bcsInfoMaskSize = 9u; +using BcsInfoMask = std::bitset; + struct FeatureTableBase { public: FeatureTableBase() { diff --git a/shared/test/common/helpers/engine_node_helper_tests.cpp b/shared/test/common/helpers/engine_node_helper_tests.cpp index a2b11a17d4..a596d5cb55 100644 --- a/shared/test/common/helpers/engine_node_helper_tests.cpp +++ b/shared/test/common/helpers/engine_node_helper_tests.cpp @@ -5,25 +5,28 @@ * */ +#include "shared/source/device/device.h" #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 "test.h" using namespace NEO; -TEST(EngineNodeHelperTests, givenValidEngineUsageWhenGettingStringRepresentationThenItIsCorrect) { +TEST(EngineNodeHelperTest, givenValidEngineUsageWhenGettingStringRepresentationThenItIsCorrect) { EXPECT_EQ(std::string{"Regular"}, EngineHelpers::engineUsageToString(EngineUsage::Regular)); EXPECT_EQ(std::string{"Internal"}, EngineHelpers::engineUsageToString(EngineUsage::Internal)); EXPECT_EQ(std::string{"LowPriority"}, EngineHelpers::engineUsageToString(EngineUsage::LowPriority)); EXPECT_EQ(std::string{"Cooperative"}, EngineHelpers::engineUsageToString(EngineUsage::Cooperative)); } -TEST(EngineNodeHelperTests, givenInValidEngineUsageWhenGettingStringRepresentationThenReturnUnknown) { +TEST(EngineNodeHelperTest, givenInValidEngineUsageWhenGettingStringRepresentationThenReturnUnknown) { EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineUsageToString(EngineUsage::EngineUsageCount)); EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineUsageToString(static_cast(0xcc))); } -TEST(EngineNodeHelperTests, givenValidEngineTypeWhenGettingStringRepresentationThenItIsCorrect) { +TEST(EngineNodeHelperTest, givenValidEngineTypeWhenGettingStringRepresentationThenItIsCorrect) { #define CHECK_ENGINE(type) EXPECT_EQ(std::string{#type}, EngineHelpers::engineTypeToString(aub_stream::EngineType::ENGINE_##type)) CHECK_ENGINE(RCS); CHECK_ENGINE(BCS); @@ -33,10 +36,31 @@ TEST(EngineNodeHelperTests, givenValidEngineTypeWhenGettingStringRepresentationT CHECK_ENGINE(CCS1); CHECK_ENGINE(CCS2); CHECK_ENGINE(CCS3); + CHECK_ENGINE(CCCS); + CHECK_ENGINE(BCS1); + CHECK_ENGINE(BCS2); + CHECK_ENGINE(BCS3); + CHECK_ENGINE(BCS4); + CHECK_ENGINE(BCS5); + CHECK_ENGINE(BCS6); + CHECK_ENGINE(BCS7); + CHECK_ENGINE(BCS8); #undef CHECK_ENGINE } -TEST(EngineNodeHelperTests, givenCcsEngineWhenHelperIsUsedThenReturnTrue) { +TEST(EngineNodeHelperTest, givenBcsWhenGettingBcsIndexThenReturnCorrectIndex) { + EXPECT_EQ(0u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS)); + EXPECT_EQ(1u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS1)); + EXPECT_EQ(2u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS2)); + EXPECT_EQ(3u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS3)); + EXPECT_EQ(4u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS4)); + EXPECT_EQ(5u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS5)); + EXPECT_EQ(6u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS6)); + EXPECT_EQ(7u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS7)); + EXPECT_EQ(8u, EngineHelpers::getBcsIndex(aub_stream::ENGINE_BCS8)); +} + +TEST(EngineNodeHelperTest, givenCcsEngineWhenHelperIsUsedThenReturnTrue) { EXPECT_TRUE(EngineHelpers::isCcs(aub_stream::EngineType::ENGINE_CCS)); EXPECT_TRUE(EngineHelpers::isCcs(aub_stream::EngineType::ENGINE_CCS1)); EXPECT_TRUE(EngineHelpers::isCcs(aub_stream::EngineType::ENGINE_CCS2)); @@ -45,7 +69,68 @@ TEST(EngineNodeHelperTests, givenCcsEngineWhenHelperIsUsedThenReturnTrue) { EXPECT_FALSE(EngineHelpers::isCcs(aub_stream::EngineType::NUM_ENGINES)); } -TEST(EngineNodeHelperTests, givenInvalidEngineTypeWhenGettingStringRepresentationThenItIsCorrect) { +TEST(EngineNodeHelperTest, givenInvalidEngineTypeWhenGettingStringRepresentationThenItIsCorrect) { EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineTypeToString(aub_stream::EngineType::NUM_ENGINES)); EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineTypeToString(static_cast(0xcc))); } + +TEST(EngineNodeHelperTest, givenLinkCopyEnginesSupportedWhenGettingBcsEngineTypeThenFirstReturnMainCopyEngineAndThenRoundRobinBetweenLinkEngines) { + SelectorCopyEngine selectorCopyEngine{}; + HardwareInfo hwInfo = *::defaultHwInfo; + 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)); +} + +TEST(EngineNodeHelperTest, givenMainBcsEngineIsReleasedWhenGettingBcsEngineTypeThenItCanBeReturnedAgain) { + SelectorCopyEngine selectorCopyEngine{}; + HardwareInfo hwInfo = *::defaultHwInfo; + 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)); + + 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)); +} + +TEST(EngineNodeHelperTest, givenLinkBcsEngineIsReleasedWhenGettingBcsEngineTypeThenItDoesNotAffectFurtherSelections) { + SelectorCopyEngine selectorCopyEngine{}; + HardwareInfo hwInfo = *::defaultHwInfo; + 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)); + + 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)); +} + +TEST(EngineNodeHelperTest, givenLinkCopyEnginesAndInternalUsageEnabledWhenGettingBcsEngineThenAlwaysReturnLinkEngine) { + SelectorCopyEngine selectorCopyEngine{}; + HardwareInfo hwInfo = *::defaultHwInfo; + DeviceBitfield deviceBitfield = 0b11; + hwInfo.featureTable.ftrBcsInfo = 0b111; + + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, true)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, true)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, true)); + EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, EngineHelpers::getBcsEngineType(hwInfo, deviceBitfield, selectorCopyEngine, true)); +}