Add prelim support for temperature, power and global operations

Related-To: LOCI-2864

Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
Bellekallu Rajkiran
2022-02-21 16:54:01 +00:00
committed by Compute-Runtime-Automation
parent 6658768149
commit 922a224cc9
11 changed files with 482 additions and 26 deletions

View File

@@ -1,16 +1,25 @@
#
# Copyright (C) 2020-2021 Intel Corporation
# Copyright (C) 2020-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_TOOLS_GLOBAL_OPERATIONS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}os_global_operations_helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_global_operations_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_global_operations_imp.h
)
if(NEO_ENABLE_i915_PRELIM_DETECTION)
list(APPEND L0_SRCS_TOOLS_GLOBAL_OPERATIONS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/os_global_operations_helper_prelim.cpp
)
else()
list(APPEND L0_SRCS_TOOLS_GLOBAL_OPERATIONS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/os_global_operations_helper.cpp
)
endif()
if(UNIX)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.h"
namespace L0 {
void LinuxGlobalOperationsImp::getRepairStatus(zes_device_state_t *pState) {
bool ifrStatus = false;
if (IGFX_PVC == pLinuxSysmanImp->getProductFamily()) {
auto pFwInterface = pLinuxSysmanImp->getFwUtilInterface();
if (pFwInterface != nullptr) {
if (ZE_RESULT_SUCCESS == pFwInterface->fwDeviceInit()) {
auto result = pFwInterface->fwIfrApplied(ifrStatus);
if (result == ZE_RESULT_SUCCESS) {
pState->repaired = ZES_REPAIR_STATUS_NOT_PERFORMED;
if (ifrStatus) {
pState->reset |= ZES_RESET_REASON_FLAG_REPAIR;
pState->repaired = ZES_REPAIR_STATUS_PERFORMED;
}
}
}
}
}
}
} // namespace L0

View File

@@ -1,25 +1,24 @@
/*
* Copyright (C) 2021 Intel Corporation
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/sysman/linux/pmt/pmt.h"
#include "level_zero/tools/source/sysman/linux/pmt/pmt_xml_offsets.h"
namespace L0 {
const std::map<std::string, uint64_t> deviceKeyOffsetMap = {
{"PACKAGE_ENERGY", 0x400},
{"COMPUTE_TEMPERATURES", 0x68},
{"SOC_TEMPERATURES", 0x60},
{"CORE_TEMPERATURES", 0x6c}};
ze_result_t PlatformMonitoringTech::getKeyOffsetMap(std::string guid, std::map<std::string, uint64_t> &keyOffsetMap) {
if (guid.empty()) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
ze_result_t retVal = ZE_RESULT_ERROR_UNKNOWN;
auto keyOffsetMapEntry = guidToKeyOffsetMap.find(guid);
if (keyOffsetMapEntry == guidToKeyOffsetMap.end()) {
// We didnt have any entry for this guid in guidToKeyOffsetMap
retVal = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
return retVal;
}
keyOffsetMap = deviceKeyOffsetMap;
keyOffsetMap = keyOffsetMapEntry->second;
return ZE_RESULT_SUCCESS;
}

View File

@@ -0,0 +1,106 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include <map>
#include <string>
namespace L0 {
// Each entry of this map corresponds to one particular graphics card type for example, DG1 A or B step.
// or XeHP_SDV. GUID string will help in identify the card type
const std::map<std::string, std::map<std::string, uint64_t>> guidToKeyOffsetMap = {
{"0x490e01", // DG1 B stepping
{{"PACKAGE_ENERGY", 0x420},
{"COMPUTE_TEMPERATURES", 0x68},
{"SOC_TEMPERATURES", 0x60},
{"CORE_TEMPERATURES", 0x6c}}},
{"0x490e", // DG1 A stepping
{{"PACKAGE_ENERGY", 0x400},
{"COMPUTE_TEMPERATURES", 0x68},
{"SOC_TEMPERATURES", 0x60},
{"CORE_TEMPERATURES", 0x6c}}},
{"0x4f95", // For DG2 device
{{"PACKAGE_ENERGY", 1032},
{"SOC_TEMPERATURES", 56}}}, // SOC_TEMPERATURE contains GT_TEMP, DRAM_TEMP, SA_TEMP, DE_TEMP, PCIE_TEMP, TYPEC_TEMP
{"0x4f9301", // For ATSM device
{{"PACKAGE_ENERGY", 1032},
{"SOC_TEMPERATURES", 56}}}, // SOC_TEMPERATURE contains GT_TEMP, DRAM_TEMP, SA_TEMP, DE_TEMP, PCIE_TEMP, TYPEC_TEMP
{"0xfdc76194", // For XeHP_SDV device
{{"HBM0MaxDeviceTemperature", 28},
{"HBM1MaxDeviceTemperature", 36},
{"TileMinTemperature", 40},
{"TileMaxTemperature", 44},
{"GTMinTemperature", 48},
{"GTMaxTemperature", 52},
{"VF0_VFID", 88},
{"VF0_HBM0_READ", 92},
{"VF0_HBM0_WRITE", 96},
{"VF0_HBM1_READ", 104},
{"VF0_HBM1_WRITE", 108},
{"VF0_TIMESTAMP_L", 168},
{"VF0_TIMESTAMP_H", 172},
{"VF1_VFID", 176},
{"VF1_HBM0_READ", 180},
{"VF1_HBM0_WRITE", 184},
{"VF1_HBM1_READ", 192},
{"VF1_HBM1_WRITE", 196},
{"VF1_TIMESTAMP_L", 256},
{"VF1_TIMESTAMP_H", 260}}},
{"0xfdc76196", // For XeHP_SDV B0 device
{{"HBM0MaxDeviceTemperature", 28},
{"HBM1MaxDeviceTemperature", 36},
{"TileMinTemperature", 40},
{"TileMaxTemperature", 44},
{"GTMinTemperature", 48},
{"GTMaxTemperature", 52},
{"VF0_VFID", 88},
{"VF0_HBM0_READ", 92},
{"VF0_HBM0_WRITE", 96},
{"VF0_HBM1_READ", 104},
{"VF0_HBM1_WRITE", 108},
{"VF0_TIMESTAMP_L", 168},
{"VF0_TIMESTAMP_H", 172},
{"VF1_VFID", 176},
{"VF1_HBM0_READ", 180},
{"VF1_HBM0_WRITE", 184},
{"VF1_HBM1_READ", 192},
{"VF1_HBM1_WRITE", 196},
{"VF1_TIMESTAMP_L", 256},
{"VF1_TIMESTAMP_H", 260}}},
{"0xb15a0edc", // For PVC device
{{"HBM0MaxDeviceTemperature", 28},
{"HBM1MaxDeviceTemperature", 36},
{"TileMinTemperature", 40},
{"TileMaxTemperature", 44},
{"GTMinTemperature", 48},
{"GTMaxTemperature", 52},
{"VF0_VFID", 88},
{"VF0_HBM0_READ", 92},
{"VF0_HBM0_WRITE", 96},
{"VF0_HBM1_READ", 104},
{"VF0_HBM1_WRITE", 108},
{"VF0_TIMESTAMP_L", 168},
{"VF0_TIMESTAMP_H", 172},
{"VF1_VFID", 176},
{"VF1_HBM0_READ", 180},
{"VF1_HBM0_WRITE", 184},
{"VF1_HBM1_READ", 192},
{"VF1_HBM1_WRITE", 196},
{"VF1_TIMESTAMP_L", 256},
{"VF1_TIMESTAMP_H", 260},
{"HBM2MaxDeviceTemperature", 300},
{"HBM3MaxDeviceTemperature", 308},
{"VF0_HBM2_READ", 312},
{"VF0_HBM2_WRITE", 316},
{"VF0_HBM3_READ", 328},
{"VF0_HBM3_WRITE", 332},
{"VF1_HBM2_READ", 344},
{"VF1_HBM2_WRITE", 348},
{"VF1_HBM3_READ", 360},
{"VF1_HBM3_WRITE", 364}}}};
} // namespace L0

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2020-2021 Intel Corporation
# Copyright (C) 2020-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -8,9 +8,18 @@ set(L0_SRCS_TOOLS_SYSMAN_POWER_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/os_power_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_power_imp.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/os_power_helper.cpp
)
if(NEO_ENABLE_i915_PRELIM_DETECTION)
list(APPEND L0_SRCS_TOOLS_SYSMAN_POWER_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/os_power_helper_prelim.cpp
)
else()
list(APPEND L0_SRCS_TOOLS_SYSMAN_POWER_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/os_power_helper.cpp
)
endif()
if(UNIX)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/sysman/power/linux/os_power_imp.h"
#include "level_zero/tools/source/sysman/sysman_const.h"
#include "sysman/linux/os_sysman_imp.h"
namespace L0 {
// The top-level hwmon(hwmon1 in example) contains all the power related information and device level
// energy counters. The other hwmon directories contain per tile energy counters.
// ex:- device/hwmon/hwmon1/energy1_input name = "i915" (Top level hwmon)
// device/hwmon/hwmon2/energy1_input name = "i915_gt0" (Tile 0)
// device/hwmon/hwmon3/energy1_input name = "i915_gt1" (Tile 1)
bool LinuxPowerImp::isEnergyHwmonDir(std::string name) {
if (isSubdevice == true) {
if (name == i915 + "_gt" + std::to_string(subdeviceId)) {
return true;
}
} else if (name == i915) {
return true;
}
return false;
}
} // namespace L0

View File

@@ -1,14 +1,24 @@
#
# Copyright (C) 2020-2021 Intel Corporation
# Copyright (C) 2020-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_TOOLS_SYSMAN_TEMPERATURE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}os_temperature_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/os_temperature_imp.h
)
if(NEO_ENABLE_i915_PRELIM_DETECTION)
list(APPEND L0_SRCS_TOOLS_SYSMAN_TEMPERATURE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/os_temperature_imp_prelim.cpp
)
else()
list(APPEND L0_SRCS_TOOLS_SYSMAN_TEMPERATURE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/os_temperature_imp.cpp
)
endif()
if(UNIX)
target_sources(${L0_STATIC_LIB_NAME}
PRIVATE

View File

@@ -0,0 +1,235 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/sysman/linux/pmt/pmt.h"
#include "level_zero/tools/source/sysman/temperature/linux/os_temperature_imp.h"
#include "sysman/linux/os_sysman_imp.h"
namespace L0 {
constexpr uint32_t numSocTemperatureEntries = 7; // entries would be PCH or GT_TEMP, DRAM, SA, PSF, DE, PCIE, TYPEC
constexpr uint32_t numCoreTemperatureEntries = 4; // entries would be CORE0, CORE1, CORE2, CORE3
constexpr uint32_t numComputeTemperatureEntries = 3; // entries would be IA, GT and LLC
constexpr uint32_t invalidMaxTemperature = 125;
constexpr uint32_t invalidMinTemperature = 10;
ze_result_t LinuxTemperatureImp::getProperties(zes_temp_properties_t *pProperties) {
pProperties->type = type;
pProperties->onSubdevice = 0;
pProperties->subdeviceId = 0;
if (isSubdevice) {
pProperties->onSubdevice = isSubdevice;
pProperties->subdeviceId = subdeviceId;
}
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxTemperatureImp::getGlobalMaxTemperatureNoSubDevice(double *pTemperature) {
auto isValidTemperature = [](auto temperature) {
if ((temperature > invalidMaxTemperature) || (temperature < invalidMinTemperature)) {
return false;
}
return true;
};
auto getMaxTemperature = [&](auto temperature, auto numTemperatureEntries) {
uint32_t maxTemperature = 0;
for (uint32_t count = 0; count < numTemperatureEntries; count++) {
uint32_t localTemperatureVal = (temperature >> (8 * count)) & 0xff;
if (isValidTemperature(localTemperatureVal)) {
if (localTemperatureVal > maxTemperature) {
maxTemperature = localTemperatureVal;
}
}
}
return maxTemperature;
};
ze_result_t result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
uint32_t maxComputeTemperature = 0;
uint32_t maxCoreTemperature = 0;
std::string key;
auto productFamily = pDevice->getNEODevice()->getHardwareInfo().platform.eProductFamily;
if (productFamily == IGFX_DG1) {
uint32_t computeTemperature = 0;
key = "COMPUTE_TEMPERATURES";
result = pPmt->readValue(key, computeTemperature);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
// Check max temperature among IA, GT and LLC sensors across COMPUTE_TEMPERATURES
maxComputeTemperature = getMaxTemperature(computeTemperature, numComputeTemperatureEntries);
uint32_t coreTemperature = 0;
key = "CORE_TEMPERATURES";
result = pPmt->readValue(key, coreTemperature);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
// Check max temperature among CORE0, CORE1, CORE2, CORE3 sensors across CORE_TEMPERATURES
maxCoreTemperature = getMaxTemperature(coreTemperature, numCoreTemperatureEntries);
}
// SOC_TEMPERATURES is present in all product families
uint64_t socTemperature = 0;
key = "SOC_TEMPERATURES";
result = pPmt->readValue(key, socTemperature);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
// Check max temperature among possible sensors like PCH or GT_TEMP, DRAM, SA, PSF, DE, PCIE, TYPEC across SOC_TEMPERATURES
uint32_t maxSocTemperature = getMaxTemperature(socTemperature, numSocTemperatureEntries);
*pTemperature = static_cast<double>(std::max({maxComputeTemperature, maxCoreTemperature, maxSocTemperature}));
return result;
}
ze_result_t LinuxTemperatureImp::getGlobalMaxTemperature(double *pTemperature) {
if (!isSubdevice) {
return getGlobalMaxTemperatureNoSubDevice(pTemperature);
}
uint32_t globalMaxTemperature = 0;
std::string key("TileMaxTemperature");
ze_result_t result = pPmt->readValue(key, globalMaxTemperature);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
*pTemperature = static_cast<double>(globalMaxTemperature);
return result;
}
ze_result_t LinuxTemperatureImp::getGpuMaxTemperatureNoSubDevice(double *pTemperature) {
double gpuMaxTemperature = 0;
uint64_t socTemperature = 0;
// Gpu temperature is obtained from GT_TEMP in SOC_TEMPERATURE's bit 0 to 7.
std::string key = "SOC_TEMPERATURES";
auto result = pPmt->readValue(key, socTemperature);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
gpuMaxTemperature = static_cast<double>(socTemperature & 0xff);
auto productFamily = pDevice->getNEODevice()->getHardwareInfo().platform.eProductFamily;
if (productFamily == IGFX_DG1) {
// In DG1 platform, Gpu Max Temperature is obtained from COMPUTE_TEMPERATURE only
uint32_t computeTemperature = 0;
std::string key("COMPUTE_TEMPERATURES");
ze_result_t result = pPmt->readValue(key, computeTemperature);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
// GT temperature could be read via 8th to 15th bit in the value read in temperature
computeTemperature = (computeTemperature >> 8) & 0xff;
gpuMaxTemperature = static_cast<double>(computeTemperature);
}
*pTemperature = gpuMaxTemperature;
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxTemperatureImp::getGpuMaxTemperature(double *pTemperature) {
if (!isSubdevice) {
return getGpuMaxTemperatureNoSubDevice(pTemperature);
}
uint32_t gpuMaxTemperature = 0;
std::string key("GTMaxTemperature");
ze_result_t result = pPmt->readValue(key, gpuMaxTemperature);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
*pTemperature = static_cast<double>(gpuMaxTemperature);
return result;
}
ze_result_t LinuxTemperatureImp::getMemoryMaxTemperature(double *pTemperature) {
ze_result_t result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
uint32_t numHbmModules = 0u;
auto productFamily = pDevice->getNEODevice()->getHardwareInfo().platform.eProductFamily;
if (productFamily == IGFX_XE_HP_SDV) {
numHbmModules = 2u;
} else if (productFamily == IGFX_PVC) {
numHbmModules = 4u;
} else {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
std::vector<uint32_t> maxDeviceTemperatureList;
for (auto hbmModuleIndex = 0u; hbmModuleIndex < numHbmModules; hbmModuleIndex++) {
uint32_t maxDeviceTemperature = 0;
// To read HBM 0's max device temperature key would be HBM0MaxDeviceTemperature
std::string key = "HBM" + std::to_string(hbmModuleIndex) + "MaxDeviceTemperature";
result = pPmt->readValue(key, maxDeviceTemperature);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
maxDeviceTemperatureList.push_back(maxDeviceTemperature);
}
*pTemperature = static_cast<double>(*std::max_element(maxDeviceTemperatureList.begin(), maxDeviceTemperatureList.end()));
return result;
}
ze_result_t LinuxTemperatureImp::getSensorTemperature(double *pTemperature) {
ze_result_t result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
switch (type) {
case ZES_TEMP_SENSORS_GLOBAL:
result = getGlobalMaxTemperature(pTemperature);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
break;
case ZES_TEMP_SENSORS_GPU:
result = getGpuMaxTemperature(pTemperature);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
break;
case ZES_TEMP_SENSORS_MEMORY:
result = getMemoryMaxTemperature(pTemperature);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
break;
default:
*pTemperature = 0;
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
break;
}
return result;
}
bool LinuxTemperatureImp::isTempModuleSupported() {
if (!isSubdevice) {
if (type == ZES_TEMP_SENSORS_MEMORY) {
return false;
}
}
return (pPmt != nullptr);
}
void LinuxTemperatureImp::setSensorType(zes_temp_sensors_t sensorType) {
type = sensorType;
}
LinuxTemperatureImp::LinuxTemperatureImp(OsSysman *pOsSysman, ze_bool_t onSubdevice,
uint32_t subdeviceId) : subdeviceId(subdeviceId), isSubdevice(onSubdevice) {
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
pPmt = pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId);
pDevice = pLinuxSysmanImp->getDeviceHandle();
}
std::unique_ptr<OsTemperature> OsTemperature::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId, zes_temp_sensors_t sensorType) {
std::unique_ptr<LinuxTemperatureImp> pLinuxTemperatureImp = std::make_unique<LinuxTemperatureImp>(pOsSysman, onSubdevice, subdeviceId);
pLinuxTemperatureImp->setSensorType(sensorType);
return pLinuxTemperatureImp;
}
} // namespace L0