mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 16:45:25 +08:00
Update power control/query interface
Add support for getCardPowerDomain API. Modify check to verify whether hwmon dir exists. Modify ULTs to verify updated power interface. Update power control/query interface. Related-To: LOCI-2735, LOCI-3046 Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d797d79f97
commit
cee2051db8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -57,6 +57,7 @@ zesGetDeviceProcAddrTable(
|
||||
pDdiTable->pfnEnumMemoryModules = zesDeviceEnumMemoryModules;
|
||||
pDdiTable->pfnEnumPerformanceFactorDomains = zesDeviceEnumPerformanceFactorDomains;
|
||||
pDdiTable->pfnEnumPowerDomains = zesDeviceEnumPowerDomains;
|
||||
pDdiTable->pfnGetCardPowerDomain = zesDeviceGetCardPowerDomain;
|
||||
pDdiTable->pfnEnumPsus = zesDeviceEnumPsus;
|
||||
pDdiTable->pfnEnumRasErrorSets = zesDeviceEnumRasErrorSets;
|
||||
pDdiTable->pfnEnumSchedulers = zesDeviceEnumSchedulers;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -141,6 +141,13 @@ zesDeviceEnumPowerDomains(
|
||||
return L0::SysmanDevice::powerGet(hDevice, pCount, phPower);
|
||||
}
|
||||
|
||||
ZE_APIEXPORT ze_result_t ZE_APICALL
|
||||
zesDeviceGetCardPowerDomain(
|
||||
zes_device_handle_t hDevice,
|
||||
zes_pwr_handle_t *phPower) {
|
||||
return L0::SysmanDevice::powerGetCardDomain(hDevice, phPower);
|
||||
}
|
||||
|
||||
ZE_APIEXPORT ze_result_t ZE_APICALL
|
||||
zesPowerGetProperties(
|
||||
zes_pwr_handle_t hPower,
|
||||
|
||||
@@ -6,17 +6,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
|
||||
)
|
||||
|
||||
if(NEO_ENABLE_i915_PRELIM_DETECTION)
|
||||
list(APPEND L0_SRCS_TOOLS_SYSMAN_POWER_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_power_helper_prelim.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_power_imp_prelim.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_power_imp_prelim.h
|
||||
|
||||
)
|
||||
else()
|
||||
list(APPEND L0_SRCS_TOOLS_SYSMAN_POWER_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_power_helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_power_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_power_imp.h
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/sysman/power/linux/os_power_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
bool LinuxPowerImp::isEnergyHwmonDir(std::string name) {
|
||||
if (isSubdevice == false && (name == i915)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -61,14 +61,15 @@ ze_result_t LinuxPowerImp::getProperties(zes_power_properties_t *pProperties) {
|
||||
ze_result_t LinuxPowerImp::getPmtEnergyCounter(zes_power_energy_counter_t *pEnergy) {
|
||||
const std::string key("PACKAGE_ENERGY");
|
||||
uint64_t energy = 0;
|
||||
constexpr uint64_t fixedPointToJoule = 1048576;
|
||||
ze_result_t result = pPmt->readValue(key, energy);
|
||||
// PMT will return energy counter in Q20 format(fixed point representation) where first 20 bits(from LSB) represent decimal part and remaining integral part which is converted into joule by division with 1048576(2^20) and then converted into microjoules
|
||||
pEnergy->energy = (energy / 1048576) * convertJouleToMicroJoule;
|
||||
pEnergy->energy = (energy / fixedPointToJoule) * convertJouleToMicroJoule;
|
||||
return result;
|
||||
}
|
||||
ze_result_t LinuxPowerImp::getEnergyCounter(zes_power_energy_counter_t *pEnergy) {
|
||||
powerGetTimestamp(pEnergy->timestamp);
|
||||
ze_result_t result = pSysfsAccess->read(energyHwmonDir + "/" + energyCounterNode, pEnergy->energy);
|
||||
ze_result_t result = pSysfsAccess->read(i915HwmonDir + "/" + energyCounterNode, pEnergy->energy);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
if (pPmt != nullptr) {
|
||||
return getPmtEnergyCounter(pEnergy);
|
||||
@@ -187,6 +188,13 @@ ze_result_t LinuxPowerImp::setEnergyThreshold(double threshold) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
bool LinuxPowerImp::isHwmonDir(std::string name) {
|
||||
if (isSubdevice == false && (name == i915)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LinuxPowerImp::isPowerModuleSupported() {
|
||||
std::vector<std::string> listOfAllHwmonDirs = {};
|
||||
bool hwmonDirExists = false;
|
||||
@@ -199,14 +207,11 @@ bool LinuxPowerImp::isPowerModuleSupported() {
|
||||
if (ZE_RESULT_SUCCESS != pSysfsAccess->read(i915NameFile, name)) {
|
||||
continue;
|
||||
}
|
||||
if (name == i915) {
|
||||
if (isHwmonDir(name)) {
|
||||
i915HwmonDir = hwmonDir + "/" + tempHwmonDirEntry;
|
||||
hwmonDirExists = true;
|
||||
canControl = true;
|
||||
}
|
||||
if (isEnergyHwmonDir(name) == true) {
|
||||
energyHwmonDir = hwmonDir + "/" + tempHwmonDirEntry;
|
||||
}
|
||||
}
|
||||
if (hwmonDirExists == false) {
|
||||
return (pPmt != nullptr);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -27,7 +27,7 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
||||
ze_result_t setEnergyThreshold(double threshold) override;
|
||||
|
||||
bool isPowerModuleSupported() override;
|
||||
bool isEnergyHwmonDir(std::string name);
|
||||
bool isHwmonDir(std::string name);
|
||||
ze_result_t getPmtEnergyCounter(zes_power_energy_counter_t *pEnergy);
|
||||
LinuxPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
||||
LinuxPowerImp() = default;
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/sysman/power/linux/os_power_imp_prelim.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/linux/pmt/pmt.h"
|
||||
#include "level_zero/tools/source/sysman/sysman_const.h"
|
||||
|
||||
#include "sysman/linux/os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
const std::string LinuxPowerImp::hwmonDir("device/hwmon");
|
||||
const std::string LinuxPowerImp::i915("i915");
|
||||
const std::string LinuxPowerImp::sustainedPowerLimit("power1_max");
|
||||
const std::string LinuxPowerImp::criticalPowerLimit("power1_crit");
|
||||
const std::string LinuxPowerImp::energyCounterNode("energy1_input");
|
||||
const std::string LinuxPowerImp::defaultPowerLimit("power1_max_default");
|
||||
|
||||
void powerGetTimestamp(uint64_t ×tamp) {
|
||||
std::chrono::time_point<std::chrono::steady_clock> ts = std::chrono::steady_clock::now();
|
||||
timestamp = std::chrono::duration_cast<std::chrono::microseconds>(ts.time_since_epoch()).count();
|
||||
}
|
||||
|
||||
ze_result_t LinuxPowerImp::getProperties(zes_power_properties_t *pProperties) {
|
||||
pProperties->onSubdevice = isSubdevice;
|
||||
pProperties->subdeviceId = subdeviceId;
|
||||
pProperties->canControl = canControl;
|
||||
pProperties->isEnergyThresholdSupported = false;
|
||||
pProperties->defaultLimit = -1;
|
||||
pProperties->minLimit = -1;
|
||||
pProperties->maxLimit = -1;
|
||||
if (!isSubdevice) {
|
||||
uint32_t val = 0;
|
||||
auto result = pSysfsAccess->read(i915HwmonDir + "/" + defaultPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS == result) {
|
||||
pProperties->defaultLimit = static_cast<int32_t>(val / milliFactor); // need to convert from microwatt to milliwatt
|
||||
}
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t LinuxPowerImp::getPmtEnergyCounter(zes_power_energy_counter_t *pEnergy) {
|
||||
const std::string key("PACKAGE_ENERGY");
|
||||
uint64_t energy = 0;
|
||||
constexpr uint64_t fixedPointToJoule = 1048576;
|
||||
ze_result_t result = pPmt->readValue(key, energy);
|
||||
// PMT will return energy counter in Q20 format(fixed point representation) where first 20 bits(from LSB) represent decimal part and remaining integral part which is converted into joule by division with 1048576(2^20) and then converted into microjoules
|
||||
pEnergy->energy = (energy / fixedPointToJoule) * convertJouleToMicroJoule;
|
||||
return result;
|
||||
}
|
||||
ze_result_t LinuxPowerImp::getEnergyCounter(zes_power_energy_counter_t *pEnergy) {
|
||||
powerGetTimestamp(pEnergy->timestamp);
|
||||
ze_result_t result = pSysfsAccess->read(i915HwmonDir + "/" + energyCounterNode, pEnergy->energy);
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
if (pPmt != nullptr) {
|
||||
return getPmtEnergyCounter(pEnergy);
|
||||
}
|
||||
}
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return getErrorCode(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t LinuxPowerImp::getLimits(zes_power_sustained_limit_t *pSustained, zes_power_burst_limit_t *pBurst, zes_power_peak_limit_t *pPeak) {
|
||||
ze_result_t result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
if (!isSubdevice) {
|
||||
uint64_t val = 0;
|
||||
if (pSustained != nullptr) {
|
||||
val = 0;
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + sustainedPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
return getErrorCode(result);
|
||||
}
|
||||
val /= milliFactor; // Convert microWatts to milliwatts
|
||||
pSustained->power = static_cast<int32_t>(val);
|
||||
pSustained->enabled = true;
|
||||
pSustained->interval = -1;
|
||||
}
|
||||
if (pBurst != nullptr) {
|
||||
pBurst->power = -1;
|
||||
pBurst->enabled = false;
|
||||
}
|
||||
if (pPeak != nullptr) {
|
||||
result = pSysfsAccess->read(i915HwmonDir + "/" + criticalPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
return getErrorCode(result);
|
||||
}
|
||||
val /= milliFactor; // Convert microWatts to milliwatts
|
||||
pPeak->powerAC = static_cast<int32_t>(val);
|
||||
pPeak->powerDC = -1;
|
||||
}
|
||||
result = ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t LinuxPowerImp::setLimits(const zes_power_sustained_limit_t *pSustained, const zes_power_burst_limit_t *pBurst, const zes_power_peak_limit_t *pPeak) {
|
||||
ze_result_t result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
if (!isSubdevice) {
|
||||
int32_t val = 0;
|
||||
if (pSustained != nullptr) {
|
||||
val = static_cast<uint32_t>(pSustained->power) * milliFactor; // Convert milliWatts to microwatts
|
||||
result = pSysfsAccess->write(i915HwmonDir + "/" + sustainedPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
return getErrorCode(result);
|
||||
}
|
||||
}
|
||||
if (pPeak != nullptr) {
|
||||
val = static_cast<uint32_t>(pPeak->powerAC) * milliFactor; // Convert milliWatts to microwatts
|
||||
result = pSysfsAccess->write(i915HwmonDir + "/" + criticalPowerLimit, val);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
return getErrorCode(result);
|
||||
}
|
||||
}
|
||||
result = ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t LinuxPowerImp::getEnergyThreshold(zes_energy_threshold_t *pThreshold) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t LinuxPowerImp::setEnergyThreshold(double threshold) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
// 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::isHwmonDir(std::string name) {
|
||||
if (isSubdevice == true) {
|
||||
if (name == (i915 + "_gt" + std::to_string(subdeviceId))) {
|
||||
return true;
|
||||
}
|
||||
} else if (name == i915) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LinuxPowerImp::isPowerModuleSupported() {
|
||||
std::vector<std::string> listOfAllHwmonDirs = {};
|
||||
bool hwmonDirExists = false;
|
||||
if (ZE_RESULT_SUCCESS != pSysfsAccess->scanDirEntries(hwmonDir, listOfAllHwmonDirs)) {
|
||||
hwmonDirExists = false;
|
||||
}
|
||||
for (const auto &tempHwmonDirEntry : listOfAllHwmonDirs) {
|
||||
const std::string i915NameFile = hwmonDir + "/" + tempHwmonDirEntry + "/" + "name";
|
||||
std::string name;
|
||||
if (ZE_RESULT_SUCCESS != pSysfsAccess->read(i915NameFile, name)) {
|
||||
continue;
|
||||
}
|
||||
if (isHwmonDir(name)) {
|
||||
i915HwmonDir = hwmonDir + "/" + tempHwmonDirEntry;
|
||||
hwmonDirExists = true;
|
||||
canControl = isSubdevice ? false : true;
|
||||
}
|
||||
}
|
||||
if (hwmonDirExists == false) {
|
||||
return (pPmt != nullptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
LinuxPowerImp::LinuxPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
|
||||
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||
pPmt = pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId);
|
||||
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
}
|
||||
|
||||
OsPower *OsPower::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
||||
LinuxPowerImp *pLinuxPowerImp = new LinuxPowerImp(pOsSysman, onSubdevice, subdeviceId);
|
||||
return static_cast<OsPower *>(pLinuxPowerImp);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/power/os_power.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class SysfsAccess;
|
||||
class PlatformMonitoringTech;
|
||||
class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
ze_result_t getProperties(zes_power_properties_t *pProperties) override;
|
||||
ze_result_t getEnergyCounter(zes_power_energy_counter_t *pEnergy) override;
|
||||
ze_result_t getLimits(zes_power_sustained_limit_t *pSustained, zes_power_burst_limit_t *pBurst, zes_power_peak_limit_t *pPeak) override;
|
||||
ze_result_t setLimits(const zes_power_sustained_limit_t *pSustained, const zes_power_burst_limit_t *pBurst, const zes_power_peak_limit_t *pPeak) override;
|
||||
ze_result_t getEnergyThreshold(zes_energy_threshold_t *pThreshold) override;
|
||||
ze_result_t setEnergyThreshold(double threshold) override;
|
||||
|
||||
bool isPowerModuleSupported() override;
|
||||
bool isHwmonDir(std::string name);
|
||||
ze_result_t getPmtEnergyCounter(zes_power_energy_counter_t *pEnergy);
|
||||
LinuxPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
|
||||
LinuxPowerImp() = default;
|
||||
~LinuxPowerImp() override = default;
|
||||
|
||||
protected:
|
||||
PlatformMonitoringTech *pPmt = nullptr;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
|
||||
private:
|
||||
std::string i915HwmonDir;
|
||||
static const std::string hwmonDir;
|
||||
static const std::string i915;
|
||||
static const std::string sustainedPowerLimit;
|
||||
static const std::string criticalPowerLimit;
|
||||
static const std::string energyCounterNode;
|
||||
static const std::string defaultPowerLimit;
|
||||
bool canControl = false;
|
||||
bool isSubdevice = false;
|
||||
uint32_t subdeviceId = 0;
|
||||
|
||||
ze_result_t getErrorCode(ze_result_t result) {
|
||||
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
|
||||
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
} // namespace L0
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -28,7 +28,7 @@ void PowerHandleContext::createHandle(ze_device_handle_t deviceHandle) {
|
||||
}
|
||||
}
|
||||
ze_result_t PowerHandleContext::init(std::vector<ze_device_handle_t> &deviceHandles, ze_device_handle_t coreDevice) {
|
||||
// Create Handle for device level power
|
||||
// Create Handle for card level power
|
||||
if (deviceHandles.size() > 1) {
|
||||
createHandle(coreDevice);
|
||||
}
|
||||
@@ -53,4 +53,18 @@ ze_result_t PowerHandleContext::powerGet(uint32_t *pCount, zes_pwr_handle_t *phP
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t PowerHandleContext::powerGetCardDomain(zes_pwr_handle_t *phPower) {
|
||||
if (nullptr == phPower) {
|
||||
return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < handleList.size(); i++) {
|
||||
if (handleList[i]->isCardPower) {
|
||||
*phPower = handleList[i]->toHandle();
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
}
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -36,6 +36,7 @@ class Power : _zet_sysman_pwr_handle_t, _zes_pwr_handle_t {
|
||||
}
|
||||
inline zes_pwr_handle_t toHandle() { return this; }
|
||||
bool initSuccess = false;
|
||||
bool isCardPower = false;
|
||||
zes_power_properties_t powerProperties = {};
|
||||
};
|
||||
struct PowerHandleContext {
|
||||
@@ -44,6 +45,7 @@ struct PowerHandleContext {
|
||||
|
||||
ze_result_t init(std::vector<ze_device_handle_t> &deviceHandles, ze_device_handle_t coreDevice);
|
||||
ze_result_t powerGet(uint32_t *pCount, zes_pwr_handle_t *phPower);
|
||||
ze_result_t powerGetCardDomain(zes_pwr_handle_t *phPower);
|
||||
|
||||
OsSysman *pOsSysman = nullptr;
|
||||
std::vector<Power *> handleList = {};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -47,6 +47,7 @@ void PowerImp::init() {
|
||||
if (pOsPower->isPowerModuleSupported()) {
|
||||
pOsPower->getProperties(&powerProperties);
|
||||
this->initSuccess = true;
|
||||
this->isCardPower = powerProperties.onSubdevice ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -115,6 +115,14 @@ ze_result_t SysmanDevice::powerGet(zes_device_handle_t hDevice, uint32_t *pCount
|
||||
return pSysmanDevice->powerGet(pCount, phPower);
|
||||
}
|
||||
|
||||
ze_result_t SysmanDevice::powerGetCardDomain(zes_device_handle_t hDevice, zes_pwr_handle_t *phPower) {
|
||||
auto pSysmanDevice = L0::SysmanDevice::fromHandle(hDevice);
|
||||
if (pSysmanDevice == nullptr) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
return pSysmanDevice->powerGetCardDomain(phPower);
|
||||
}
|
||||
|
||||
ze_result_t SysmanDevice::frequencyGet(zes_device_handle_t hDevice, uint32_t *pCount, zes_freq_handle_t *phFrequency) {
|
||||
auto pSysmanDevice = L0::SysmanDevice::fromHandle(hDevice);
|
||||
if (pSysmanDevice == nullptr) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -33,6 +33,7 @@ struct SysmanDevice : _ze_device_handle_t {
|
||||
static SysmanDevice *fromHandle(zes_device_handle_t handle) { return Device::fromHandle(handle)->getSysmanHandle(); }
|
||||
static ze_result_t performanceGet(zes_device_handle_t hDevice, uint32_t *pCount, zes_perf_handle_t *phPerformance);
|
||||
static ze_result_t powerGet(zes_device_handle_t hDevice, uint32_t *pCount, zes_pwr_handle_t *phPower);
|
||||
static ze_result_t powerGetCardDomain(zes_device_handle_t hDevice, zes_pwr_handle_t *phPower);
|
||||
static ze_result_t frequencyGet(zes_device_handle_t hDevice, uint32_t *pCount, zes_freq_handle_t *phFrequency);
|
||||
static ze_result_t fabricPortGet(zes_device_handle_t hDevice, uint32_t *pCount, zes_fabric_port_handle_t *phPort);
|
||||
static ze_result_t temperatureGet(zes_device_handle_t hDevice, uint32_t *pCount, zes_temp_handle_t *phTemperature);
|
||||
@@ -57,6 +58,7 @@ struct SysmanDevice : _ze_device_handle_t {
|
||||
|
||||
virtual ze_result_t performanceGet(uint32_t *pCount, zes_perf_handle_t *phPerformance) = 0;
|
||||
virtual ze_result_t powerGet(uint32_t *pCount, zes_pwr_handle_t *phPower) = 0;
|
||||
virtual ze_result_t powerGetCardDomain(zes_pwr_handle_t *phPower) = 0;
|
||||
virtual ze_result_t frequencyGet(uint32_t *pCount, zes_freq_handle_t *phFrequency) = 0;
|
||||
virtual ze_result_t fabricPortGet(uint32_t *pCount, zes_fabric_port_handle_t *phPort) = 0;
|
||||
virtual ze_result_t temperatureGet(uint32_t *pCount, zes_temp_handle_t *phTemperature) = 0;
|
||||
|
||||
@@ -189,6 +189,10 @@ ze_result_t SysmanDeviceImp::pciGetStats(zes_pci_stats_t *pStats) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t SysmanDeviceImp::powerGetCardDomain(zes_pwr_handle_t *phPower) {
|
||||
return pPowerHandleContext->powerGetCardDomain(phPower);
|
||||
}
|
||||
|
||||
ze_result_t SysmanDeviceImp::powerGet(uint32_t *pCount, zes_pwr_handle_t *phPower) {
|
||||
return pPowerHandleContext->powerGet(pCount, phPower);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ struct SysmanDeviceImp : SysmanDevice, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
ze_result_t performanceGet(uint32_t *pCount, zes_perf_handle_t *phPerformance) override;
|
||||
ze_result_t powerGet(uint32_t *pCount, zes_pwr_handle_t *phPower) override;
|
||||
ze_result_t powerGetCardDomain(zes_pwr_handle_t *phPower) override;
|
||||
ze_result_t frequencyGet(uint32_t *pCount, zes_freq_handle_t *phFrequency) override;
|
||||
ze_result_t fabricPortGet(uint32_t *pCount, zes_fabric_port_handle_t *phPort) override;
|
||||
ze_result_t temperatureGet(uint32_t *pCount, zes_temp_handle_t *phTemperature) override;
|
||||
|
||||
@@ -125,6 +125,8 @@ TEST_F(SysmanDeviceFixture, GivenValidDeviceHandleAndIfSysmanDeviceInitFailsThen
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDevicePciGetStats(hSysman, &pciStats));
|
||||
zes_event_type_flags_t events = ZES_EVENT_TYPE_FLAG_DEVICE_DETACH;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceEventRegister(hSysman, events));
|
||||
zes_pwr_handle_t phPower = {};
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceGetCardPowerDomain(hSysman, &phPower));
|
||||
static_cast<DeviceImp *>(device)->setSysmanHandle(pSysmanDeviceOriginal);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
|
||||
set(L0_TESTS_TOOLS_SYSMAN_POWER_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_power.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_power.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_sysfs_power_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_zes_power_helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}test_zes_power.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}mock_sysfs_power.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}test_zes_power_helper.cpp
|
||||
)
|
||||
|
||||
if((NEO_ENABLE_i915_PRELIM_DETECTION) AND ("${BRANCH_TYPE}" STREQUAL ""))
|
||||
list(REMOVE_ITEM L0_TESTS_TOOLS_SYSMAN_POWER_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_power_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_power_helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_power.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_power.h
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -66,6 +66,25 @@ TEST_F(SysmanDevicePowerFixture, GivenComponentCountZeroWhenEnumeratingPowerDoma
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerPointerWhenGettingCardPowerDomainWhenhwmonInterfaceExistsAndThenCallSucceds) {
|
||||
zes_pwr_handle_t phPower = {};
|
||||
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenInvalidPowerPointerWhenGettingCardPowerDomainAndThenReturnsFailure) {
|
||||
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), nullptr), ZE_RESULT_ERROR_INVALID_NULL_POINTER);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenUninitializedPowerHandlesAndWhenGettingCardPowerDomainThenReurnsFailure) {
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
|
||||
zes_pwr_handle_t phPower = {};
|
||||
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerPropertiesWhenhwmonInterfaceExistsThenCallSucceeds) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
@@ -529,6 +548,27 @@ TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyThre
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenScanDiectoriesFailAndPmtIsNullWhenGettingCardPowerThenReturnsFailure) {
|
||||
|
||||
EXPECT_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillRepeatedly(Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
for (auto &pmtMapElement : pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject) {
|
||||
if (pmtMapElement.second) {
|
||||
delete pmtMapElement.second;
|
||||
pmtMapElement.second = nullptr;
|
||||
}
|
||||
}
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init(deviceHandles, device->toHandle());
|
||||
|
||||
zes_pwr_handle_t phPower = {};
|
||||
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenSettingPowerEnergyThresholdThenUnsupportedFeatureErrorIsReturned) {
|
||||
EXPECT_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillRepeatedly(Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -35,5 +35,30 @@ TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidDeviceHandlesAndHwmo
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerPointerWhenGettingCardPowerDomainWhenhwmonInterfaceExistsAndThenCallSucceds) {
|
||||
zes_pwr_handle_t phPower = {};
|
||||
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenScanDiectoriesFailAndPmtIsNullForSubDeviceZeroWhenGettingCardPowerThenReturnsFailure) {
|
||||
|
||||
EXPECT_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillRepeatedly(Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
for (auto &pmtMapElement : pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject) {
|
||||
if (pmtMapElement.first == 0) {
|
||||
delete pmtMapElement.second;
|
||||
pmtMapElement.second = nullptr;
|
||||
}
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->init(deviceHandles, device->toHandle());
|
||||
|
||||
zes_pwr_handle_t phPower = {};
|
||||
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
Reference in New Issue
Block a user