2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-05-17 02:51:16 +08:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2021-01-13 16:30:01 +08:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2020-07-30 21:02:11 +08:00
|
|
|
|
|
|
|
#include "hw_cmds.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-07-18 17:58:30 +08:00
|
|
|
#include <algorithm>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2019-05-08 22:00:24 +08:00
|
|
|
HardwareInfo::HardwareInfo(const PLATFORM *platform, const FeatureTable *featureTable, const WorkaroundTable *workaroundTable,
|
|
|
|
const GT_SYSTEM_INFO *gtSystemInfo, const RuntimeCapabilityTable &capabilityTable)
|
|
|
|
: platform(*platform), featureTable(*featureTable), workaroundTable(*workaroundTable), gtSystemInfo(*gtSystemInfo), capabilityTable(capabilityTable) {
|
2018-06-12 15:42:47 +08:00
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-08-26 21:36:24 +08:00
|
|
|
// Global table of hardware prefixes
|
|
|
|
const char *hardwarePrefix[IGFX_MAX_PRODUCT] = {
|
|
|
|
nullptr,
|
|
|
|
};
|
2019-10-18 16:15:09 +08:00
|
|
|
|
|
|
|
// Global table of default hardware info configs
|
2020-01-25 00:19:06 +08:00
|
|
|
uint64_t defaultHardwareInfoConfigTable[IGFX_MAX_PRODUCT] = {
|
|
|
|
0x0,
|
2019-10-18 16:15:09 +08:00
|
|
|
};
|
|
|
|
|
2019-08-26 21:36:24 +08:00
|
|
|
// Global table of family names
|
|
|
|
const char *familyName[IGFX_MAX_CORE] = {
|
|
|
|
nullptr,
|
|
|
|
};
|
|
|
|
// Global table of family names
|
|
|
|
bool familyEnabled[IGFX_MAX_CORE] = {
|
|
|
|
false,
|
|
|
|
};
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
const HardwareInfo *hardwareInfoTable[IGFX_MAX_PRODUCT] = {};
|
2020-01-25 00:19:06 +08:00
|
|
|
void (*hardwareInfoSetup[IGFX_MAX_PRODUCT])(HardwareInfo *, bool, uint64_t) = {
|
|
|
|
0x0,
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
2019-07-18 17:58:30 +08:00
|
|
|
bool getHwInfoForPlatformString(std::string &platform, const HardwareInfo *&hwInfoIn) {
|
|
|
|
std::transform(platform.begin(), platform.end(), platform.begin(), ::tolower);
|
|
|
|
|
2021-01-13 16:30:01 +08:00
|
|
|
overridePlatformName(platform);
|
|
|
|
|
2018-06-07 22:18:53 +08:00
|
|
|
bool ret = false;
|
|
|
|
for (int j = 0; j < IGFX_MAX_PRODUCT; j++) {
|
|
|
|
if (hardwarePrefix[j] == nullptr)
|
|
|
|
continue;
|
2019-07-18 17:58:30 +08:00
|
|
|
if (hardwarePrefix[j] == platform) {
|
2018-06-07 22:18:53 +08:00
|
|
|
hwInfoIn = hardwareInfoTable[j];
|
|
|
|
ret = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-01-13 16:30:01 +08:00
|
|
|
|
2018-06-07 22:18:53 +08:00
|
|
|
return ret;
|
|
|
|
}
|
2018-10-02 04:36:15 +08:00
|
|
|
|
2020-01-25 00:19:06 +08:00
|
|
|
void setHwInfoValuesFromConfig(const uint64_t hwInfoConfig, HardwareInfo &hwInfoIn) {
|
|
|
|
uint32_t sliceCount = static_cast<uint16_t>(hwInfoConfig >> 32);
|
|
|
|
uint32_t subSlicePerSliceCount = static_cast<uint16_t>(hwInfoConfig >> 16);
|
|
|
|
uint32_t euPerSubSliceCount = static_cast<uint16_t>(hwInfoConfig);
|
|
|
|
|
|
|
|
hwInfoIn.gtSystemInfo.SliceCount = sliceCount;
|
|
|
|
hwInfoIn.gtSystemInfo.SubSliceCount = subSlicePerSliceCount * sliceCount;
|
2021-06-01 21:07:41 +08:00
|
|
|
hwInfoIn.gtSystemInfo.DualSubSliceCount = subSlicePerSliceCount * sliceCount;
|
2020-01-25 00:19:06 +08:00
|
|
|
hwInfoIn.gtSystemInfo.EUCount = euPerSubSliceCount * subSlicePerSliceCount * sliceCount;
|
2021-12-07 03:25:14 +08:00
|
|
|
for (uint32_t slice = 0; slice < hwInfoIn.gtSystemInfo.SliceCount; slice++) {
|
|
|
|
hwInfoIn.gtSystemInfo.SliceInfo[slice].Enabled = true;
|
|
|
|
}
|
2020-01-25 00:19:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool parseHwInfoConfigString(const std::string &hwInfoConfigStr, uint64_t &hwInfoConfig) {
|
|
|
|
hwInfoConfig = 0u;
|
|
|
|
|
|
|
|
size_t currPos = hwInfoConfigStr.find('x', 0);
|
2019-10-18 16:15:09 +08:00
|
|
|
if (currPos == std::string::npos) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-01-25 00:19:06 +08:00
|
|
|
uint32_t sliceCount = static_cast<uint32_t>(std::stoul(hwInfoConfigStr.substr(0, currPos)));
|
2019-11-21 19:43:58 +08:00
|
|
|
if (sliceCount > std::numeric_limits<uint16_t>::max()) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-10-18 16:15:09 +08:00
|
|
|
size_t prevPos = currPos + 1;
|
|
|
|
|
2020-01-25 00:19:06 +08:00
|
|
|
currPos = hwInfoConfigStr.find('x', prevPos);
|
2019-10-18 16:15:09 +08:00
|
|
|
if (currPos == std::string::npos) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-01-25 00:19:06 +08:00
|
|
|
uint32_t subSlicePerSliceCount = static_cast<uint32_t>(std::stoul(hwInfoConfigStr.substr(prevPos, currPos)));
|
2019-11-21 19:43:58 +08:00
|
|
|
if (subSlicePerSliceCount > std::numeric_limits<uint16_t>::max()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
uint32_t subSliceCount = subSlicePerSliceCount * sliceCount;
|
|
|
|
if (subSliceCount > std::numeric_limits<uint16_t>::max()) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-10-18 16:15:09 +08:00
|
|
|
prevPos = currPos + 1;
|
|
|
|
|
2020-01-25 00:19:06 +08:00
|
|
|
uint32_t euPerSubSliceCount = static_cast<uint32_t>(std::stoul(hwInfoConfigStr.substr(prevPos, std::string::npos)));
|
2019-11-21 19:43:58 +08:00
|
|
|
if (euPerSubSliceCount > std::numeric_limits<uint16_t>::max()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
uint32_t euCount = euPerSubSliceCount * subSliceCount;
|
|
|
|
if (euCount > std::numeric_limits<uint16_t>::max()) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-10-18 16:15:09 +08:00
|
|
|
|
2020-01-25 00:19:06 +08:00
|
|
|
hwInfoConfig = static_cast<uint64_t>(sliceCount & 0xffff) << 32 | static_cast<uint64_t>(subSlicePerSliceCount & 0xffff) << 16 | static_cast<uint64_t>(euPerSubSliceCount & 0xffff);
|
2019-10-18 16:15:09 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-27 17:06:29 +08:00
|
|
|
aub_stream::EngineType getChosenEngineType(const HardwareInfo &hwInfo) {
|
2018-10-02 04:36:15 +08:00
|
|
|
return DebugManager.flags.NodeOrdinal.get() == -1
|
|
|
|
? hwInfo.capabilityTable.defaultEngineType
|
2019-03-27 17:06:29 +08:00
|
|
|
: static_cast<aub_stream::EngineType>(DebugManager.flags.NodeOrdinal.get());
|
2018-10-02 04:36:15 +08:00
|
|
|
}
|
2019-08-26 21:36:24 +08:00
|
|
|
|
|
|
|
const std::string getFamilyNameWithType(const HardwareInfo &hwInfo) {
|
|
|
|
std::string platformName = familyName[hwInfo.platform.eRenderCoreFamily];
|
|
|
|
platformName.append(hwInfo.capabilityTable.platformType);
|
|
|
|
return platformName;
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|