diff --git a/shared/source/xe_hpg_core/enable_compiler_product_helper_mtl.cpp b/shared/source/xe_hpg_core/enable_compiler_product_helper_mtl.cpp index ab9ae70657..c4a49ab58d 100644 --- a/shared/source/xe_hpg_core/enable_compiler_product_helper_mtl.cpp +++ b/shared/source/xe_hpg_core/enable_compiler_product_helper_mtl.cpp @@ -11,4 +11,49 @@ constexpr auto gfxProduct = IGFX_METEORLAKE; #include "shared/source/xe_hpg_core/xe_lpg/compiler_product_helper_xe_lpg.inl" +namespace NEO { +template <> +uint32_t CompilerProductHelperHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + if (hwInfo.ipVersion.value) { + return hwInfo.ipVersion.value; + } + switch (hwInfo.platform.usDeviceID) { + case 0x7D40: + case 0x7D45: { + switch (hwInfo.platform.usRevId) { + case 0x0: + case 0x2: + return AOT::MTL_M_A0; + case 0x3: + case 0x8: + return AOT::MTL_M_B0; + } + break; + } + case 0x7D55: + case 0X7DD5: { + switch (hwInfo.platform.usRevId) { + case 0x0: + case 0x2: + return AOT::MTL_P_A0; + case 0x3: + case 0x8: + return AOT::MTL_P_B0; + } + break; + } + case 0x7D60: { + switch (hwInfo.platform.usRevId) { + case 0x0: + return AOT::MTL_M_A0; + case 0x2: + return AOT::MTL_M_B0; + } + break; + } + } + return getDefaultHwIpVersion(); +} +} // namespace NEO + static NEO::EnableCompilerProductHelper enableCompilerProductHelperMTL; 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 512848a434..f870d0fec5 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 @@ -5,14 +5,18 @@ * */ +#include "shared/source/helpers/compiler_product_helper.h" #include "shared/source/memory_manager/allocation_properties.h" #include "shared/source/memory_manager/allocation_type.h" #include "shared/source/os_interface/product_helper.h" #include "shared/source/xe_hpg_core/hw_cmds_mtl.h" +#include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/test_macros/header/per_product_test_definitions.h" #include "shared/test/common/test_macros/test.h" #include "shared/test/unit_test/os_interface/product_helper_tests.h" +#include "platforms.h" + using namespace NEO; using MtlProductHelper = ProductHelperTest; @@ -21,6 +25,66 @@ MTLTEST_F(MtlProductHelper, givenProductHelperWhenCheckDirectSubmissionSupported EXPECT_TRUE(productHelper->isDirectSubmissionSupported(releaseHelper)); } +MTLTEST_F(MtlProductHelper, givenMtlWithoutHwIpVersionInHwInfoWhenGettingIpVersionThenCorrectValueIsReturnedBasedOnDeviceIdAndRevId) { + auto hwInfo = *defaultHwInfo; + hwInfo.ipVersion = {}; + + auto mtlMDeviceIds = {0x7D40, 0x7D45}; + auto mtlPDeviceIds = {0x7D55, 0X7DD5}; + + hwInfo.platform.usDeviceID = 0x7D60; + hwInfo.platform.usRevId = 0; + + EXPECT_EQ(AOT::MTL_M_A0, compilerProductHelper->getHwIpVersion(hwInfo)); + + hwInfo.platform.usRevId = 2; + + EXPECT_EQ(AOT::MTL_M_B0, compilerProductHelper->getHwIpVersion(hwInfo)); + + hwInfo.platform.usRevId = 0xdead; + + EXPECT_EQ(compilerProductHelper->getDefaultHwIpVersion(), compilerProductHelper->getHwIpVersion(hwInfo)); + + for (auto &deviceId : mtlMDeviceIds) { + hwInfo.platform.usDeviceID = deviceId; + for (auto &revision : {0, 2}) { + hwInfo.platform.usRevId = revision; + + EXPECT_EQ(AOT::MTL_M_A0, compilerProductHelper->getHwIpVersion(hwInfo)); + } + for (auto &revision : {3, 8}) { + hwInfo.platform.usRevId = revision; + + EXPECT_EQ(AOT::MTL_M_B0, compilerProductHelper->getHwIpVersion(hwInfo)); + } + hwInfo.platform.usRevId = 0xdead; + + EXPECT_EQ(compilerProductHelper->getDefaultHwIpVersion(), compilerProductHelper->getHwIpVersion(hwInfo)); + } + + for (auto &deviceId : mtlPDeviceIds) { + hwInfo.platform.usDeviceID = deviceId; + for (auto &revision : {0, 2}) { + hwInfo.platform.usRevId = revision; + + EXPECT_EQ(AOT::MTL_P_A0, compilerProductHelper->getHwIpVersion(hwInfo)); + } + for (auto &revision : {3, 8}) { + hwInfo.platform.usRevId = revision; + + EXPECT_EQ(AOT::MTL_P_B0, compilerProductHelper->getHwIpVersion(hwInfo)); + } + hwInfo.platform.usRevId = 0xdead; + + EXPECT_EQ(compilerProductHelper->getDefaultHwIpVersion(), compilerProductHelper->getHwIpVersion(hwInfo)); + } + + hwInfo.platform.usDeviceID = 0; + hwInfo.platform.usRevId = 0xdead; + + EXPECT_EQ(compilerProductHelper->getDefaultHwIpVersion(), compilerProductHelper->getHwIpVersion(hwInfo)); +} + MTLTEST_F(MtlProductHelper, givenProductHelperWhenCheckOverrideAllocationCacheableThenTrueIsReturnedForCommandBuffer) { AllocationData allocationData{}; allocationData.type = AllocationType::COMMAND_BUFFER; @@ -28,4 +92,4 @@ MTLTEST_F(MtlProductHelper, givenProductHelperWhenCheckOverrideAllocationCacheab allocationData.type = AllocationType::BUFFER; EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData)); -} \ No newline at end of file +}