diff --git a/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp b/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp index 6907842006..299eb2bdf5 100644 --- a/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp +++ b/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp @@ -61,7 +61,7 @@ bool LinuxGlobalOperationsImp::getSerialNumber(char (&serialNumber)[ZES_STRING_P } uint64_t containerOffset = 0; - if (!PlatformMonitoringTech::getTelemOffsetForContainer(telemDir, "PPIN", containerOffset)) { + if (!PlatformMonitoringTech::getTelemOffsetForContainer(pLinuxSysmanImp->getSysmanProductHelper(), telemDir, "PPIN", containerOffset)) { return false; } @@ -88,7 +88,7 @@ bool LinuxGlobalOperationsImp::getBoardNumber(char (&boardNumber)[ZES_STRING_PRO } uint64_t containerOffset = 0; - if (!PlatformMonitoringTech::getTelemOffsetForContainer(telemDir, "BoardNumber", containerOffset)) { + if (!PlatformMonitoringTech::getTelemOffsetForContainer(pLinuxSysmanImp->getSysmanProductHelper(), telemDir, "BoardNumber", containerOffset)) { return false; } diff --git a/level_zero/sysman/source/shared/linux/pmt/sysman_pmt.cpp b/level_zero/sysman/source/shared/linux/pmt/sysman_pmt.cpp index 469fcfbafe..c9bde48006 100644 --- a/level_zero/sysman/source/shared/linux/pmt/sysman_pmt.cpp +++ b/level_zero/sysman/source/shared/linux/pmt/sysman_pmt.cpp @@ -12,6 +12,7 @@ #include "shared/source/os_interface/linux/pmt_util.h" #include "level_zero/sysman/source/device/sysman_device_imp.h" +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h" #include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h" #include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h" @@ -120,10 +121,11 @@ ze_result_t PlatformMonitoringTech::enumerateRootTelemIndex(FsAccessInterface *p return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE; } -ze_result_t PlatformMonitoringTech::init(FsAccessInterface *pFsAccess, const std::string &gpuUpstreamPortPath, PRODUCT_FAMILY productFamily) { +ze_result_t PlatformMonitoringTech::init(LinuxSysmanImp *pLinuxSysmanImp, const std::string &gpuUpstreamPortPath) { std::string telemNode = telem + std::to_string(rootDeviceTelemNodeIndex); // For XE_HP_SDV and PVC single tile devices, telemetry info is retrieved from // tile's telem node rather from root device telem node. + auto productFamily = pLinuxSysmanImp->getSysmanDeviceImp()->getProductFamily(); if ((isSubdevice) || (productFamily == IGFX_PVC)) { uint32_t telemNodeIndex = 0; // If rootDeviceTelemNode is telem1, then rootDeviceTelemNodeIndex = 1 @@ -132,7 +134,9 @@ ze_result_t PlatformMonitoringTech::init(FsAccessInterface *pFsAccess, const std telemNodeIndex = rootDeviceTelemNodeIndex + subdeviceId + 1; telemNode = telem + std::to_string(telemNodeIndex); } + std::string baseTelemSysFSNode = baseTelemSysFS + "/" + telemNode; + auto pFsAccess = &pLinuxSysmanImp->getFsAccess(); if (!isValidTelemNode(pFsAccess, gpuUpstreamPortPath, baseTelemSysFSNode)) { return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE; } @@ -152,7 +156,9 @@ ze_result_t PlatformMonitoringTech::init(FsAccessInterface *pFsAccess, const std "Telemetry sysfs entry not available %s\n", guidPath.c_str()); return result; } - result = PlatformMonitoringTech::getKeyOffsetMap(guid, keyOffsetMap); + + auto pSysmanProductHelper = pLinuxSysmanImp->getSysmanProductHelper(); + result = PlatformMonitoringTech::getKeyOffsetMap(pSysmanProductHelper, guid, keyOffsetMap); if (ZE_RESULT_SUCCESS != result) { // We didnt have any entry for this guid in guidToKeyOffsetMap return result; @@ -173,10 +179,10 @@ PlatformMonitoringTech::PlatformMonitoringTech(FsAccessInterface *pFsAccess, ze_ uint32_t subdeviceId) : subdeviceId(subdeviceId), isSubdevice(onSubdevice) { } -void PlatformMonitoringTech::doInitPmtObject(FsAccessInterface *pFsAccess, uint32_t subdeviceId, PlatformMonitoringTech *pPmt, - const std::string &gpuUpstreamPortPath, - std::map &mapOfSubDeviceIdToPmtObject, PRODUCT_FAMILY productFamily) { - if (pPmt->init(pFsAccess, gpuUpstreamPortPath, productFamily) == ZE_RESULT_SUCCESS) { +void PlatformMonitoringTech::doInitPmtObject(LinuxSysmanImp *pLinuxSysmanImp, uint32_t subdeviceId, PlatformMonitoringTech *pPmt, const std::string &gpuUpstreamPortPath, + std::map &mapOfSubDeviceIdToPmtObject) { + + if (pPmt->init(pLinuxSysmanImp, gpuUpstreamPortPath) == ZE_RESULT_SUCCESS) { mapOfSubDeviceIdToPmtObject.emplace(subdeviceId, pPmt); NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stdout, "Pmt object: 0x%llX initialization for subdeviceId %d successful\n", pPmt, static_cast(subdeviceId)); @@ -194,11 +200,9 @@ void PlatformMonitoringTech::create(LinuxSysmanImp *pLinuxSysmanImp, std::string uint32_t subdeviceId = 0; do { ze_bool_t onSubdevice = (subDeviceCount == 0) ? false : true; - auto productFamily = pLinuxSysmanImp->getSysmanDeviceImp()->getProductFamily(); auto pPmt = new PlatformMonitoringTech(&pLinuxSysmanImp->getFsAccess(), onSubdevice, subdeviceId); UNRECOVERABLE_IF(nullptr == pPmt); - PlatformMonitoringTech::doInitPmtObject(&pLinuxSysmanImp->getFsAccess(), subdeviceId, pPmt, - gpuUpstreamPortPath, mapOfSubDeviceIdToPmtObject, productFamily); + PlatformMonitoringTech::doInitPmtObject(pLinuxSysmanImp, subdeviceId, pPmt, gpuUpstreamPortPath, mapOfSubDeviceIdToPmtObject); subdeviceId++; } while (subdeviceId < subDeviceCount); } @@ -225,7 +229,7 @@ bool PlatformMonitoringTech::getTelemOffsetAndTelemDir(LinuxSysmanImp *pLinuxSys return true; } -bool PlatformMonitoringTech::getTelemOffsetForContainer(const std::string &telemDir, const std::string &key, uint64_t &telemOffset) { +bool PlatformMonitoringTech::getTelemOffsetForContainer(SysmanProductHelper *pSysmanProductHelper, const std::string &telemDir, const std::string &key, uint64_t &telemOffset) { std::array guidString = {}; if (!NEO::PmtUtil::readGuid(telemDir, guidString)) { NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read GUID from %s \n", __FUNCTION__, telemDir.c_str()); @@ -233,7 +237,7 @@ bool PlatformMonitoringTech::getTelemOffsetForContainer(const std::string &telem } std::map keyOffsetMap; - if (ZE_RESULT_SUCCESS == PlatformMonitoringTech::getKeyOffsetMap(guidString.data(), keyOffsetMap)) { + if (ZE_RESULT_SUCCESS == PlatformMonitoringTech::getKeyOffsetMap(pSysmanProductHelper, guidString.data(), keyOffsetMap)) { auto keyOffset = keyOffsetMap.find(key.c_str()); if (keyOffset != keyOffsetMap.end()) { telemOffset = keyOffset->second; diff --git a/level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h b/level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h index a1b1f72d2f..02a249f4e3 100644 --- a/level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h +++ b/level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h @@ -11,8 +11,6 @@ #include "level_zero/zes_api.h" -#include "igfxfmid.h" - #include #include #include @@ -22,6 +20,7 @@ namespace L0 { namespace Sysman { class LinuxSysmanImp; class FsAccessInterface; +class SysmanProductHelper; class PlatformMonitoringTech : NEO::NonCopyableOrMovableClass { public: @@ -35,18 +34,18 @@ class PlatformMonitoringTech : NEO::NonCopyableOrMovableClass { static ze_result_t enumerateRootTelemIndex(FsAccessInterface *pFsAccess, std::string &gpuUpstreamPortPath); static void create(LinuxSysmanImp *pLinuxSysmanImp, std::string &gpuUpstreamPortPath, std::map &mapOfSubDeviceIdToPmtObject); - static ze_result_t getKeyOffsetMap(std::string guid, std::map &keyOffsetMap); + static ze_result_t getKeyOffsetMap(SysmanProductHelper *pSysmanProductHelper, std::string guid, std::map &keyOffsetMap); static bool getTelemOffsetAndTelemDir(LinuxSysmanImp *pLinuxSysmanImp, uint64_t &telemOffset, std::string &telemDir); - static bool getTelemOffsetForContainer(const std::string &telemDir, const std::string &key, uint64_t &telemOffset); + static bool getTelemOffsetForContainer(SysmanProductHelper *pSysmanProductHelper, const std::string &telemDir, const std::string &key, uint64_t &telemOffset); protected: static uint32_t rootDeviceTelemNodeIndex; std::string telemetryDeviceEntry{}; std::map keyOffsetMap; std::string guid; - ze_result_t init(FsAccessInterface *pFsAccess, const std::string &gpuUpstreamPortPath, PRODUCT_FAMILY productFamily); - static void doInitPmtObject(FsAccessInterface *pFsAccess, uint32_t subdeviceId, PlatformMonitoringTech *pPmt, const std::string &gpuUpstreamPortPath, - std::map &mapOfSubDeviceIdToPmtObject, PRODUCT_FAMILY productFamily); + ze_result_t init(LinuxSysmanImp *pLinuxSysmanImp, const std::string &gpuUpstreamPortPath); + static void doInitPmtObject(LinuxSysmanImp *pLinuxSysmanImp, uint32_t subdeviceId, PlatformMonitoringTech *pPmt, const std::string &gpuUpstreamPortPath, + std::map &mapOfSubDeviceIdToPmtObject); decltype(&NEO::SysCalls::pread) preadFunction = NEO::SysCalls::pread; private: diff --git a/level_zero/sysman/source/shared/linux/pmt/sysman_pmt_helper.cpp b/level_zero/sysman/source/shared/linux/pmt/sysman_pmt_helper.cpp index f85f3c33e9..712d7c409f 100644 --- a/level_zero/sysman/source/shared/linux/pmt/sysman_pmt_helper.cpp +++ b/level_zero/sysman/source/shared/linux/pmt/sysman_pmt_helper.cpp @@ -1,20 +1,24 @@ /* - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h" -#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt_xml_offsets.h" +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h" namespace L0 { namespace Sysman { -ze_result_t PlatformMonitoringTech::getKeyOffsetMap(std::string guid, std::map &keyOffsetMap) { +ze_result_t PlatformMonitoringTech::getKeyOffsetMap(SysmanProductHelper *pSysmanProductHelper, std::string guid, std::map &keyOffsetMap) { ze_result_t retVal = ZE_RESULT_ERROR_UNKNOWN; - auto keyOffsetMapEntry = guidToKeyOffsetMap.find(guid); - if (keyOffsetMapEntry == guidToKeyOffsetMap.end()) { + auto pGuidToKeyOffsetMap = pSysmanProductHelper->getGuidToKeyOffsetMap(); + if (pGuidToKeyOffsetMap == nullptr) { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + auto keyOffsetMapEntry = pGuidToKeyOffsetMap->find(guid); + if (keyOffsetMapEntry == pGuidToKeyOffsetMap->end()) { // We didnt have any entry for this guid in guidToKeyOffsetMap retVal = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; return retVal; diff --git a/level_zero/sysman/source/shared/linux/pmt/sysman_pmt_xml_offsets.h b/level_zero/sysman/source/shared/linux/pmt/sysman_pmt_xml_offsets.h deleted file mode 100644 index 594a62cca5..0000000000 --- a/level_zero/sysman/source/shared/linux/pmt/sysman_pmt_xml_offsets.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (C) 2020-2023 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#pragma once - -#include -#include -#include - -namespace L0 { -namespace Sysman { - -// 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> 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 - {"0x4f9302", // For DG2 512EU / ATS-M1 - {{"PACKAGE_ENERGY", 1032}, - {"SOC_TEMPERATURES", 56}, - {"MC_CAPTURE_TIMESTAMP", 1088}, - {"IDI_READS[0]", 1096}, - {"IDI_READS[1]", 1104}, - {"IDI_READS[2]", 1112}, - {"IDI_READS[3]", 1120}, - {"IDI_READS[4]", 1128}, - {"IDI_READS[5]", 1136}, - {"IDI_READS[6]", 1144}, - {"IDI_READS[7]", 1152}, - {"IDI_READS[8]", 1160}, - {"IDI_READS[9]", 1168}, - {"IDI_READS[10]", 1176}, - {"IDI_READS[11]", 1184}, - {"IDI_READS[12]", 1192}, - {"IDI_READS[13]", 1200}, - {"IDI_READS[14]", 1208}, - {"IDI_READS[15]", 1216}, - {"IDI_WRITES[0]", 1224}, - {"IDI_WRITES[1]", 1232}, - {"IDI_WRITES[2]", 1240}, - {"IDI_WRITES[3]", 1248}, - {"IDI_WRITES[4]", 1256}, - {"IDI_WRITES[5]", 1264}, - {"IDI_WRITES[6]", 1272}, - {"IDI_WRITES[7]", 1280}, - {"IDI_WRITES[8]", 1288}, - {"IDI_WRITES[9]", 1296}, - {"IDI_WRITES[10]", 1304}, - {"IDI_WRITES[11]", 1312}, - {"IDI_WRITES[12]", 1320}, - {"IDI_WRITES[13]", 1328}, - {"IDI_WRITES[14]", 1336}, - {"IDI_WRITES[15]", 1344}, - {"DISPLAY_VC1_READS[0]", 1352}, - {"DISPLAY_VC1_READS[1]", 1360}, - {"DISPLAY_VC1_READS[2]", 1368}, - {"DISPLAY_VC1_READS[3]", 1376}, - {"DISPLAY_VC1_READS[4]", 1384}, - {"DISPLAY_VC1_READS[5]", 1392}, - {"DISPLAY_VC1_READS[6]", 1400}, - {"DISPLAY_VC1_READS[7]", 1408}, - {"DISPLAY_VC1_READS[8]", 1416}, - {"DISPLAY_VC1_READS[9]", 1424}, - {"DISPLAY_VC1_READS[10]", 1432}, - {"DISPLAY_VC1_READS[11]", 1440}, - {"DISPLAY_VC1_READS[12]", 1448}, - {"DISPLAY_VC1_READS[13]", 1456}, - {"DISPLAY_VC1_READS[14]", 1464}, - {"DISPLAY_VC1_READS[15]", 1472}}}, - {"0x4f9502", // For DG2 128EU / ATS-M3 - {{"PACKAGE_ENERGY", 1032}, - {"SOC_TEMPERATURES", 56}, - {"MC_CAPTURE_TIMESTAMP", 1088}, - {"IDI_READS[0]", 1096}, - {"IDI_READS[1]", 1104}, - {"IDI_READS[2]", 1112}, - {"IDI_READS[3]", 1120}, - {"IDI_READS[4]", 1128}, - {"IDI_READS[5]", 1136}, - {"IDI_READS[6]", 1144}, - {"IDI_READS[7]", 1152}, - {"IDI_READS[8]", 1160}, - {"IDI_READS[9]", 1168}, - {"IDI_READS[10]", 1176}, - {"IDI_READS[11]", 1184}, - {"IDI_READS[12]", 1192}, - {"IDI_READS[13]", 1200}, - {"IDI_READS[14]", 1208}, - {"IDI_READS[15]", 1216}, - {"IDI_WRITES[0]", 1224}, - {"IDI_WRITES[1]", 1232}, - {"IDI_WRITES[2]", 1240}, - {"IDI_WRITES[3]", 1248}, - {"IDI_WRITES[4]", 1256}, - {"IDI_WRITES[5]", 1264}, - {"IDI_WRITES[6]", 1272}, - {"IDI_WRITES[7]", 1280}, - {"IDI_WRITES[8]", 1288}, - {"IDI_WRITES[9]", 1296}, - {"IDI_WRITES[10]", 1304}, - {"IDI_WRITES[11]", 1312}, - {"IDI_WRITES[12]", 1320}, - {"IDI_WRITES[13]", 1328}, - {"IDI_WRITES[14]", 1336}, - {"IDI_WRITES[15]", 1344}, - {"DISPLAY_VC1_READS[0]", 1352}, - {"DISPLAY_VC1_READS[1]", 1360}, - {"DISPLAY_VC1_READS[2]", 1368}, - {"DISPLAY_VC1_READS[3]", 1376}, - {"DISPLAY_VC1_READS[4]", 1384}, - {"DISPLAY_VC1_READS[5]", 1392}, - {"DISPLAY_VC1_READS[6]", 1400}, - {"DISPLAY_VC1_READS[7]", 1408}, - {"DISPLAY_VC1_READS[8]", 1416}, - {"DISPLAY_VC1_READS[9]", 1424}, - {"DISPLAY_VC1_READS[10]", 1432}, - {"DISPLAY_VC1_READS[11]", 1440}, - {"DISPLAY_VC1_READS[12]", 1448}, - {"DISPLAY_VC1_READS[13]", 1456}, - {"DISPLAY_VC1_READS[14]", 1464}, - {"DISPLAY_VC1_READS[15]", 1472}}}, - {"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}}}, - {"0xb15a0edd", // 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}}}, - {"0xb15a0ede", // 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}, - {"VF0_HBM_READ_L", 384}, - {"VF0_HBM_READ_H", 388}, - {"VF0_HBM_WRITE_L", 392}, - {"VF0_HBM_WRITE_H", 396}, - {"VF1_HBM_READ_L", 400}, - {"VF1_HBM_READ_H", 404}, - {"VF1_HBM_WRITE_L", 408}, - {"VF1_HBM_WRITE_H", 412}}}, - {"0x41fe79a5", // For PVC root device - {{"PPIN", 152}, - {"BoardNumber", 72}}}}; -} // namespace Sysman -} // namespace L0 diff --git a/level_zero/sysman/source/shared/linux/product_helper/gen12lp/dg1/sysman_product_helper_dg1.cpp b/level_zero/sysman/source/shared/linux/product_helper/gen12lp/dg1/sysman_product_helper_dg1.cpp index 7860046e1b..28d2cf4685 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/gen12lp/dg1/sysman_product_helper_dg1.cpp +++ b/level_zero/sysman/source/shared/linux/product_helper/gen12lp/dg1/sysman_product_helper_dg1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -17,6 +17,23 @@ namespace L0 { namespace Sysman { constexpr static auto gfxProduct = IGFX_DG1; +static std::map> 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}}}}; + +template <> +const std::map> *SysmanProductHelperHw::getGuidToKeyOffsetMap() { + return &guidToKeyOffsetMap; +} + template <> ze_result_t SysmanProductHelperHw::getGlobalMaxTemperature(PlatformMonitoringTech *pPmt, double *pTemperature) { auto isValidTemperature = [](auto temperature) { diff --git a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h index 19a37bdc38..ca6d3be7a8 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h +++ b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h @@ -12,6 +12,7 @@ #include "igfxfmid.h" +#include #include #include @@ -96,6 +97,7 @@ class SysmanProductHelper { virtual bool isEccConfigurationSupported() = 0; virtual ~SysmanProductHelper() = default; + virtual const std::map> *getGuidToKeyOffsetMap() = 0; protected: SysmanProductHelper() = default; diff --git a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h index 4f4286be0a..f8c5998478 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h +++ b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h @@ -73,6 +73,8 @@ class SysmanProductHelperHw : public SysmanProductHelper { ~SysmanProductHelperHw() override = default; + const std::map> *getGuidToKeyOffsetMap() override; + protected: SysmanProductHelperHw() = default; }; diff --git a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl index 2e805aba7d..045c9485b7 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl +++ b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl @@ -24,6 +24,11 @@ namespace L0 { namespace Sysman { +template +const std::map> *SysmanProductHelperHw::getGuidToKeyOffsetMap() { + return nullptr; +} + template void SysmanProductHelperHw::getFrequencyStepSize(double *pStepSize) { *pStepSize = (50.0 / 3); // Step of 16.6666667 Mhz diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp b/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp index af49d187e9..3c6a92a320 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp +++ b/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp @@ -19,6 +19,117 @@ static const uint32_t numHbmModules = 4; #include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_xe_hp_and_later.inl" +static std::map> guidToKeyOffsetMap = { + {"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}}}, + {"0xb15a0edd", // 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}}}, + {"0xb15a0ede", // 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}, + {"VF0_HBM_READ_L", 384}, + {"VF0_HBM_READ_H", 388}, + {"VF0_HBM_WRITE_L", 392}, + {"VF0_HBM_WRITE_H", 396}, + {"VF1_HBM_READ_L", 400}, + {"VF1_HBM_READ_H", 404}, + {"VF1_HBM_WRITE_L", 408}, + {"VF1_HBM_WRITE_H", 412}}}, + {"0x41fe79a5", // For PVC root device + {{"PPIN", 152}, + {"BoardNumber", 72}}}}; + +template <> +const std::map> *SysmanProductHelperHw::getGuidToKeyOffsetMap() { + return &guidToKeyOffsetMap; +} + void getHBMFrequency(SysmanKmdInterface *pSysmanKmdInterface, SysFsAccessInterface *pSysFsAccess, uint64_t &hbmFrequency, uint32_t subdeviceId, unsigned short stepping) { hbmFrequency = 0; if (stepping >= REVISION_B) { diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe_hpg_core/dg2/sysman_product_helper_dg2.cpp b/level_zero/sysman/source/shared/linux/product_helper/xe_hpg_core/dg2/sysman_product_helper_dg2.cpp index 7c5fbba350..3b9bfa0ab7 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/xe_hpg_core/dg2/sysman_product_helper_dg2.cpp +++ b/level_zero/sysman/source/shared/linux/product_helper/xe_hpg_core/dg2/sysman_product_helper_dg2.cpp @@ -20,6 +20,123 @@ RasInterfaceType SysmanProductHelperHw::getGtRasUtilInterface() { #include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_xe_hp_and_later.inl" +static std::map> guidToKeyOffsetMap = { + {"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 + {"0x4f9302", // For DG2 512EU / ATS-M1 + {{"PACKAGE_ENERGY", 1032}, + {"SOC_TEMPERATURES", 56}, + {"MC_CAPTURE_TIMESTAMP", 1088}, + {"IDI_READS[0]", 1096}, + {"IDI_READS[1]", 1104}, + {"IDI_READS[2]", 1112}, + {"IDI_READS[3]", 1120}, + {"IDI_READS[4]", 1128}, + {"IDI_READS[5]", 1136}, + {"IDI_READS[6]", 1144}, + {"IDI_READS[7]", 1152}, + {"IDI_READS[8]", 1160}, + {"IDI_READS[9]", 1168}, + {"IDI_READS[10]", 1176}, + {"IDI_READS[11]", 1184}, + {"IDI_READS[12]", 1192}, + {"IDI_READS[13]", 1200}, + {"IDI_READS[14]", 1208}, + {"IDI_READS[15]", 1216}, + {"IDI_WRITES[0]", 1224}, + {"IDI_WRITES[1]", 1232}, + {"IDI_WRITES[2]", 1240}, + {"IDI_WRITES[3]", 1248}, + {"IDI_WRITES[4]", 1256}, + {"IDI_WRITES[5]", 1264}, + {"IDI_WRITES[6]", 1272}, + {"IDI_WRITES[7]", 1280}, + {"IDI_WRITES[8]", 1288}, + {"IDI_WRITES[9]", 1296}, + {"IDI_WRITES[10]", 1304}, + {"IDI_WRITES[11]", 1312}, + {"IDI_WRITES[12]", 1320}, + {"IDI_WRITES[13]", 1328}, + {"IDI_WRITES[14]", 1336}, + {"IDI_WRITES[15]", 1344}, + {"DISPLAY_VC1_READS[0]", 1352}, + {"DISPLAY_VC1_READS[1]", 1360}, + {"DISPLAY_VC1_READS[2]", 1368}, + {"DISPLAY_VC1_READS[3]", 1376}, + {"DISPLAY_VC1_READS[4]", 1384}, + {"DISPLAY_VC1_READS[5]", 1392}, + {"DISPLAY_VC1_READS[6]", 1400}, + {"DISPLAY_VC1_READS[7]", 1408}, + {"DISPLAY_VC1_READS[8]", 1416}, + {"DISPLAY_VC1_READS[9]", 1424}, + {"DISPLAY_VC1_READS[10]", 1432}, + {"DISPLAY_VC1_READS[11]", 1440}, + {"DISPLAY_VC1_READS[12]", 1448}, + {"DISPLAY_VC1_READS[13]", 1456}, + {"DISPLAY_VC1_READS[14]", 1464}, + {"DISPLAY_VC1_READS[15]", 1472}}}, + {"0x4f9502", // For DG2 128EU / ATS-M3 + {{"PACKAGE_ENERGY", 1032}, + {"SOC_TEMPERATURES", 56}, + {"MC_CAPTURE_TIMESTAMP", 1088}, + {"IDI_READS[0]", 1096}, + {"IDI_READS[1]", 1104}, + {"IDI_READS[2]", 1112}, + {"IDI_READS[3]", 1120}, + {"IDI_READS[4]", 1128}, + {"IDI_READS[5]", 1136}, + {"IDI_READS[6]", 1144}, + {"IDI_READS[7]", 1152}, + {"IDI_READS[8]", 1160}, + {"IDI_READS[9]", 1168}, + {"IDI_READS[10]", 1176}, + {"IDI_READS[11]", 1184}, + {"IDI_READS[12]", 1192}, + {"IDI_READS[13]", 1200}, + {"IDI_READS[14]", 1208}, + {"IDI_READS[15]", 1216}, + {"IDI_WRITES[0]", 1224}, + {"IDI_WRITES[1]", 1232}, + {"IDI_WRITES[2]", 1240}, + {"IDI_WRITES[3]", 1248}, + {"IDI_WRITES[4]", 1256}, + {"IDI_WRITES[5]", 1264}, + {"IDI_WRITES[6]", 1272}, + {"IDI_WRITES[7]", 1280}, + {"IDI_WRITES[8]", 1288}, + {"IDI_WRITES[9]", 1296}, + {"IDI_WRITES[10]", 1304}, + {"IDI_WRITES[11]", 1312}, + {"IDI_WRITES[12]", 1320}, + {"IDI_WRITES[13]", 1328}, + {"IDI_WRITES[14]", 1336}, + {"IDI_WRITES[15]", 1344}, + {"DISPLAY_VC1_READS[0]", 1352}, + {"DISPLAY_VC1_READS[1]", 1360}, + {"DISPLAY_VC1_READS[2]", 1368}, + {"DISPLAY_VC1_READS[3]", 1376}, + {"DISPLAY_VC1_READS[4]", 1384}, + {"DISPLAY_VC1_READS[5]", 1392}, + {"DISPLAY_VC1_READS[6]", 1400}, + {"DISPLAY_VC1_READS[7]", 1408}, + {"DISPLAY_VC1_READS[8]", 1416}, + {"DISPLAY_VC1_READS[9]", 1424}, + {"DISPLAY_VC1_READS[10]", 1432}, + {"DISPLAY_VC1_READS[11]", 1440}, + {"DISPLAY_VC1_READS[12]", 1448}, + {"DISPLAY_VC1_READS[13]", 1456}, + {"DISPLAY_VC1_READS[14]", 1464}, + {"DISPLAY_VC1_READS[15]", 1472}}}}; + +template <> +const std::map> *SysmanProductHelperHw::getGuidToKeyOffsetMap() { + return &guidToKeyOffsetMap; +} + ze_result_t readMcChannelCounters(PlatformMonitoringTech *pPmt, uint64_t &readCounters, uint64_t &writeCounters) { uint32_t numMcChannels = 16u; ze_result_t result = ZE_RESULT_ERROR_UNKNOWN; diff --git a/level_zero/sysman/test/unit_tests/sources/global_operations/linux/test_zes_global_operations.cpp b/level_zero/sysman/test/unit_tests/sources/global_operations/linux/test_zes_global_operations.cpp index a02b9e1786..9ce13e48d5 100644 --- a/level_zero/sysman/test/unit_tests/sources/global_operations/linux/test_zes_global_operations.cpp +++ b/level_zero/sysman/test/unit_tests/sources/global_operations/linux/test_zes_global_operations.cpp @@ -11,6 +11,7 @@ #include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h" #include "level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.h" +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h" #include "level_zero/sysman/test/unit_tests/sources/global_operations/linux/mock_global_operations.h" #include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h" #include "level_zero/sysman/test/unit_tests/sources/shared/linux/kmd_interface/mock_sysman_kmd_interface_i915.h" @@ -202,6 +203,19 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesGlobal return -1; }); + struct MockSysmanProductHelperGlobalOperation : L0::Sysman::SysmanProductHelperHw { + MockSysmanProductHelperGlobalOperation() = default; + std::unique_ptr>> mockMap; + std::map> *getGuidToKeyOffsetMap() override { + mockMap = std::make_unique>>(); + (*mockMap)["0x41fe79a5"] = {{"PPIN", 152}, + {"BoardNumber", 72}}; + return mockMap.get(); + } + }; + std::unique_ptr pSysmanProductHelper = std::make_unique(); + std::swap(pLinuxSysmanImp->pSysmanProductHelper, pSysmanProductHelper); + MockGlobalOperationsFsAccess *pFsAccess = new MockGlobalOperationsFsAccess(); MockGlobalOperationsSysfsAccess *pSysfsAccess = new MockGlobalOperationsSysfsAccess(); MockSysmanKmdInterfacePrelim *pSysmanKmdInterface = new MockSysmanKmdInterfacePrelim(pLinuxSysmanImp->getSysmanProductHelper()); diff --git a/level_zero/sysman/test/unit_tests/sources/linux/mocks/mock_sysman_product_helper.h b/level_zero/sysman/test/unit_tests/sources/linux/mocks/mock_sysman_product_helper.h index 1044d069d8..1d2f183500 100644 --- a/level_zero/sysman/test/unit_tests/sources/linux/mocks/mock_sysman_product_helper.h +++ b/level_zero/sysman/test/unit_tests/sources/linux/mocks/mock_sysman_product_helper.h @@ -15,8 +15,16 @@ namespace L0 { namespace Sysman { namespace ult { +static std::map> mockGuidToKeyOffsetMap = { + {"0x490e01", + {{"PACKAGE_ENERGY", 0x420}, + {"COMPUTE_TEMPERATURES", 0x68}, + {"SOC_TEMPERATURES", 0x60}, + {"CORE_TEMPERATURES", 0x6c}}}}; + struct MockSysmanProductHelper : public L0::Sysman::SysmanProductHelperHw { MockSysmanProductHelper() = default; + std::map> *getGuidToKeyOffsetMap() override { return &mockGuidToKeyOffsetMap; } ADDMETHOD_NOBASE(isFrequencySetRangeSupported, bool, false, ()); ADDMETHOD_NOBASE(isPowerSetLimitSupported, bool, false, ()); }; diff --git a/level_zero/sysman/test/unit_tests/sources/linux/pmt/test_pmt.cpp b/level_zero/sysman/test/unit_tests/sources/linux/pmt/test_pmt.cpp index 79c4b4d117..92fbb47568 100644 --- a/level_zero/sysman/test/unit_tests/sources/linux/pmt/test_pmt.cpp +++ b/level_zero/sysman/test/unit_tests/sources/linux/pmt/test_pmt.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h" #include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h" +#include "level_zero/sysman/test/unit_tests/sources/linux/mocks/mock_sysman_product_helper.h" #include "mock_pmt.h" @@ -23,6 +25,7 @@ class ZesPmtFixtureMultiDevice : public SysmanMultiDeviceFixture { void SetUp() override { SysmanMultiDeviceFixture::SetUp(); pTestFsAccess = std::make_unique(); + pLinuxSysmanImp->pFsAccess = pTestFsAccess.get(); L0::Sysman::PlatformMonitoringTech::create(pLinuxSysmanImp, gpuUpstreamPortPathInPmt, mapOfSubDeviceIdToPmtObject); } void TearDown() override { @@ -59,25 +62,22 @@ TEST_F(ZesPmtFixtureMultiDevice, GivenTelemDirectoryContainNowTelemEntryWhenenum TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenCreatingPMTHandlesThenCheckForErrorThatCouldHappenDuringWhileValidatingTelemNode) { pTestFsAccess->getRealPathResult = ZE_RESULT_ERROR_NOT_AVAILABLE; L0::Sysman::PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt); - auto productFamily = pSysmanDeviceImp->getProductFamily(); auto pPmt = std::make_unique(pTestFsAccess.get(), 1, 0); - EXPECT_EQ(pPmt->init(pTestFsAccess.get(), gpuUpstreamPortPathInPmt, productFamily), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE); + EXPECT_EQ(pPmt->init(pLinuxSysmanImp, gpuUpstreamPortPathInPmt), ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE); } TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenCreatingPMTHandlesThenCheckForErrorThatCouldHappenDuringGUIDRead) { pTestFsAccess->readStringResult = ZE_RESULT_ERROR_NOT_AVAILABLE; L0::Sysman::PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt); - auto productFamily = pSysmanDeviceImp->getProductFamily(); auto pPmt = std::make_unique(pTestFsAccess.get(), 1, 0); - EXPECT_EQ(pPmt->init(pTestFsAccess.get(), gpuUpstreamPortPathInPmt, productFamily), ZE_RESULT_ERROR_NOT_AVAILABLE); + EXPECT_EQ(pPmt->init(pLinuxSysmanImp, gpuUpstreamPortPathInPmt), ZE_RESULT_ERROR_NOT_AVAILABLE); } TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenCreatingPMTHandlesThenCheckForErrorIfGUIDReadValueIsNotSupported) { pTestFsAccess->readInvalidString = true; L0::Sysman::PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt); - auto productFamily = pSysmanDeviceImp->getProductFamily(); auto pPmt = std::make_unique(pTestFsAccess.get(), 1, 0); - EXPECT_EQ(pPmt->init(pTestFsAccess.get(), gpuUpstreamPortPathInPmt, productFamily), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + EXPECT_EQ(pPmt->init(pLinuxSysmanImp, gpuUpstreamPortPathInPmt), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); } TEST_F(ZesPmtFixtureMultiDevice, GivenSomeKeyWhenCallingreadValueWithUint64TypeThenCheckForErrorBranches) { @@ -95,11 +95,12 @@ TEST_F(ZesPmtFixtureMultiDevice, GivenSomeKeyWhenCallingreadValueWithUint32TypeT } TEST_F(ZesPmtFixtureMultiDevice, GivenValidDeviceHandlesWhenCreatingPMTHandlesThenCheckForErrorThatCouldHappenDuringbaseOffsetRead) { + std::unique_ptr pSysmanProductHelper = std::make_unique(); + std::swap(pLinuxSysmanImp->pSysmanProductHelper, pSysmanProductHelper); pTestFsAccess->readUnsignedResult = ZE_RESULT_ERROR_NOT_AVAILABLE; L0::Sysman::PlatformMonitoringTech::enumerateRootTelemIndex(pTestFsAccess.get(), gpuUpstreamPortPathInPmt); - auto productFamily = pSysmanDeviceImp->getProductFamily(); auto pPmt = std::make_unique(pTestFsAccess.get(), 1, 0); - EXPECT_EQ(pPmt->init(pTestFsAccess.get(), gpuUpstreamPortPathInPmt, productFamily), ZE_RESULT_ERROR_NOT_AVAILABLE); + EXPECT_EQ(pPmt->init(pLinuxSysmanImp, gpuUpstreamPortPathInPmt), ZE_RESULT_ERROR_NOT_AVAILABLE); } inline static int openMockReturnFailure(const char *pathname, int flags) { @@ -189,6 +190,8 @@ TEST_F(ZesPmtFixtureMultiDevice, GivenValidSyscallsWhenCallingreadValueWithUint6 } TEST_F(ZesPmtFixtureMultiDevice, GivenValidSyscallsWhenDoingPMTInitThenPMTmapOfSubDeviceIdToPmtObjectWouldContainValidEntries) { + std::unique_ptr pSysmanProductHelper = std::make_unique(); + std::swap(pLinuxSysmanImp->pSysmanProductHelper, pSysmanProductHelper); std::map mapOfSubDeviceIdToPmtObject; auto subDeviceCount = pLinuxSysmanImp->getSubDeviceCount(); uint32_t subdeviceId = 0; @@ -196,10 +199,8 @@ TEST_F(ZesPmtFixtureMultiDevice, GivenValidSyscallsWhenDoingPMTInitThenPMTmapOfS ze_bool_t onSubdevice = (subDeviceCount == 0) ? false : true; auto pPmt = new PublicPlatformMonitoringTech(pTestFsAccess.get(), onSubdevice, subdeviceId); PublicPlatformMonitoringTech::rootDeviceTelemNodeIndex = 1; - auto productFamily = pSysmanDeviceImp->getProductFamily(); UNRECOVERABLE_IF(nullptr == pPmt); - PublicPlatformMonitoringTech::doInitPmtObject(pTestFsAccess.get(), subdeviceId, pPmt, - gpuUpstreamPortPathInPmt, mapOfSubDeviceIdToPmtObject, productFamily); + PublicPlatformMonitoringTech::doInitPmtObject(pLinuxSysmanImp, subdeviceId, pPmt, gpuUpstreamPortPathInPmt, mapOfSubDeviceIdToPmtObject); auto subDeviceIdToPmtEntry = mapOfSubDeviceIdToPmtObject.find(subdeviceId); EXPECT_EQ(subDeviceIdToPmtEntry->second, pPmt); delete pPmt; @@ -215,10 +216,8 @@ TEST_F(ZesPmtFixtureMultiDevice, GivenBaseOffsetReadFailWhenDoingPMTInitThenPMTm do { ze_bool_t onSubdevice = (subDeviceCount == 0) ? false : true; auto pPmt = new PublicPlatformMonitoringTech(pTestFsAccess.get(), onSubdevice, subdeviceId); - auto productFamily = pSysmanDeviceImp->getProductFamily(); UNRECOVERABLE_IF(nullptr == pPmt); - PublicPlatformMonitoringTech::doInitPmtObject(pTestFsAccess.get(), subdeviceId, pPmt, - gpuUpstreamPortPathInPmt, mapOfSubDeviceIdToPmtObject, productFamily); + PublicPlatformMonitoringTech::doInitPmtObject(pLinuxSysmanImp, subdeviceId, pPmt, gpuUpstreamPortPathInPmt, mapOfSubDeviceIdToPmtObject); EXPECT_TRUE(mapOfSubDeviceIdToPmtObject.empty()); } while (++subdeviceId < subDeviceCount); diff --git a/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/CMakeLists.txt b/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/CMakeLists.txt index 06408a4d65..050031515e 100644 --- a/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/CMakeLists.txt +++ b/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/CMakeLists.txt @@ -14,6 +14,7 @@ if(UNIX) ${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_frequency_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_ras_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_power_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_pmt_tests.cpp ) endif() add_subdirectories() \ No newline at end of file diff --git a/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_pmt_tests.cpp b/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_pmt_tests.cpp new file mode 100644 index 0000000000..512f6866d0 --- /dev/null +++ b/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_pmt_tests.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h" +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h" +#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h" + +namespace L0 { +namespace Sysman { +namespace ult { + +const std::map> mockDg1GuidToKeyOffsetMap = {{"0x490e01", + {{"PACKAGE_ENERGY", 0x420}, + {"COMPUTE_TEMPERATURES", 0x68}}}}; + +const std::map> mockDg2GuidToKeyOffsetMap = {{"0x4f95", + {{"PACKAGE_ENERGY", 1032}, + {"SOC_TEMPERATURES", 56}}}}; + +const std::map> mockPvcGuidToKeyOffsetMap = {{"0xb15a0edc", + {{"HBM0MaxDeviceTemperature", 28}, + {"HBM1MaxDeviceTemperature", 36}, + {"TileMinTemperature", 40}, + {"TileMaxTemperature", 44}}}}; + +using IsUnknown = IsProduct; +using SysmanProductHelperPmtTest = ::testing::Test; + +HWTEST2_F(SysmanProductHelperPmtTest, GivenSysmanProductHelperInstanceWhenGetGuidToKeyOffsetMapIsCalledThenValidMapIsReturned, IsDG1) { + auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily); + auto pGuidToKeyOffsetMap = pSysmanProductHelper->getGuidToKeyOffsetMap(); + EXPECT_NE(nullptr, pGuidToKeyOffsetMap); + EXPECT_EQ(mockDg1GuidToKeyOffsetMap.at("0x490e01").at("PACKAGE_ENERGY"), (*pGuidToKeyOffsetMap).at("0x490e01").at("PACKAGE_ENERGY")); + EXPECT_EQ(mockDg1GuidToKeyOffsetMap.at("0x490e01").at("COMPUTE_TEMPERATURES"), (*pGuidToKeyOffsetMap).at("0x490e01").at("COMPUTE_TEMPERATURES")); +} + +HWTEST2_F(SysmanProductHelperPmtTest, GivenSysmanProductHelperInstanceWhenGetGuidToKeyOffsetMapIsCalledThenValidMapIsReturned, IsDG2) { + auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily); + auto pGuidToKeyOffsetMap = pSysmanProductHelper->getGuidToKeyOffsetMap(); + EXPECT_NE(nullptr, pGuidToKeyOffsetMap); + EXPECT_EQ(mockDg2GuidToKeyOffsetMap.at("0x4f95").at("PACKAGE_ENERGY"), (*pGuidToKeyOffsetMap).at("0x4f95").at("PACKAGE_ENERGY")); + EXPECT_EQ(mockDg2GuidToKeyOffsetMap.at("0x4f95").at("SOC_TEMPERATURES"), (*pGuidToKeyOffsetMap).at("0x4f95").at("SOC_TEMPERATURES")); +} + +HWTEST2_F(SysmanProductHelperPmtTest, GivenSysmanProductHelperInstanceWhenGetGuidToKeyOffsetMapIsCalledThenValidMapIsReturned, IsPVC) { + auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily); + auto pGuidToKeyOffsetMap = pSysmanProductHelper->getGuidToKeyOffsetMap(); + EXPECT_NE(nullptr, pGuidToKeyOffsetMap); + EXPECT_EQ(mockPvcGuidToKeyOffsetMap.at("0xb15a0edc").at("HBM0MaxDeviceTemperature"), (*pGuidToKeyOffsetMap).at("0xb15a0edc").at("HBM0MaxDeviceTemperature")); + EXPECT_EQ(mockPvcGuidToKeyOffsetMap.at("0xb15a0edc").at("HBM1MaxDeviceTemperature"), (*pGuidToKeyOffsetMap).at("0xb15a0edc").at("HBM1MaxDeviceTemperature")); + EXPECT_EQ(mockPvcGuidToKeyOffsetMap.at("0xb15a0edc").at("TileMinTemperature"), (*pGuidToKeyOffsetMap).at("0xb15a0edc").at("TileMinTemperature")); + EXPECT_EQ(mockPvcGuidToKeyOffsetMap.at("0xb15a0edc").at("TileMaxTemperature"), (*pGuidToKeyOffsetMap).at("0xb15a0edc").at("TileMaxTemperature")); +} + +HWTEST2_F(SysmanProductHelperPmtTest, GivenSysmanProductHelperInstanceWhenGetGuidToKeyOffsetMapIsCalledForUnsupportedProductThenNullptrIsReturned, IsUnknown) { + auto pSysmanProductHelper = L0::Sysman::SysmanProductHelper::create(defaultHwInfo->platform.eProductFamily); + auto pGuidToKeyOffsetMap = pSysmanProductHelper->getGuidToKeyOffsetMap(); + EXPECT_EQ(nullptr, pGuidToKeyOffsetMap); +} + +} // namespace ult +} // namespace Sysman +} // namespace L0 \ No newline at end of file diff --git a/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_temperature_tests.cpp b/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_temperature_tests.cpp index b853b6393c..211744436f 100644 --- a/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_temperature_tests.cpp +++ b/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_temperature_tests.cpp @@ -1,11 +1,10 @@ /* - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation * * SPDX-License-Identifier: MIT * */ -#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt_xml_offsets.h" #include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper.h" #include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h" #include "level_zero/sysman/test/unit_tests/sources/temperature/linux/mock_sysfs_temperature.h" diff --git a/level_zero/sysman/test/unit_tests/sources/temperature/linux/test_zes_temperature.cpp b/level_zero/sysman/test/unit_tests/sources/temperature/linux/test_zes_temperature.cpp index 670cef5c9f..52816560f5 100644 --- a/level_zero/sysman/test/unit_tests/sources/temperature/linux/test_zes_temperature.cpp +++ b/level_zero/sysman/test/unit_tests/sources/temperature/linux/test_zes_temperature.cpp @@ -1,11 +1,10 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * */ -#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt_xml_offsets.h" #include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h" #include "level_zero/sysman/test/unit_tests/sources/temperature/linux/mock_sysfs_temperature.h" @@ -18,8 +17,20 @@ constexpr uint32_t handleComponentCountForSingleTileDevice = 3u; constexpr uint32_t handleComponentCountForNoSubDevices = 2u; constexpr uint32_t invalidMaxTemperature = 125; constexpr uint32_t invalidMinTemperature = 10; -const std::string sampleGuid1 = "0xb15a0edc"; -const std::string sampleGuid2 = "0x490e01"; + +const std::map mockMap1 = {{"HBM0MaxDeviceTemperature", 28}, + {"HBM1MaxDeviceTemperature", 36}, + {"TileMinTemperature", 40}, + {"TileMaxTemperature", 44}, + {"GTMinTemperature", 48}, + {"GTMaxTemperature", 52}, + {"HBM2MaxDeviceTemperature", 300}, + {"HBM3MaxDeviceTemperature", 308}}; + +const std::map mockMap2 = {{"PACKAGE_ENERGY", 0x420}, + {"COMPUTE_TEMPERATURES", 0x68}, + {"SOC_TEMPERATURES", 0x60}, + {"CORE_TEMPERATURES", 0x6c}}; class SysmanMultiDeviceTemperatureFixture : public SysmanMultiDeviceFixture { protected: @@ -46,8 +57,7 @@ class SysmanMultiDeviceTemperatureFixture : public SysmanMultiDeviceFixture { ze_bool_t onSubdevice = (subDeviceCount == 0) ? false : true; auto pPmt = new MockTemperaturePmt(pFsAccess.get(), onSubdevice, subdeviceId); pPmt->mockedInit(pFsAccess.get()); - auto keyOffsetMapEntry = L0::Sysman::guidToKeyOffsetMap.find(sampleGuid1); - pPmt->keyOffsetMap = keyOffsetMapEntry->second; + pPmt->keyOffsetMap = mockMap1; pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(subdeviceId, pPmt); } while (++subdeviceId < subDeviceCount); getTempHandles(0); @@ -179,8 +189,7 @@ class SysmanDeviceTemperatureFixture : public SysmanDeviceFixture { ze_bool_t onSubdevice = (subDeviceCount == 0) ? false : true; auto pPmt = new MockTemperaturePmt(pFsAccess.get(), onSubdevice, subdeviceId); pPmt->mockedInit(pFsAccess.get()); - auto keyOffsetMapEntry = L0::Sysman::guidToKeyOffsetMap.find(sampleGuid2); - pPmt->keyOffsetMap = keyOffsetMapEntry->second; + pPmt->keyOffsetMap = mockMap2; pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(subdeviceId, pPmt); } while (++subdeviceId < subDeviceCount); getTempHandles(0); @@ -345,9 +354,7 @@ TEST_F(SysmanDeviceTemperatureFixture, GivenValidateEnumerateRootTelemIndexWheng TEST_F(SysmanDeviceTemperatureFixture, GivenValidatePmtReadValueWhenkeyOffsetMapIsNotThereThenFailureReturned) { auto pPmt = std::make_unique(pFsAccess.get(), 0, 0); pPmt->mockedInit(pFsAccess.get()); - // Get keyOffsetMap - auto keyOffsetMapEntry = L0::Sysman::guidToKeyOffsetMap.find(sampleGuid2); - pPmt->keyOffsetMap = keyOffsetMapEntry->second; + pPmt->keyOffsetMap = mockMap2; uint32_t val = 0; EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pPmt->readValue("SOMETHING", val)); }