From 944c33237146234d9edd0221faaf45fe66e3e65d Mon Sep 17 00:00:00 2001 From: Kamil Kopryk Date: Tue, 16 May 2023 14:53:43 +0000 Subject: [PATCH] refactor: move getProductMaxPreferredSlmSize to release helper Related-To: NEO-7786 Signed-off-by: Kamil Kopryk --- shared/source/os_interface/product_helper.h | 1 - shared/source/os_interface/product_helper.inl | 5 +---- .../source/os_interface/product_helper_hw.h | 1 - shared/source/release_helper/release_helper.h | 2 ++ .../release_helper/release_helper_1270.cpp | 11 ++++++++++ .../release_helper/release_helper_1271.cpp | 10 +++++++++ .../release_helper/release_helper_base.inl | 4 ++++ .../command_encoder_xe_hpg_core.cpp | 9 ++++++-- .../mtl/os_agnostic_product_helper_mtl.inl | 10 --------- .../mtl/product_helper_tests_mtl.cpp | 21 ++++++++++++------- 10 files changed, 48 insertions(+), 26 deletions(-) diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 06214e3f3d..273180a55c 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -102,7 +102,6 @@ class ProductHelper { virtual bool allowCompression(const HardwareInfo &hwInfo) const = 0; virtual LocalMemoryAccessMode getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const = 0; virtual bool isAllocationSizeAdjustmentRequired(const HardwareInfo &hwInfo) const = 0; - virtual int getProductMaxPreferredSlmSize(const HardwareInfo &hwInfo, int preferredEnumValue) const = 0; virtual bool isPrefetchDisablingRequired(const ReleaseHelper *releaseHelper) const = 0; virtual bool isNewResidencyModelSupported() const = 0; virtual bool isDirectSubmissionSupported(const HardwareInfo &hwInfo) const = 0; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index 849d13ebf4..e52f757f81 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -276,10 +276,7 @@ template bool ProductHelperHw::isAllocationSizeAdjustmentRequired(const HardwareInfo &hwInfo) const { return false; } -template -int ProductHelperHw::getProductMaxPreferredSlmSize(const HardwareInfo &hwInfo, int preferredEnumValue) const { - return preferredEnumValue; -} + template bool ProductHelperHw::isPrefetchDisablingRequired(const ReleaseHelper *releaseHelper) const { if (releaseHelper) { diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index 796b771c02..23df08851b 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -55,7 +55,6 @@ class ProductHelperHw : public ProductHelper { bool allowCompression(const HardwareInfo &hwInfo) const override; LocalMemoryAccessMode getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override; bool isAllocationSizeAdjustmentRequired(const HardwareInfo &hwInfo) const override; - int getProductMaxPreferredSlmSize(const HardwareInfo &hwInfo, int preferredEnumValue) const override; bool isPrefetchDisablingRequired(const ReleaseHelper *releaseHelper) const override; bool isNewResidencyModelSupported() const override; bool isDirectSubmissionSupported(const HardwareInfo &hwInfo) const override; diff --git a/shared/source/release_helper/release_helper.h b/shared/source/release_helper/release_helper.h index dd7dffefc8..54a311b296 100644 --- a/shared/source/release_helper/release_helper.h +++ b/shared/source/release_helper/release_helper.h @@ -28,6 +28,7 @@ class ReleaseHelper { virtual bool isMatrixMultiplyAccumulateSupported() const = 0; virtual bool isPipeControlPriorToNonPipelinedStateCommandsWARequired() const = 0; virtual bool isPrefetchDisablingRequired() const = 0; + virtual int getProductMaxPreferredSlmSize(int preferredEnumValue) const = 0; protected: ReleaseHelper(HardwareIpVersion hardwareIpVersion) : hardwareIpVersion(hardwareIpVersion) {} @@ -45,6 +46,7 @@ class ReleaseHelperHw : public ReleaseHelper { bool isMatrixMultiplyAccumulateSupported() const override; bool isPipeControlPriorToNonPipelinedStateCommandsWARequired() const override; bool isPrefetchDisablingRequired() const override; + int getProductMaxPreferredSlmSize(int preferredEnumValue) const override; private: ReleaseHelperHw(HardwareIpVersion hardwareIpVersion) : ReleaseHelper(hardwareIpVersion) {} diff --git a/shared/source/release_helper/release_helper_1270.cpp b/shared/source/release_helper/release_helper_1270.cpp index 5d29a58194..d717da31c2 100644 --- a/shared/source/release_helper/release_helper_1270.cpp +++ b/shared/source/release_helper/release_helper_1270.cpp @@ -7,6 +7,7 @@ #include "shared/source/release_helper/release_helper.h" #include "shared/source/release_helper/release_helper_base.inl" +#include "shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h" #include "platforms.h" #include "release_definitions.h" @@ -19,6 +20,16 @@ bool ReleaseHelperHw::isPipeControlPriorToNonPipelinedStateCommandsWARe return hardwareIpVersion.value == AOT::MTL_M_A0; } +template <> +int ReleaseHelperHw::getProductMaxPreferredSlmSize(int preferredEnumValue) const { + using PREFERRED_SLM_ALLOCATION_SIZE = typename XeHpgCoreFamily::INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE; + + if (hardwareIpVersion.value == AOT::MTL_M_A0) { + return static_cast(PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_96K); + } + return preferredEnumValue; +} + } // namespace NEO #include "shared/source/release_helper/release_helper_common_xe_lpg.inl" diff --git a/shared/source/release_helper/release_helper_1271.cpp b/shared/source/release_helper/release_helper_1271.cpp index 5cf5721463..dcd6af0944 100644 --- a/shared/source/release_helper/release_helper_1271.cpp +++ b/shared/source/release_helper/release_helper_1271.cpp @@ -7,6 +7,7 @@ #include "shared/source/release_helper/release_helper.h" #include "shared/source/release_helper/release_helper_base.inl" +#include "shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h" #include "platforms.h" #include "release_definitions.h" @@ -18,6 +19,15 @@ template <> bool ReleaseHelperHw::isPipeControlPriorToNonPipelinedStateCommandsWARequired() const { return hardwareIpVersion.value == AOT::MTL_P_A0; } +template <> +int ReleaseHelperHw::getProductMaxPreferredSlmSize(int preferredEnumValue) const { + using PREFERRED_SLM_ALLOCATION_SIZE = typename XeHpgCoreFamily::INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE; + + if (hardwareIpVersion.value == AOT::MTL_P_A0) { + return static_cast(PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_96K); + } + return preferredEnumValue; +} } // namespace NEO diff --git a/shared/source/release_helper/release_helper_base.inl b/shared/source/release_helper/release_helper_base.inl index 51b2019d15..de8c741d7e 100644 --- a/shared/source/release_helper/release_helper_base.inl +++ b/shared/source/release_helper/release_helper_base.inl @@ -27,5 +27,9 @@ template bool ReleaseHelperHw::isPrefetchDisablingRequired() const { return false; } +template +int ReleaseHelperHw::getProductMaxPreferredSlmSize(int preferredEnumValue) const { + return preferredEnumValue; +} } // namespace NEO diff --git a/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp b/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp index d1381272e7..b4a924dc0e 100644 --- a/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp @@ -12,6 +12,7 @@ #include "shared/source/command_stream/stream_properties.h" #include "shared/source/helpers/cache_flush_xehp_and_later.inl" #include "shared/source/os_interface/product_helper.h" +#include "shared/source/release_helper/release_helper.h" #include "shared/source/utilities/lookup_array.h" #include "shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h" @@ -66,14 +67,18 @@ void EncodeDispatchKernel::appendAdditionalIDDFields(INTERFACE_DESCRIPTO }}; auto programmableIdPreferredSlmSize = PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_128K; - auto &productHelper = rootDeviceEnvironment.getHelper(); - programmableIdPreferredSlmSize = static_cast(productHelper.getProductMaxPreferredSlmSize(hwInfo, programmableIdPreferredSlmSize)); + auto *releaseHelper = rootDeviceEnvironment.getReleaseHelper(); + programmableIdPreferredSlmSize = static_cast( + releaseHelper->getProductMaxPreferredSlmSize(programmableIdPreferredSlmSize)); + for (auto &range : ranges) { if (slmSize <= range.upperLimit) { programmableIdPreferredSlmSize = range.valueToProgram; break; } } + auto &productHelper = rootDeviceEnvironment.getHelper(); + if (productHelper.isAllocationSizeAdjustmentRequired(hwInfo)) { pInterfaceDescriptor->setPreferredSlmAllocationSize(PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_128K); } else { diff --git a/shared/source/xe_hpg_core/mtl/os_agnostic_product_helper_mtl.inl b/shared/source/xe_hpg_core/mtl/os_agnostic_product_helper_mtl.inl index 0af8359eb9..ef724b5ad3 100644 --- a/shared/source/xe_hpg_core/mtl/os_agnostic_product_helper_mtl.inl +++ b/shared/source/xe_hpg_core/mtl/os_agnostic_product_helper_mtl.inl @@ -92,16 +92,6 @@ uint64_t ProductHelperHw::overridePatIndex(AllocationType allocation return patIndex; } -template <> -int ProductHelperHw::getProductMaxPreferredSlmSize(const HardwareInfo &hwInfo, int preferredEnumValue) const { - using PREFERRED_SLM_ALLOCATION_SIZE = typename XeHpgCoreFamily::INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE; - if (getProductConfigFromHwInfo(hwInfo) == AOT::MTL_M_A0 || getProductConfigFromHwInfo(hwInfo) == AOT::MTL_P_A0) { - return static_cast(PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_96K); - } else { - return preferredEnumValue; - } -} - template <> bool ProductHelperHw::isDummyBlitWaRequired() const { return true; diff --git a/shared/test/unit_test/xe_hpg_core/mtl/product_helper_tests_mtl.cpp b/shared/test/unit_test/xe_hpg_core/mtl/product_helper_tests_mtl.cpp index 76e2f3e1ea..e4512868b8 100644 --- a/shared/test/unit_test/xe_hpg_core/mtl/product_helper_tests_mtl.cpp +++ b/shared/test/unit_test/xe_hpg_core/mtl/product_helper_tests_mtl.cpp @@ -11,6 +11,7 @@ #include "shared/source/helpers/compiler_product_helper.h" #include "shared/source/memory_manager/allocation_type.h" #include "shared/source/os_interface/product_helper.h" +#include "shared/source/release_helper/release_helper.h" #include "shared/source/xe_hpg_core/hw_cmds_mtl.h" #include "shared/test/common/fixtures/device_fixture.h" #include "shared/test/common/helpers/default_hw_info.h" @@ -212,7 +213,7 @@ MTLTEST_F(MtlProductHelper, givenMtlLpgWhenIsBFloat16ConversionSupportedIsCalled EXPECT_FALSE(compilerProductHelper.isBFloat16ConversionSupported(hwInfo)); } -MTLTEST_F(MtlProductHelper, givenMtlMA0WhengetProductMaxPreferredSlmSizeThen96KbValueReturned) { +MTLTEST_F(MtlProductHelper, givenMtlMA0WhenGetProductMaxPreferredSlmSizeThen96KbValueReturned) { using PREFERRED_SLM_ALLOCATION_SIZE = typename XeHpgCoreFamily::INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE; PREFERRED_SLM_ALLOCATION_SIZE preferredEnumValue = PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_0K; auto hwInfo = *defaultHwInfo.get(); @@ -220,11 +221,12 @@ MTLTEST_F(MtlProductHelper, givenMtlMA0WhengetProductMaxPreferredSlmSizeThen96Kb aotConfig.value = AOT::MTL_M_A0; auto &compilerProductHelper = this->executionEnvironment->rootDeviceEnvironments[0]->getHelper(); compilerProductHelper.setProductConfigForHwInfo(hwInfo, aotConfig); - preferredEnumValue = static_cast(productHelper->getProductMaxPreferredSlmSize(hwInfo, preferredEnumValue)); + refreshReleaseHelper(&hwInfo); + preferredEnumValue = static_cast(releaseHelper->getProductMaxPreferredSlmSize(preferredEnumValue)); EXPECT_EQ(preferredEnumValue, PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_96K); } -MTLTEST_F(MtlProductHelper, givenMtlPA0WhengetProductMaxPreferredSlmSizeThen96KbValueReturned) { +MTLTEST_F(MtlProductHelper, givenMtlPA0WhenGetProductMaxPreferredSlmSizeThen96KbValueReturned) { using PREFERRED_SLM_ALLOCATION_SIZE = typename XeHpgCoreFamily::INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE; PREFERRED_SLM_ALLOCATION_SIZE preferredEnumValue = PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_0K; auto hwInfo = *defaultHwInfo.get(); @@ -232,10 +234,11 @@ MTLTEST_F(MtlProductHelper, givenMtlPA0WhengetProductMaxPreferredSlmSizeThen96Kb aotConfig.value = AOT::MTL_P_A0; auto &compilerProductHelper = this->executionEnvironment->rootDeviceEnvironments[0]->getHelper(); compilerProductHelper.setProductConfigForHwInfo(hwInfo, aotConfig); - preferredEnumValue = static_cast(productHelper->getProductMaxPreferredSlmSize(hwInfo, preferredEnumValue)); + refreshReleaseHelper(&hwInfo); + preferredEnumValue = static_cast(releaseHelper->getProductMaxPreferredSlmSize(preferredEnumValue)); EXPECT_EQ(preferredEnumValue, PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_96K); } -MTLTEST_F(MtlProductHelper, givenMtlMB0WhengetProductMaxPreferredSlmSizeThenPassedValueReturned) { +MTLTEST_F(MtlProductHelper, givenMtlMB0WhenGetProductMaxPreferredSlmSizeThenPassedValueReturned) { using PREFERRED_SLM_ALLOCATION_SIZE = typename XeHpgCoreFamily::INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE; PREFERRED_SLM_ALLOCATION_SIZE preferredEnumValue = PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_0K; auto hwInfo = *defaultHwInfo.get(); @@ -243,11 +246,12 @@ MTLTEST_F(MtlProductHelper, givenMtlMB0WhengetProductMaxPreferredSlmSizeThenPass aotConfig.value = AOT::MTL_M_B0; auto &compilerProductHelper = this->executionEnvironment->rootDeviceEnvironments[0]->getHelper(); compilerProductHelper.setProductConfigForHwInfo(hwInfo, aotConfig); - preferredEnumValue = static_cast(productHelper->getProductMaxPreferredSlmSize(hwInfo, preferredEnumValue)); + refreshReleaseHelper(&hwInfo); + preferredEnumValue = static_cast(releaseHelper->getProductMaxPreferredSlmSize(preferredEnumValue)); EXPECT_EQ(preferredEnumValue, PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_0K); } -MTLTEST_F(MtlProductHelper, givenMtlPB0WhengetProductMaxPreferredSlmSizeThenPassedValueReturned) { +MTLTEST_F(MtlProductHelper, givenMtlPB0WhenGetProductMaxPreferredSlmSizeThenPassedValueReturned) { using PREFERRED_SLM_ALLOCATION_SIZE = typename XeHpgCoreFamily::INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE; PREFERRED_SLM_ALLOCATION_SIZE preferredEnumValue = PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_0K; auto hwInfo = *defaultHwInfo.get(); @@ -255,7 +259,8 @@ MTLTEST_F(MtlProductHelper, givenMtlPB0WhengetProductMaxPreferredSlmSizeThenPass aotConfig.value = AOT::MTL_P_B0; auto &compilerProductHelper = this->executionEnvironment->rootDeviceEnvironments[0]->getHelper(); compilerProductHelper.setProductConfigForHwInfo(hwInfo, aotConfig); - preferredEnumValue = static_cast(productHelper->getProductMaxPreferredSlmSize(hwInfo, preferredEnumValue)); + refreshReleaseHelper(&hwInfo); + preferredEnumValue = static_cast(releaseHelper->getProductMaxPreferredSlmSize(preferredEnumValue)); EXPECT_EQ(preferredEnumValue, PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_0K); }