Support for power limit extensions

Boiler plate implementation of power limit
extension functions.

Related-To: LOCI-3125, LOCI-3193

Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
Bellekallu Rajkiran
2022-07-05 09:48:01 +00:00
committed by Compute-Runtime-Automation
parent 97a3368aad
commit e1ba6d825a
14 changed files with 108 additions and 4 deletions

View File

@@ -373,6 +373,8 @@ zesGetPowerProcAddrTable(
pDdiTable->pfnGetEnergyCounter = L0::zesPowerGetEnergyCounter;
pDdiTable->pfnGetLimits = L0::zesPowerGetLimits;
pDdiTable->pfnSetLimits = L0::zesPowerSetLimits;
pDdiTable->pfnGetLimitsExt = L0::zesPowerGetLimitsExt;
pDdiTable->pfnSetLimitsExt = L0::zesPowerSetLimitsExt;
pDdiTable->pfnGetEnergyThreshold = L0::zesPowerGetEnergyThreshold;
pDdiTable->pfnSetEnergyThreshold = L0::zesPowerSetEnergyThreshold;

View File

@@ -161,6 +161,20 @@ ze_result_t zesPowerSetLimits(
return L0::Power::fromHandle(hPower)->powerSetLimits(pSustained, pBurst, pPeak);
}
ze_result_t zesPowerGetLimitsExt(
zes_pwr_handle_t hPower,
uint32_t *pCount,
zes_power_limit_ext_desc_t *pSustained) {
return L0::Power::fromHandle(hPower)->powerGetLimitsExt(pCount, pSustained);
}
ze_result_t zesPowerSetLimitsExt(
zes_pwr_handle_t hPower,
uint32_t *pCount,
zes_power_limit_ext_desc_t *pSustained) {
return L0::Power::fromHandle(hPower)->powerSetLimitsExt(pCount, pSustained);
}
ze_result_t zesPowerGetEnergyThreshold(
zes_pwr_handle_t hPower,
zes_energy_threshold_t *pThreshold) {
@@ -1352,6 +1366,26 @@ ZE_APIEXPORT ze_result_t ZE_APICALL zesPowerSetLimits(
pPeak);
}
ZE_APIEXPORT ze_result_t ZE_APICALL zesPowerGetLimitsExt(
zes_pwr_handle_t hPower,
uint32_t *pCount,
zes_power_limit_ext_desc_t *pSustained) {
return L0::zesPowerGetLimitsExt(
hPower,
pCount,
pSustained);
}
ZE_APIEXPORT ze_result_t ZE_APICALL zesPowerSetLimitsExt(
zes_pwr_handle_t hPower,
uint32_t *pCount,
zes_power_limit_ext_desc_t *pSustained) {
return L0::zesPowerSetLimitsExt(
hPower,
pCount,
pSustained);
}
ZE_APIEXPORT ze_result_t ZE_APICALL zesPowerGetEnergyThreshold(
zes_pwr_handle_t hPower,
zes_energy_threshold_t *pThreshold) {

View File

@@ -188,6 +188,14 @@ ze_result_t LinuxPowerImp::setEnergyThreshold(double threshold) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxPowerImp::getLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxPowerImp::setLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
bool LinuxPowerImp::isHwmonDir(std::string name) {
if (isSubdevice == false && (name == i915)) {
return true;

View File

@@ -25,6 +25,8 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
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;
ze_result_t getLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) override;
ze_result_t setLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) override;
bool isPowerModuleSupported() override;
bool isHwmonDir(std::string name);

View File

@@ -123,6 +123,14 @@ ze_result_t LinuxPowerImp::setLimits(const zes_power_sustained_limit_t *pSustain
return result;
}
ze_result_t LinuxPowerImp::getLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxPowerImp::setLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxPowerImp::getEnergyThreshold(zes_energy_threshold_t *pThreshold) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

View File

@@ -25,6 +25,8 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
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;
ze_result_t getLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) override;
ze_result_t setLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) override;
bool isPowerModuleSupported() override;
bool isHwmonDir(std::string name);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -20,6 +20,8 @@ class OsPower {
virtual 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) = 0;
virtual ze_result_t getEnergyThreshold(zes_energy_threshold_t *pThreshold) = 0;
virtual ze_result_t setEnergyThreshold(double threshold) = 0;
virtual ze_result_t getLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) = 0;
virtual ze_result_t setLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) = 0;
virtual bool isPowerModuleSupported() = 0;
static OsPower *create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);

View File

@@ -30,6 +30,8 @@ class Power : _zet_sysman_pwr_handle_t, _zes_pwr_handle_t {
virtual ze_result_t powerSetLimits(const zes_power_sustained_limit_t *pSustained, const zes_power_burst_limit_t *pBurst, const zes_power_peak_limit_t *pPeak) = 0;
virtual ze_result_t powerGetEnergyThreshold(zes_energy_threshold_t *pThreshold) = 0;
virtual ze_result_t powerSetEnergyThreshold(double threshold) = 0;
virtual ze_result_t powerGetLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) = 0;
virtual ze_result_t powerSetLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) = 0;
static Power *fromHandle(zes_pwr_handle_t handle) {
return static_cast<Power *>(handle);

View File

@@ -27,6 +27,15 @@ ze_result_t PowerImp::powerGetLimits(zes_power_sustained_limit_t *pSustained, ze
ze_result_t PowerImp::powerSetLimits(const zes_power_sustained_limit_t *pSustained, const zes_power_burst_limit_t *pBurst, const zes_power_peak_limit_t *pPeak) {
return pOsPower->setLimits(pSustained, pBurst, pPeak);
}
ze_result_t PowerImp::powerGetLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
return pOsPower->getLimitsExt(pCount, pSustained);
}
ze_result_t PowerImp::powerSetLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
return pOsPower->setLimitsExt(pCount, pSustained);
}
ze_result_t PowerImp::powerGetEnergyThreshold(zes_energy_threshold_t *pThreshold) {
return pOsPower->getEnergyThreshold(pThreshold);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -21,6 +21,8 @@ class PowerImp : public Power, NEO::NonCopyableOrMovableClass {
ze_result_t powerSetLimits(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 powerGetEnergyThreshold(zes_energy_threshold_t *pThreshold) override;
ze_result_t powerSetEnergyThreshold(double threshold) override;
ze_result_t powerGetLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) override;
ze_result_t powerSetLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) override;
PowerImp() = default;
PowerImp(OsSysman *pOsSysman, ze_device_handle_t device);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -327,6 +327,14 @@ bool WddmPowerImp::isPowerModuleSupported() {
return ((status == ZE_RESULT_SUCCESS) && (enabled));
}
ze_result_t WddmPowerImp::getLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t WddmPowerImp::setLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
WddmPowerImp::WddmPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
WddmSysmanImp *pWddmSysmanImp = static_cast<WddmSysmanImp *>(pOsSysman);
pKmdSysManager = &pWddmSysmanImp->getKmdSysManager();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -21,6 +21,8 @@ class WddmPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
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;
ze_result_t getLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) override;
ze_result_t setLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) override;
bool isPowerModuleSupported() override;
WddmPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);

View File

@@ -645,5 +645,15 @@ TEST_F(SysmanDevicePowerMultiDeviceFixture, GivenValidPowerHandleWhenGettingPowe
}
}
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandlesWhenCallingSetAndGetPowerLimitExtWhenHwmonInterfaceExistThenUnsupportedFeatureIsReturned) {
auto handles = getPowerHandles(powerHandleComponentCount);
for (auto handle : handles) {
uint32_t limitCount = 0;
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimitsExt(handle, &limitCount, nullptr));
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimitsExt(handle, &limitCount, nullptr));
}
}
} // namespace ult
} // namespace L0

View File

@@ -297,5 +297,18 @@ TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenSettingPowerLimitsAllo
}
}
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandlesWhenCallingSetAndGetPowerLimitExtWhenHwmonInterfaceExistThenUnsupportedFeatureIsReturned) {
// Setting allow set calls or not
init(true);
auto handles = get_power_handles(powerHandleComponentCount);
for (auto handle : handles) {
uint32_t limitCount = 0;
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimitsExt(handle, &limitCount, nullptr));
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimitsExt(handle, &limitCount, nullptr));
}
}
} // namespace ult
} // namespace L0