From dc8b92d8a674c71eec6a13a1e4a4e0ce068de160 Mon Sep 17 00:00:00 2001 From: Rafal Maziejuk Date: Tue, 21 Sep 2021 13:34:25 +0000 Subject: [PATCH] Move heapInLocalMem function from HwHelper to HwInfoConfig Signed-off-by: Rafal Maziejuk Related-To: NEO-4541 --- .../sources/helper/heap_assigner_l0_tests.cpp | 3 ++- .../os_interface/hw_info_config_tests.cpp | 5 +++++ .../unit_test/xe_hp_core/excludes_xe_hp_core.cpp | 1 + .../xe_hp_core/xehp/hw_helper_tests_xehp.inl | 16 ---------------- shared/source/helpers/hw_helper.h | 3 --- .../source/helpers/hw_helper_bdw_and_later.inl | 5 ----- .../source/helpers/hw_helper_xehp_and_later.inl | 5 ----- shared/source/memory_manager/memory_manager.cpp | 3 ++- shared/source/os_interface/hw_info_config.h | 2 ++ .../hw_info_config_bdw_and_later.inl | 5 +++++ .../os_agnostic_hw_info_config_xe_hp_core.inl | 5 +++++ shared/test/common/mocks/mock_hw_info_config.cpp | 5 +++++ .../test_hw_info_config_xe_hp_core.cpp | 15 +++++++++++++++ 13 files changed, 42 insertions(+), 31 deletions(-) diff --git a/level_zero/core/test/unit_tests/sources/helper/heap_assigner_l0_tests.cpp b/level_zero/core/test/unit_tests/sources/helper/heap_assigner_l0_tests.cpp index eafe0f7027..7f8ea93a2f 100644 --- a/level_zero/core/test/unit_tests/sources/helper/heap_assigner_l0_tests.cpp +++ b/level_zero/core/test/unit_tests/sources/helper/heap_assigner_l0_tests.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/helpers/heap_assigner.h" +#include "shared/source/os_interface/hw_info_config.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "test.h" @@ -56,7 +57,7 @@ TEST_F(AlocationHelperTests, GivenLinearStreamAllocTypeWhenUseExternalAllocatorF allocationData.type = GraphicsAllocation::AllocationType::LINEAR_STREAM; std::unique_ptr mockMemoryManager(new MockMemoryManagerAllocationHelper(*device->getNEODevice()->getExecutionEnvironment())); mockMemoryManager->allocateGraphicsMemory(allocationData); - EXPECT_EQ(mockMemoryManager->passedUseLocalMem, HwHelper::get(device->getHwInfo().platform.eRenderCoreFamily).heapInLocalMem(device->getHwInfo())); + EXPECT_EQ(mockMemoryManager->passedUseLocalMem, HwInfoConfig::get(device->getHwInfo().platform.eProductFamily)->heapInLocalMem(device->getHwInfo())); } TEST_F(AlocationHelperTests, GivenInternalAllocTypeWhenUseExternalAllocatorForSshAndDshDisabledThenUseLocalMemEqualFalse) { diff --git a/opencl/test/unit_test/os_interface/hw_info_config_tests.cpp b/opencl/test/unit_test/os_interface/hw_info_config_tests.cpp index 56da21f467..a58a137f55 100644 --- a/opencl/test/unit_test/os_interface/hw_info_config_tests.cpp +++ b/opencl/test/unit_test/os_interface/hw_info_config_tests.cpp @@ -278,3 +278,8 @@ HWTEST_F(HwInfoConfigTest, givenHwInfoConfigWhenAskedIfPipeControlPriorToNonPipe const auto &hwInfoConfig = *HwInfoConfig::get(pInHwInfo.platform.eProductFamily); EXPECT_FALSE(hwInfoConfig.isPipeControlPriorToNonPipelinedStateCommandsWARequired(pInHwInfo)); } + +HWTEST_F(HwInfoConfigTest, givenHwInfoConfigWhenAskedIfHeapInLocalMemThenFalseIsReturned) { + const auto &hwInfoConfig = *HwInfoConfig::get(pInHwInfo.platform.eProductFamily); + EXPECT_FALSE(hwInfoConfig.heapInLocalMem(pInHwInfo)); +} diff --git a/opencl/test/unit_test/xe_hp_core/excludes_xe_hp_core.cpp b/opencl/test/unit_test/xe_hp_core/excludes_xe_hp_core.cpp index e32248e5ac..fdb02e5b6d 100644 --- a/opencl/test/unit_test/xe_hp_core/excludes_xe_hp_core.cpp +++ b/opencl/test/unit_test/xe_hp_core/excludes_xe_hp_core.cpp @@ -12,3 +12,4 @@ HWTEST_EXCLUDE_PRODUCT(BufferSetSurfaceTests, givenBufferSetSurfaceThatMemoryIsU HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, WhenAllowRenderCompressionIsCalledThenTrueIsReturned, IGFX_XE_HP_CORE); HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHardwareInfoWhenCallingIsMaxThreadsForWorkgroupWARequiredThenFalseIsReturned, IGFX_XE_HP_CORE); HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, whenCallingGetDeviceMemoryNameThenDdrIsReturned, IGFX_XE_HP_CORE); +HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHwInfoConfigWhenAskedIfHeapInLocalMemThenFalseIsReturned, IGFX_XE_HP_CORE); diff --git a/opencl/test/unit_test/xe_hp_core/xehp/hw_helper_tests_xehp.inl b/opencl/test/unit_test/xe_hp_core/xehp/hw_helper_tests_xehp.inl index 0a35d2b165..e3a6c37a97 100644 --- a/opencl/test/unit_test/xe_hp_core/xehp/hw_helper_tests_xehp.inl +++ b/opencl/test/unit_test/xe_hp_core/xehp/hw_helper_tests_xehp.inl @@ -47,22 +47,6 @@ XEHPTEST_F(HwHelperTestsXeHP, givenXEHPWhenIsBankOverrideRequiredIsCalledThenCor } } -XEHPTEST_F(HwHelperTestsXeHP, givenXEHPWhenHeapInLocalMemIsCalledThenCorrectValueIsReturned) { - DebugManagerStateRestore restore; - auto hwInfo = *defaultHwInfo; - auto &helper = HwHelper::get(renderCoreFamily); - const auto &hwInfoConfig = *HwInfoConfig::get(productFamily); - - { - hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_A0, hwInfo); - EXPECT_FALSE(helper.heapInLocalMem(hwInfo)); - } - { - hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo); - EXPECT_TRUE(helper.heapInLocalMem(hwInfo)); - } -} - XEHPTEST_F(HwHelperTestsXeHP, givenRcsDisabledWhenGetGpgpuEnginesCalledThenDontSetRcs) { HardwareInfo hwInfo = *defaultHwInfo; hwInfo.featureTable.ftrCCSNode = true; diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index aa3fbe5545..a71255916b 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -109,7 +109,6 @@ class HwHelper { virtual bool isSpecialWorkgroupSizeRequired(const HardwareInfo &hwInfo, bool isSimulation) const = 0; virtual uint32_t getGlobalTimeStampBits() const = 0; virtual uint32_t getDefaultThreadArbitrationPolicy() const = 0; - virtual bool heapInLocalMem(const HardwareInfo &hwInfo) const = 0; virtual bool useOnlyGlobalTimestamps() const = 0; virtual bool useSystemMemoryPlacementForISA(const HardwareInfo &hwInfo) const = 0; virtual bool packedFormatsSupported() const = 0; @@ -219,8 +218,6 @@ class HwHelperHw : public HwHelper { bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) const override; - bool heapInLocalMem(const HardwareInfo &hwInfo) const override; - bool hvAlign4Required() const override; bool isBufferSizeSuitableForRenderCompression(const size_t size, const HardwareInfo &hwInfo) const override; diff --git a/shared/source/helpers/hw_helper_bdw_and_later.inl b/shared/source/helpers/hw_helper_bdw_and_later.inl index 66422e34a8..61d5f25ef9 100644 --- a/shared/source/helpers/hw_helper_bdw_and_later.inl +++ b/shared/source/helpers/hw_helper_bdw_and_later.inl @@ -35,11 +35,6 @@ bool HwHelperHw::isLocalMemoryEnabled(const HardwareInfo &hwInfo) con return false; } -template -bool HwHelperHw::heapInLocalMem(const HardwareInfo &hwInfo) const { - return false; -} - template bool HwHelperHw::hvAlign4Required() const { return true; diff --git a/shared/source/helpers/hw_helper_xehp_and_later.inl b/shared/source/helpers/hw_helper_xehp_and_later.inl index a997e823f2..79165fd190 100644 --- a/shared/source/helpers/hw_helper_xehp_and_later.inl +++ b/shared/source/helpers/hw_helper_xehp_and_later.inl @@ -49,11 +49,6 @@ bool HwHelperHw::isLocalMemoryEnabled(const HardwareInfo &hwInfo) con return hwInfo.featureTable.ftrLocalMemory; } -template -bool HwHelperHw::heapInLocalMem(const HardwareInfo &hwInfo) const { - return !(hwInfo.platform.eProductFamily == IGFX_XE_HP_SDV && isWorkaroundRequired(REVISION_A0, REVISION_B, hwInfo)); -} - template bool HwHelperHw::hvAlign4Required() const { return false; diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 19aac93131..34910866ed 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -27,6 +27,7 @@ #include "shared/source/memory_manager/deferred_deleter.h" #include "shared/source/memory_manager/host_ptr_manager.h" #include "shared/source/memory_manager/internal_allocation_storage.h" +#include "shared/source/os_interface/hw_info_config.h" #include "shared/source/os_interface/os_context.h" #include "shared/source/os_interface/os_interface.h" #include "shared/source/utilities/compiler_support.h" @@ -518,7 +519,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData & if (use32Allocator || isAllocationOnLimitedGPU || (force32bitAllocations && allocationData.flags.allow32Bit && is64bit)) { auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); - bool useLocalMem = heapAssigner.useExternal32BitHeap(allocationData.type) ? HwHelper::get(hwInfo->platform.eRenderCoreFamily).heapInLocalMem(*hwInfo) : false; + bool useLocalMem = heapAssigner.useExternal32BitHeap(allocationData.type) ? HwInfoConfig::get(hwInfo->platform.eProductFamily)->heapInLocalMem(*hwInfo) : false; return allocate32BitGraphicsMemoryImpl(allocationData, useLocalMem); } if (allocationData.flags.isUSMHostAllocation && allocationData.hostPtr) { diff --git a/shared/source/os_interface/hw_info_config.h b/shared/source/os_interface/hw_info_config.h index c9c936c026..77cd9f69e7 100644 --- a/shared/source/os_interface/hw_info_config.h +++ b/shared/source/os_interface/hw_info_config.h @@ -63,6 +63,7 @@ class HwInfoConfig { virtual bool isPrefetchDisablingRequired(const HardwareInfo &hwInfo) const = 0; virtual bool isNewResidencyModelSupported() const = 0; virtual bool isPipeControlPriorToNonPipelinedStateCommandsWARequired(const HardwareInfo &hwInfo) const = 0; + virtual bool heapInLocalMem(const HardwareInfo &hwInfo) const = 0; protected: virtual LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const = 0; @@ -111,6 +112,7 @@ class HwInfoConfigHw : public HwInfoConfig { bool isPrefetchDisablingRequired(const HardwareInfo &hwInfo) const override; bool isNewResidencyModelSupported() const override; bool isPipeControlPriorToNonPipelinedStateCommandsWARequired(const HardwareInfo &hwInfo) const override; + bool heapInLocalMem(const HardwareInfo &hwInfo) const override; protected: HwInfoConfigHw() = default; diff --git a/shared/source/os_interface/hw_info_config_bdw_and_later.inl b/shared/source/os_interface/hw_info_config_bdw_and_later.inl index c5de3dc868..230bd1850f 100644 --- a/shared/source/os_interface/hw_info_config_bdw_and_later.inl +++ b/shared/source/os_interface/hw_info_config_bdw_and_later.inl @@ -40,4 +40,9 @@ bool HwInfoConfigHw::isNewResidencyModelSupported() const { return false; } +template +bool HwInfoConfigHw::heapInLocalMem(const HardwareInfo &hwInfo) const { + return false; +} + } // namespace NEO diff --git a/shared/source/xe_hp_core/os_agnostic_hw_info_config_xe_hp_core.inl b/shared/source/xe_hp_core/os_agnostic_hw_info_config_xe_hp_core.inl index 9496025000..0a49b3d4c5 100644 --- a/shared/source/xe_hp_core/os_agnostic_hw_info_config_xe_hp_core.inl +++ b/shared/source/xe_hp_core/os_agnostic_hw_info_config_xe_hp_core.inl @@ -100,3 +100,8 @@ bool HwInfoConfigHw::isPipeControlPriorToNonPipelinedStateCommandsWA } return false; } + +template <> +bool HwInfoConfigHw::heapInLocalMem(const HardwareInfo &hwInfo) const { + return !HwHelper::get(hwInfo.platform.eDisplayCoreFamily).isWorkaroundRequired(REVISION_A0, REVISION_B, hwInfo); +} diff --git a/shared/test/common/mocks/mock_hw_info_config.cpp b/shared/test/common/mocks/mock_hw_info_config.cpp index 926fe4496f..72c1f90d70 100644 --- a/shared/test/common/mocks/mock_hw_info_config.cpp +++ b/shared/test/common/mocks/mock_hw_info_config.cpp @@ -183,4 +183,9 @@ bool HwInfoConfigHw::isPipeControlPriorToNonPipelinedStateCommands return false; } +template <> +bool HwInfoConfigHw::heapInLocalMem(const HardwareInfo &hwInfo) const { + return false; +} + } //namespace NEO diff --git a/shared/test/common/xe_hp_core/test_hw_info_config_xe_hp_core.cpp b/shared/test/common/xe_hp_core/test_hw_info_config_xe_hp_core.cpp index 953f663d40..4ed3f69847 100644 --- a/shared/test/common/xe_hp_core/test_hw_info_config_xe_hp_core.cpp +++ b/shared/test/common/xe_hp_core/test_hw_info_config_xe_hp_core.cpp @@ -84,3 +84,18 @@ XEHPTEST_F(TestXeHPHwInfoConfig, givenSteppingWhenAskingForLocalMemoryAccessMode hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo); EXPECT_EQ(LocalMemoryAccessMode::Default, hwInfoConfig.getLocalMemoryAccessMode(hwInfo)); } + +XEHPTEST_F(TestXeHPHwInfoConfig, givenXEHPWhenHeapInLocalMemIsCalledThenCorrectValueIsReturned) { + DebugManagerStateRestore restore; + auto hwInfo = *defaultHwInfo; + const auto &hwInfoConfig = *HwInfoConfig::get(productFamily); + + { + hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_A0, hwInfo); + EXPECT_FALSE(hwInfoConfig.heapInLocalMem(hwInfo)); + } + { + hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo); + EXPECT_TRUE(hwInfoConfig.heapInLocalMem(hwInfo)); + } +}