feature(sysman): Update Power Module to replace CARD domain with PACKAGE domain

Related-To: NEO-13985

Signed-off-by: Anvesh Bakwad <anvesh.bakwad@intel.com>
This commit is contained in:
Anvesh Bakwad
2025-02-06 06:49:40 +00:00
committed by Compute-Runtime-Automation
parent 05977f6158
commit c645f84663
10 changed files with 31 additions and 39 deletions

View File

@@ -57,7 +57,7 @@ ze_result_t LinuxPowerImp::getDefaultLimit(int32_t &defaultLimit) {
}
ze_result_t LinuxPowerImp::getPropertiesExt(zes_power_ext_properties_t *pExtPoperties) {
pExtPoperties->domain = isSubdevice ? ZES_POWER_DOMAIN_PACKAGE : powerDomain;
pExtPoperties->domain = powerDomain;
if (pExtPoperties->defaultLimit) {
if (!isSubdevice) {
uint64_t val = 0;
@@ -184,6 +184,7 @@ ze_result_t LinuxPowerImp::setLimits(const zes_power_sustained_limit_t *pSustain
}
return result;
}
ze_result_t LinuxPowerImp::getEnergyThreshold(zes_energy_threshold_t *pThreshold) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s() returning UNSUPPORTED_FEATURE \n", __FUNCTION__);
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
@@ -340,8 +341,8 @@ LinuxPowerImp::LinuxPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_
pSysmanProductHelper = pLinuxSysmanImp->getSysmanProductHelper();
}
std::vector<zes_power_domain_t> OsPower::getNumberOfPowerDomainsSupported(OsSysman *pOsSysman) {
std::vector<zes_power_domain_t> powerDomains = {ZES_POWER_DOMAIN_CARD};
std::vector<zes_power_domain_t> OsPower::getSupportedPowerDomains(OsSysman *pOsSysman) {
std::vector<zes_power_domain_t> powerDomains = {ZES_POWER_DOMAIN_PACKAGE};
return powerDomains;
}

View File

@@ -56,7 +56,7 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
bool isSubdevice = false;
uint32_t subdeviceId = 0;
uint32_t powerLimitCount = 0;
zes_power_domain_t powerDomain = ZES_POWER_DOMAIN_CARD;
zes_power_domain_t powerDomain = ZES_POWER_DOMAIN_UNKNOWN;
ze_result_t getErrorCode(ze_result_t result) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {

View File

@@ -29,7 +29,7 @@ class OsPower {
virtual bool isPowerModuleSupported() = 0;
static OsPower *create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId, zes_power_domain_t powerDomain);
static std::vector<zes_power_domain_t> getNumberOfPowerDomainsSupported(OsSysman *pOsSysman);
static std::vector<zes_power_domain_t> getSupportedPowerDomains(OsSysman *pOsSysman);
virtual ~OsPower() = default;
};

View File

@@ -35,21 +35,15 @@ void PowerHandleContext::createHandle(ze_bool_t isSubDevice, uint32_t subDeviceI
delete pPower;
}
}
ze_result_t PowerHandleContext::init(uint32_t subDeviceCount) {
auto totalDomains = OsPower::getNumberOfPowerDomainsSupported(pOsSysman);
void PowerHandleContext::init(uint32_t subDeviceCount) {
auto totalDomains = OsPower::getSupportedPowerDomains(pOsSysman);
for (auto &powerDomain : totalDomains) {
createHandle(false, 0, powerDomain);
}
for (uint32_t subDeviceId = 0; subDeviceId < subDeviceCount; subDeviceId++) {
for (auto &powerDomain : totalDomains) {
for (uint32_t subDeviceId = 0; subDeviceId < subDeviceCount; subDeviceId++) {
createHandle(true, subDeviceId, powerDomain);
}
}
return ZE_RESULT_SUCCESS;
}
void PowerHandleContext::initPower() {

View File

@@ -38,7 +38,7 @@ struct PowerHandleContext {
PowerHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
~PowerHandleContext();
ze_result_t init(uint32_t subDeviceCount);
void init(uint32_t subDeviceCount);
ze_result_t powerGet(uint32_t *pCount, zes_pwr_handle_t *phPower);
ze_result_t powerGetCardDomain(zes_pwr_handle_t *phPower);

View File

@@ -68,7 +68,7 @@ PowerImp::PowerImp(OsSysman *pOsSysman, ze_bool_t isSubDevice, uint32_t subDevic
pOsPower = OsPower::create(pOsSysman, isSubDevice, subDeviceId, powerDomain);
UNRECOVERABLE_IF(nullptr == pOsPower);
this->isCardPower = isSubDevice ? false : true;
this->isCardPower = (powerDomain == ZES_POWER_DOMAIN_CARD);
init();
}

View File

@@ -611,7 +611,7 @@ WddmPowerImp::WddmPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t
isPowerHandleEnergyCounterOnly();
}
std::vector<zes_power_domain_t> OsPower::getNumberOfPowerDomainsSupported(OsSysman *pOsSysman) {
std::vector<zes_power_domain_t> OsPower::getSupportedPowerDomains(OsSysman *pOsSysman) {
WddmSysmanImp *pWddmSysmanImp = static_cast<WddmSysmanImp *>(pOsSysman);
KmdSysManager *pKmdSysManager = &pWddmSysmanImp->getKmdSysManager();
KmdSysman::RequestProperty request;

View File

@@ -42,23 +42,22 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenComponentCountZeroWhenEnumeratingPower
}
}
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerPointerWhenGettingCardPowerDomainWhenhwmonInterfaceExistsAndThenCallSucceeds) {
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerPointerWhenGetCardPowerDomainIsCalledThenFailureIsReturned) {
zes_pwr_handle_t phPower = {};
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_SUCCESS);
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
TEST_F(SysmanDevicePowerFixtureI915, GivenInvalidPowerPointerWhenGettingCardPowerDomainAndThenReturnsFailure) {
TEST_F(SysmanDevicePowerFixtureI915, GivenInvalidPowerPointerWhenGetCardPowerDomainIsCalledThenFailureIsReturned) {
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), nullptr), ZE_RESULT_ERROR_INVALID_NULL_POINTER);
}
TEST_F(SysmanDevicePowerFixtureI915, GivenUninitializedPowerHandlesAndWhenGettingCardPowerDomainThenReturnsFailure) {
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
delete handle;
}
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
TEST_F(SysmanDevicePowerFixtureI915, GivenPowerHandlesListContainsCardDomainHandleWhenGetCardPowerDomainIsCalledThenCallSucceeds) {
Power *pPower = new PowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_CARD);
pSysmanDeviceImp->pPowerHandleContext->handleList.push_back(pPower);
zes_pwr_handle_t phPower = {};
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_SUCCESS);
}
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesWhenhwmonInterfaceExistsThenCallSucceeds) {
@@ -118,7 +117,7 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerProper
EXPECT_EQ(properties.defaultLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
EXPECT_EQ(properties.maxLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
EXPECT_EQ(properties.minLimit, -1);
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_CARD);
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_PACKAGE);
EXPECT_TRUE(defaultLimit.limitValueLocked);
EXPECT_TRUE(defaultLimit.enabledStateLocked);
EXPECT_TRUE(defaultLimit.intervalValueLocked);
@@ -180,7 +179,7 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleAndPowerSetLimitSuppor
}
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesAndSysfsReadFailsThenFailureIsReturned) {
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_CARD));
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_PACKAGE));
EXPECT_TRUE(pLinuxPowerImp->isPowerModuleSupported());
pSysfsAccess->mockReadValUnsignedLongResult.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
zes_power_properties_t properties{};

View File

@@ -32,7 +32,7 @@ TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidDeviceHandlesAndHwmo
uint32_t subdeviceId = 0;
do {
ze_bool_t onSubdevice = (subDeviceCount == 0) ? false : true;
PublicLinuxPowerImp *pPowerImp = new PublicLinuxPowerImp(pOsSysman, onSubdevice, subdeviceId, ZES_POWER_DOMAIN_CARD);
PublicLinuxPowerImp *pPowerImp = new PublicLinuxPowerImp(pOsSysman, onSubdevice, subdeviceId, ZES_POWER_DOMAIN_PACKAGE);
EXPECT_TRUE(pPowerImp->isPowerModuleSupported());
delete pPowerImp;
@@ -49,9 +49,9 @@ TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenInvalidComponentCountWhen
EXPECT_EQ(count, powerHandleComponentCountMultiDevice);
}
TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerPointerWhenGettingCardPowerDomainWhenhwmonInterfaceExistsAndThenCallSucceeds) {
TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerPointerWhenGettingCardPowerDomainThenFailureIsReturned) {
zes_pwr_handle_t phPower = {};
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_SUCCESS);
EXPECT_EQ(zesDeviceGetCardPowerDomain(device->toHandle(), &phPower), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerHandleWhenGettingPowerPropertiesThenCallSucceeds) {
@@ -102,13 +102,12 @@ TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerHandleWhenGetti
EXPECT_EQ(defaultLimit.level, ZES_POWER_LEVEL_UNKNOWN);
EXPECT_EQ(defaultLimit.source, ZES_POWER_SOURCE_ANY);
EXPECT_EQ(defaultLimit.limitUnit, ZES_LIMIT_UNIT_POWER);
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_PACKAGE);
if (properties.onSubdevice) {
EXPECT_FALSE(properties.canControl);
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_PACKAGE);
EXPECT_EQ(defaultLimit.limit, -1);
} else {
EXPECT_TRUE(properties.canControl);
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_CARD);
EXPECT_EQ(defaultLimit.limit, static_cast<int32_t>(mockDefaultPowerLimitVal / milliFactor));
EXPECT_EQ(properties.defaultLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
EXPECT_EQ(properties.maxLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
@@ -133,15 +132,14 @@ TEST_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerHandleAndExtPro
properties.pNext = &extProperties;
extProperties.stype = ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetProperties(handle, &properties));
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_PACKAGE);
if (properties.onSubdevice) {
EXPECT_FALSE(properties.canControl);
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_PACKAGE);
EXPECT_EQ(properties.maxLimit, -1);
EXPECT_EQ(properties.minLimit, -1);
EXPECT_EQ(properties.defaultLimit, -1);
} else {
EXPECT_TRUE(properties.canControl);
EXPECT_EQ(extProperties.domain, ZES_POWER_DOMAIN_CARD);
EXPECT_EQ(properties.defaultLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
EXPECT_EQ(properties.maxLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
EXPECT_EQ(properties.minLimit, -1);

View File

@@ -156,7 +156,7 @@ HWTEST2_F(SysmanProductHelperPowerTest, GivenSysfsReadFailsAndKeyOffsetMapNotAva
return count;
});
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_CARD));
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_PACKAGE));
pLinuxPowerImp->isTelemetrySupportAvailable = true;
zes_power_energy_counter_t energyCounter = {};
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, pLinuxPowerImp->getEnergyCounter(&energyCounter));
@@ -188,7 +188,7 @@ HWTEST2_F(SysmanProductHelperPowerTest, GivenSysfsReadFailsAndPmtReadValueFailsW
return count;
});
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_CARD));
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_PACKAGE));
pLinuxPowerImp->isTelemetrySupportAvailable = true;
zes_power_energy_counter_t energyCounter = {};
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pLinuxPowerImp->getEnergyCounter(&energyCounter));
@@ -200,7 +200,7 @@ HWTEST2_F(SysmanProductHelperPowerTest, GivenSysfsReadFailsWhenGettingPowerEnerg
VariableBackup<decltype(NEO::SysCalls::sysCallsOpen)> mockOpen(&NEO::SysCalls::sysCallsOpen, &mockOpenSuccess);
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, &mockReadSuccess);
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_CARD));
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0, ZES_POWER_DOMAIN_PACKAGE));
pLinuxPowerImp->isTelemetrySupportAvailable = true;
zes_power_energy_counter_t energyCounter = {};
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getEnergyCounter(&energyCounter));
@@ -240,7 +240,7 @@ HWTEST2_F(SysmanProductHelperPowerTest, GivenScanDirectoriesFailAndTelemetrySupp
pSysmanDeviceImp->pPowerHandleContext->init(subDeviceCount);
ze_bool_t onSubdevice = (subDeviceCount == 0) ? false : true;
uint32_t subdeviceId = 0;
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, onSubdevice, subdeviceId, ZES_POWER_DOMAIN_CARD));
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, onSubdevice, subdeviceId, ZES_POWER_DOMAIN_PACKAGE));
EXPECT_TRUE(pLinuxPowerImp->isPowerModuleSupported());
}