2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2025-01-14 16:36:45 +00:00
|
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2023-02-01 16:23:01 +00:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2025-11-03 13:14:00 +00:00
|
|
|
#include "shared/source/helpers/basic_math.h"
|
2022-12-20 02:00:16 +00:00
|
|
|
#include "shared/source/helpers/constants.h"
|
2022-05-25 14:39:35 +00:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2023-03-10 12:28:11 +00:00
|
|
|
#include "shared/source/os_interface/product_helper.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-10-22 16:13:05 +02:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2023-01-09 14:59:10 +00:00
|
|
|
GfxCoreHelperCreateFunctionType gfxCoreHelperFactory[IGFX_MAX_CORE] = {};
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<GfxCoreHelper> GfxCoreHelper::create(const GFXCORE_FAMILY gfxCoreFamily) {
|
|
|
|
|
|
|
|
|
|
auto createFunction = gfxCoreHelperFactory[gfxCoreFamily];
|
2023-02-02 09:50:31 +00:00
|
|
|
if (createFunction == nullptr) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2023-01-09 14:59:10 +00:00
|
|
|
auto gfxCoreHelper = createFunction();
|
|
|
|
|
return gfxCoreHelper;
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2018-12-14 16:00:43 +01:00
|
|
|
|
2022-12-08 12:22:35 +00:00
|
|
|
bool GfxCoreHelper::compressedBuffersSupported(const HardwareInfo &hwInfo) {
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.RenderCompressedBuffersEnabled.get() != -1) {
|
|
|
|
|
return !!debugManager.flags.RenderCompressedBuffersEnabled.get();
|
2018-12-14 16:00:43 +01:00
|
|
|
}
|
|
|
|
|
return hwInfo.capabilityTable.ftrRenderCompressedBuffers;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-08 12:22:35 +00:00
|
|
|
bool GfxCoreHelper::compressedImagesSupported(const HardwareInfo &hwInfo) {
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.RenderCompressedImagesEnabled.get() != -1) {
|
|
|
|
|
return !!debugManager.flags.RenderCompressedImagesEnabled.get();
|
2018-12-14 16:00:43 +01:00
|
|
|
}
|
|
|
|
|
return hwInfo.capabilityTable.ftrRenderCompressedImages;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-08 12:22:35 +00:00
|
|
|
bool GfxCoreHelper::cacheFlushAfterWalkerSupported(const HardwareInfo &hwInfo) {
|
2023-11-30 08:32:25 +00:00
|
|
|
int32_t dbgFlag = debugManager.flags.EnableCacheFlushAfterWalker.get();
|
2019-02-05 15:11:38 +01:00
|
|
|
if (dbgFlag == 1) {
|
|
|
|
|
return true;
|
|
|
|
|
} else if (dbgFlag == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return hwInfo.capabilityTable.supportCacheFlushAfterWalker;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-08 12:22:35 +00:00
|
|
|
uint32_t GfxCoreHelper::getMaxThreadsForVfe(const HardwareInfo &hwInfo) {
|
2025-08-20 17:36:09 +00:00
|
|
|
uint32_t threadsPerEU = hwInfo.gtSystemInfo.NumThreadsPerEu + hwInfo.capabilityTable.extraQuantityThreadsPerEU;
|
2020-04-29 15:37:30 +02:00
|
|
|
auto maxHwThreadsCapable = hwInfo.gtSystemInfo.EUCount * threadsPerEU;
|
|
|
|
|
auto maxHwThreadsReturned = maxHwThreadsCapable;
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.MaxHwThreadsPercent.get() != 0) {
|
|
|
|
|
maxHwThreadsReturned = int(maxHwThreadsCapable * (debugManager.flags.MaxHwThreadsPercent.get() / 100.0f));
|
2020-04-29 15:37:30 +02:00
|
|
|
}
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.MinHwThreadsUnoccupied.get() != 0) {
|
|
|
|
|
maxHwThreadsReturned = std::min(maxHwThreadsReturned, maxHwThreadsCapable - debugManager.flags.MinHwThreadsUnoccupied.get());
|
2020-04-29 15:37:30 +02:00
|
|
|
}
|
|
|
|
|
return maxHwThreadsReturned;
|
2019-05-16 17:17:53 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-26 15:04:39 +02:00
|
|
|
uint32_t GfxCoreHelper::getSubDevicesCount(const HardwareInfo *pHwInfo) {
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.CreateMultipleSubDevices.get() > 0) {
|
|
|
|
|
return debugManager.flags.CreateMultipleSubDevices.get();
|
2021-06-28 13:44:09 +00:00
|
|
|
} else if (pHwInfo->gtSystemInfo.MultiTileArchInfo.IsValid && pHwInfo->gtSystemInfo.MultiTileArchInfo.TileCount > 0u) {
|
|
|
|
|
return pHwInfo->gtSystemInfo.MultiTileArchInfo.TileCount;
|
|
|
|
|
} else {
|
|
|
|
|
return 1u;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-08 12:22:35 +00:00
|
|
|
uint32_t GfxCoreHelper::getHighestEnabledSlice(const HardwareInfo &hwInfo) {
|
2023-10-04 12:28:15 +00:00
|
|
|
uint32_t highestEnabledSlice = 1;
|
2022-09-23 00:29:32 +00:00
|
|
|
if (!hwInfo.gtSystemInfo.IsDynamicallyPopulated) {
|
|
|
|
|
return hwInfo.gtSystemInfo.MaxSlicesSupported;
|
|
|
|
|
}
|
|
|
|
|
for (int highestSlice = GT_MAX_SLICE - 1; highestSlice >= 0; highestSlice--) {
|
|
|
|
|
if (hwInfo.gtSystemInfo.SliceInfo[highestSlice].Enabled) {
|
|
|
|
|
highestEnabledSlice = highestSlice + 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return highestEnabledSlice;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-09 14:35:31 +00:00
|
|
|
uint32_t GfxCoreHelper::getHighestEnabledSubSliceOnAnySlice(const HardwareInfo &hwInfo) {
|
|
|
|
|
|
|
|
|
|
if (!hwInfo.gtSystemInfo.IsDynamicallyPopulated) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t highestSubSlice = 0;
|
|
|
|
|
for (uint32_t sliceId = 0; sliceId < GT_MAX_SLICE; sliceId++) {
|
|
|
|
|
for (uint32_t subSliceId = 0; subSliceId < GT_MAX_SUBSLICE_PER_SLICE; subSliceId++) {
|
|
|
|
|
if (hwInfo.gtSystemInfo.SliceInfo[sliceId].SubSliceInfo[subSliceId].Enabled) {
|
|
|
|
|
highestSubSlice = std::max(highestSubSlice, subSliceId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return highestSubSlice;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-02 11:53:36 +02:00
|
|
|
uint32_t getHighestEnabledSubSlice(const HardwareInfo &hwInfo) {
|
2024-07-31 09:08:46 +00:00
|
|
|
uint32_t numSubSlicesPerSlice = hwInfo.gtSystemInfo.MaxSubSlicesSupported / hwInfo.gtSystemInfo.MaxSlicesSupported;
|
2024-01-18 17:19:39 +00:00
|
|
|
uint32_t highestEnabledSliceIdx = GfxCoreHelper::getHighestEnabledSlice(hwInfo) - 1;
|
2024-07-31 09:08:46 +00:00
|
|
|
uint32_t highestSubSlice = (highestEnabledSliceIdx + 1) * numSubSlicesPerSlice;
|
2024-01-18 17:19:39 +00:00
|
|
|
|
|
|
|
|
for (int32_t subSliceId = GT_MAX_SUBSLICE_PER_SLICE - 1; subSliceId >= 0; subSliceId--) {
|
|
|
|
|
if (hwInfo.gtSystemInfo.SliceInfo[highestEnabledSliceIdx].SubSliceInfo[subSliceId].Enabled) {
|
|
|
|
|
return highestEnabledSliceIdx * numSubSlicesPerSlice + subSliceId + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return highestSubSlice;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-10 01:20:44 +00:00
|
|
|
uint32_t GfxCoreHelper::getHighestEnabledDualSubSlice(const HardwareInfo &hwInfo) {
|
2024-07-31 10:09:15 +00:00
|
|
|
uint32_t maxDualSubSlicesSupported = hwInfo.gtSystemInfo.MaxDualSubSlicesSupported;
|
2023-03-10 01:20:44 +00:00
|
|
|
if (!hwInfo.gtSystemInfo.IsDynamicallyPopulated) {
|
2024-07-31 10:09:15 +00:00
|
|
|
return maxDualSubSlicesSupported;
|
2023-03-10 01:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
2024-07-31 10:09:15 +00:00
|
|
|
if (maxDualSubSlicesSupported == 0) {
|
2024-01-18 17:19:39 +00:00
|
|
|
return getHighestEnabledSubSlice(hwInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-31 10:09:15 +00:00
|
|
|
uint32_t numDssPerSlice = maxDualSubSlicesSupported / hwInfo.gtSystemInfo.MaxSlicesSupported;
|
2023-03-10 01:20:44 +00:00
|
|
|
uint32_t highestEnabledSliceIdx = getHighestEnabledSlice(hwInfo) - 1;
|
2024-07-31 10:09:15 +00:00
|
|
|
uint32_t highestDualSubSlice = (highestEnabledSliceIdx + 1) * numDssPerSlice;
|
2023-03-10 01:20:44 +00:00
|
|
|
|
2024-07-31 10:09:15 +00:00
|
|
|
for (int32_t dssID = GT_MAX_DUALSUBSLICE_PER_SLICE - 1; dssID >= 0; dssID--) {
|
2023-03-10 01:20:44 +00:00
|
|
|
if (hwInfo.gtSystemInfo.SliceInfo[highestEnabledSliceIdx].DSSInfo[dssID].Enabled) {
|
2024-07-31 10:09:15 +00:00
|
|
|
return (highestEnabledSliceIdx * numDssPerSlice) + dssID + 1;
|
2023-03-10 01:20:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return highestDualSubSlice;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-20 02:00:16 +00:00
|
|
|
bool GfxCoreHelper::isWorkaroundRequired(uint32_t lowestSteppingWithBug, uint32_t steppingWithFix, const HardwareInfo &hwInfo, const ProductHelper &productHelper) {
|
|
|
|
|
auto lowestHwRevIdWithBug = productHelper.getHwRevIdFromStepping(lowestSteppingWithBug, hwInfo);
|
|
|
|
|
auto hwRevIdWithFix = productHelper.getHwRevIdFromStepping(steppingWithFix, hwInfo);
|
|
|
|
|
if ((lowestHwRevIdWithBug == CommonConstants::invalidStepping) || (hwRevIdWithFix == CommonConstants::invalidStepping)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return (lowestHwRevIdWithBug <= hwInfo.platform.usRevId && hwInfo.platform.usRevId < hwRevIdWithFix);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-03 13:14:00 +00:00
|
|
|
int32_t GfxCoreHelper::getHighestQueuePriorityLevel() const {
|
|
|
|
|
return -(static_cast<int32_t>(Math::divideAndRoundUp(getQueuePriorityLevels(), 2))) + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t GfxCoreHelper::getLowestQueuePriorityLevel() const {
|
|
|
|
|
return getQueuePriorityLevels() / 2;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|