diff --git a/shared/source/helpers/gfx_core_helper_xehp_and_later.inl b/shared/source/helpers/gfx_core_helper_xehp_and_later.inl index e206a9ac81..04349e633f 100644 --- a/shared/source/helpers/gfx_core_helper_xehp_and_later.inl +++ b/shared/source/helpers/gfx_core_helper_xehp_and_later.inl @@ -26,8 +26,9 @@ uint32_t GfxCoreHelperHw::getComputeUnitsUsedForScratch(const RootDev return static_cast(debugManager.flags.OverrideNumComputeUnitsForScratch.get()); } + auto &productHelper = rootDeviceEnvironment.getHelper(); auto hwInfo = rootDeviceEnvironment.getHardwareInfo(); - auto maxSubSlice = GfxCoreHelper::getHighestEnabledDualSubSlice(*hwInfo); + auto maxSubSlice = productHelper.computeMaxNeededSubSliceSpace(*hwInfo); // XeHP and later products return physical threads return maxSubSlice * hwInfo->gtSystemInfo.MaxEuPerSubSlice * (hwInfo->gtSystemInfo.ThreadCount / hwInfo->gtSystemInfo.EUCount); } diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index dba5f4520c..4bc3b65ee2 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -134,6 +134,7 @@ class ProductHelper { virtual bool isDcFlushMitigated() const = 0; virtual bool overridePatAndUsageForDcFlushMitigation(AllocationType allocationType) const = 0; virtual bool overrideCacheableForDcFlushMitigation(AllocationType allocationType) const = 0; + virtual uint32_t computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const = 0; virtual bool getUuid(NEO::DriverModel *driverModel, const uint32_t subDeviceCount, const uint32_t deviceIndex, std::array &uuid) const = 0; virtual bool isFlushTaskAllowed() const = 0; virtual bool isSystolicModeConfigurable(const HardwareInfo &hwInfo) const = 0; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index 80579b7a82..0aa96e6586 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -433,6 +433,11 @@ bool ProductHelperHw::overrideCacheableForDcFlushMitigation(Allocati allocationType == AllocationType::printfSurface); } +template +uint32_t ProductHelperHw::computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const { + return hwInfo.gtSystemInfo.MaxSubSlicesSupported; +} + template bool ProductHelperHw::getUuid(NEO::DriverModel *driverModel, const uint32_t subDeviceCount, const uint32_t deviceIndex, std::array &uuid) const { return false; diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index 36840527c2..64b1e2d410 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -78,6 +78,7 @@ class ProductHelperHw : public ProductHelper { bool isDcFlushMitigated() const override; bool overridePatAndUsageForDcFlushMitigation(AllocationType allocationType) const override; bool overrideCacheableForDcFlushMitigation(AllocationType allocationType) const override; + uint32_t computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const override; bool getUuid(NEO::DriverModel *driverModel, uint32_t subDeviceCount, uint32_t deviceIndex, std::array &uuid) const override; bool isFlushTaskAllowed() const override; bool isSystolicModeConfigurable(const HardwareInfo &hwInfo) const override; diff --git a/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl b/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl index 0f43137bf6..8e7480163d 100644 --- a/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl +++ b/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl @@ -162,6 +162,18 @@ bool ProductHelperHw::isTile64With3DSurfaceOnBCSSupported(const Hard return true; } +template <> +uint32_t ProductHelperHw::computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const { + const uint32_t highestEnabledSlice = NEO::GfxCoreHelper::getHighestEnabledSlice(hwInfo); + + UNRECOVERABLE_IF(highestEnabledSlice == 0); + UNRECOVERABLE_IF(hwInfo.gtSystemInfo.MaxSlicesSupported == 0); + auto subSlicesPerSlice = hwInfo.gtSystemInfo.MaxSubSlicesSupported / hwInfo.gtSystemInfo.MaxSlicesSupported; + auto maxSubSlice = std::max(highestEnabledSlice * subSlicesPerSlice, hwInfo.gtSystemInfo.MaxSubSlicesSupported); + + return maxSubSlice; +} + template <> bool ProductHelperHw::isCpuCopyNecessary(const void *ptr, MemoryManager *memoryManager) const { if (memoryManager) { diff --git a/shared/test/common/mocks/mock_product_helper.cpp b/shared/test/common/mocks/mock_product_helper.cpp index 4049c374ba..869e2216cc 100644 --- a/shared/test/common/mocks/mock_product_helper.cpp +++ b/shared/test/common/mocks/mock_product_helper.cpp @@ -291,6 +291,11 @@ bool ProductHelperHw::overrideCacheableForDcFlushMitigation(Alloca return false; } +template <> +uint32_t ProductHelperHw::computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const { + return hwInfo.gtSystemInfo.MaxSubSlicesSupported; +} + template <> bool ProductHelperHw::getUuid(NEO::DriverModel *driverModel, const uint32_t subDeviceCount, const uint32_t deviceIndex, std::array &uuid) const { return false; diff --git a/shared/test/unit_test/device/neo_device_tests.cpp b/shared/test/unit_test/device/neo_device_tests.cpp index c9a9ab5c10..e5b89c68f4 100644 --- a/shared/test/unit_test/device/neo_device_tests.cpp +++ b/shared/test/unit_test/device/neo_device_tests.cpp @@ -1106,7 +1106,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTest, givenHwInfoWhenRequestedComputeUnitsUse const uint32_t multiplyFactor = productHelper.getThreadEuRatioForScratch(hwInfo) / 8u; const uint32_t numThreadsPerEu = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount) * multiplyFactor; - uint32_t expectedValue = GfxCoreHelper::getHighestEnabledDualSubSlice(hwInfo) * hwInfo.gtSystemInfo.MaxEuPerSubSlice * numThreadsPerEu; + uint32_t expectedValue = productHelper.computeMaxNeededSubSliceSpace(hwInfo) * hwInfo.gtSystemInfo.MaxEuPerSubSlice * numThreadsPerEu; EXPECT_EQ(expectedValue, gfxCoreHelper.getComputeUnitsUsedForScratch(pDevice->getRootDeviceEnvironment())); EXPECT_EQ(expectedValue, pDevice->getDeviceInfo().computeUnitsUsedForScratch); diff --git a/shared/test/unit_test/os_interface/product_helper_tests.cpp b/shared/test/unit_test/os_interface/product_helper_tests.cpp index 2247148a50..c19f2ee494 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -992,6 +992,26 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenItsXe2PlusThenCacheLineSizeIs EXPECT_EQ(productHelper->getCacheLineSize(), 256u); } +TEST_F(ProductHelperTest, whenGettingMaxSubSliceSpaceThenValueIsNotSmallerThanMaxSubSliceCount) { + constexpr auto maxSupportedSubSlices = 128u; + auto hwInfo = *defaultHwInfo; + auto >SystemInfo = hwInfo.gtSystemInfo; + gtSystemInfo.SliceCount = 1; + gtSystemInfo.SubSliceCount = 2; + gtSystemInfo.DualSubSliceCount = 2; + + gtSystemInfo.MaxSlicesSupported = 2; + gtSystemInfo.MaxSlicesSupported = 2; + gtSystemInfo.MaxSubSlicesSupported = maxSupportedSubSlices; + gtSystemInfo.MaxDualSubSlicesSupported = maxSupportedSubSlices; + + gtSystemInfo.IsDynamicallyPopulated = true; + for (uint32_t slice = 0; slice < GT_MAX_SLICE; slice++) { + gtSystemInfo.SliceInfo[slice].Enabled = slice < gtSystemInfo.SliceCount; + } + EXPECT_EQ(maxSupportedSubSlices, productHelper->computeMaxNeededSubSliceSpace(hwInfo)); +} + HWTEST_F(ProductHelperTest, givenDefaultProductHelperWhenQuery2DBlockLoadThenReturnFalse) { EXPECT_FALSE(productHelper->supports2DBlockLoad()); diff --git a/shared/test/unit_test/xe_hpg_core/dg2/product_config_helper_tests_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/product_config_helper_tests_dg2.cpp index 08a668ec2d..7dc36e0eca 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/product_config_helper_tests_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/product_config_helper_tests_dg2.cpp @@ -695,6 +695,17 @@ DG2TEST_F(ProductHelperTestDg2, givenEnabledSliceInNonStandardConfigWhenComputeU EXPECT_EQ(expectedCalculation, gfxCoreHelper.getComputeUnitsUsedForScratch(*executionEnvironment->rootDeviceEnvironments[0])); } +DG2TEST_F(ProductHelperTestDg2, givenNotEnabledSliceWhenComputeUnitsUsedForScratchThenThrowUnrecoverableIf) { + HardwareInfo &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); + GT_SYSTEM_INFO &testSysInfo = hwInfo.gtSystemInfo; + testSysInfo.IsDynamicallyPopulated = false; + testSysInfo.MaxSlicesSupported = 0; + + auto &gfxCoreHelper = executionEnvironment->rootDeviceEnvironments[0]->getHelper(); + + EXPECT_THROW(gfxCoreHelper.getComputeUnitsUsedForScratch(*executionEnvironment->rootDeviceEnvironments[0]), std::exception); +} + DG2TEST_F(ProductHelperTestDg2, givenDG2WhenCheckingIsTimestampWaitSupportedForEventsThenReturnTrue) { EXPECT_TRUE(productHelper->isTimestampWaitSupportedForEvents());