mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
feature(sysman): PowerLimitsExt support in windows zes branch
Related-To: NEO-8808 Signed-off-by: shubham kumar <shubham.kumar@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a67ef72210
commit
a7e0987485
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -288,26 +288,209 @@ ze_result_t WddmPowerImp::setEnergyThreshold(double threshold) {
|
||||
}
|
||||
|
||||
bool WddmPowerImp::isPowerModuleSupported() {
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
powerLimitCount = 0;
|
||||
std::vector<KmdSysman::RequestProperty> vRequests = {};
|
||||
std::vector<KmdSysman::ResponseProperty> vResponses = {};
|
||||
KmdSysman::RequestProperty request = {};
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::PowerLimit1Enabled;
|
||||
vRequests.push_back(request);
|
||||
|
||||
ze_result_t status = pKmdSysManager->requestSingle(request, response);
|
||||
request.requestId = KmdSysman::Requests::Power::PowerLimit2Enabled;
|
||||
vRequests.push_back(request);
|
||||
|
||||
uint32_t enabled = 0;
|
||||
memcpy_s(&enabled, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
|
||||
return ((status == ZE_RESULT_SUCCESS) && (enabled));
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit4Ac;
|
||||
vRequests.push_back(request);
|
||||
|
||||
ze_result_t status = pKmdSysManager->requestMultiple(vRequests, vResponses);
|
||||
|
||||
if ((status != ZE_RESULT_SUCCESS) || (vResponses.size() != vRequests.size())) {
|
||||
return status;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < vResponses.size() - 1; i++) {
|
||||
ze_bool_t enabled = false;
|
||||
if (vResponses[i].returnCode == KmdSysman::Success) {
|
||||
memcpy_s(&enabled, sizeof(ze_bool_t), vResponses[i].dataBuffer, sizeof(ze_bool_t));
|
||||
}
|
||||
if (enabled) {
|
||||
powerLimitCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// CurrentPowerLimit4Ac is not a bool hence check for it individually
|
||||
if (vResponses[2].returnCode == KmdSysman::Success) {
|
||||
powerLimitCount++;
|
||||
}
|
||||
|
||||
if (powerLimitCount > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t WddmPowerImp::getLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
uint8_t count = 0;
|
||||
|
||||
if (*pCount == 0) {
|
||||
*pCount = powerLimitCount;
|
||||
return result;
|
||||
}
|
||||
|
||||
*pCount = std::min(*pCount, powerLimitCount);
|
||||
|
||||
std::vector<KmdSysman::RequestProperty> vRequests = {};
|
||||
std::vector<KmdSysman::ResponseProperty> vResponses = {};
|
||||
KmdSysman::RequestProperty request = {};
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.requestId = KmdSysman::Requests::Power::PowerLimit1Enabled;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1Tau;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::PowerLimit2Enabled;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit2;
|
||||
vRequests.push_back(request);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit4Ac;
|
||||
vRequests.push_back(request);
|
||||
|
||||
ze_result_t status = pKmdSysManager->requestMultiple(vRequests, vResponses);
|
||||
|
||||
if ((status != ZE_RESULT_SUCCESS) || (vResponses.size() != vRequests.size())) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// sustained
|
||||
ze_bool_t enabled = false;
|
||||
|
||||
if (vResponses[0].returnCode == KmdSysman::Success) {
|
||||
memcpy_s(&enabled, sizeof(ze_bool_t), vResponses[0].dataBuffer, sizeof(ze_bool_t));
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
if (vResponses[1].returnCode == KmdSysman::Success && vResponses[2].returnCode == KmdSysman::Success) {
|
||||
memset(&pSustained[count], 0, sizeof(zes_power_limit_ext_desc_t));
|
||||
uint32_t limit = 0;
|
||||
memcpy_s(&limit, sizeof(uint32_t), vResponses[1].dataBuffer, sizeof(uint32_t));
|
||||
|
||||
uint32_t interval = 0;
|
||||
memcpy_s(&interval, sizeof(uint32_t), vResponses[2].dataBuffer, sizeof(uint32_t));
|
||||
|
||||
pSustained[count].enabled = enabled;
|
||||
pSustained[count].limit = limit;
|
||||
pSustained[count].enabledStateLocked = true;
|
||||
pSustained[count].intervalValueLocked = false;
|
||||
pSustained[count].limitValueLocked = false;
|
||||
pSustained[count].source = ZES_POWER_SOURCE_ANY;
|
||||
pSustained[count].level = ZES_POWER_LEVEL_SUSTAINED;
|
||||
pSustained[count].limitUnit = ZES_LIMIT_UNIT_POWER;
|
||||
pSustained[count].interval = interval;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// Burst
|
||||
enabled = false;
|
||||
if (vResponses[3].returnCode == KmdSysman::Success) {
|
||||
memcpy_s(&enabled, sizeof(ze_bool_t), vResponses[3].dataBuffer, sizeof(ze_bool_t));
|
||||
}
|
||||
|
||||
if (count < *pCount && enabled) {
|
||||
if (vResponses[4].returnCode == KmdSysman::Success) {
|
||||
uint32_t limit = 0;
|
||||
memset(&pSustained[count], 0, sizeof(zes_power_limit_ext_desc_t));
|
||||
memcpy_s(&limit, sizeof(uint32_t), vResponses[4].dataBuffer, sizeof(uint32_t));
|
||||
|
||||
pSustained[count].enabled = enabled;
|
||||
pSustained[count].limit = limit;
|
||||
pSustained[count].enabledStateLocked = true;
|
||||
pSustained[count].intervalValueLocked = true;
|
||||
pSustained[count].limitValueLocked = false;
|
||||
pSustained[count].source = ZES_POWER_SOURCE_ANY;
|
||||
pSustained[count].level = ZES_POWER_LEVEL_BURST;
|
||||
pSustained[count].limitUnit = ZES_LIMIT_UNIT_POWER;
|
||||
pSustained[count].interval = 0;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
// Peak
|
||||
if (count < *pCount) {
|
||||
if (vResponses[5].returnCode == KmdSysman::Success) {
|
||||
uint32_t powerAC = 0;
|
||||
memset(&pSustained[count], 0, sizeof(zes_power_limit_ext_desc_t));
|
||||
memcpy_s(&powerAC, sizeof(uint32_t), vResponses[5].dataBuffer, sizeof(uint32_t));
|
||||
pSustained[count].enabled = true;
|
||||
pSustained[count].limit = powerAC;
|
||||
pSustained[count].enabledStateLocked = true;
|
||||
pSustained[count].intervalValueLocked = true;
|
||||
pSustained[count].limitValueLocked = false;
|
||||
pSustained[count].source = ZES_POWER_SOURCE_ANY;
|
||||
pSustained[count].level = ZES_POWER_LEVEL_PEAK;
|
||||
pSustained[count].limitUnit = ZES_LIMIT_UNIT_POWER;
|
||||
pSustained[count].interval = 0;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
*pCount = count;
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t WddmPowerImp::setLimitsExt(uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
ze_result_t status = ZE_RESULT_SUCCESS;
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
|
||||
request.commandId = KmdSysman::Command::Set;
|
||||
request.componentId = KmdSysman::Component::PowerComponent;
|
||||
request.dataSize = sizeof(uint32_t);
|
||||
|
||||
for (uint32_t i = 0; i < *pCount; i++) {
|
||||
if (pSustained[i].level == ZES_POWER_LEVEL_SUSTAINED) {
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1;
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &pSustained[i].limit, sizeof(uint32_t));
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit1Tau;
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &pSustained[i].interval, sizeof(uint32_t));
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
} else if (pSustained[i].level == ZES_POWER_LEVEL_BURST) {
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit2;
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &pSustained[i].limit, sizeof(uint32_t));
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
} else if (pSustained[i].level == ZES_POWER_LEVEL_PEAK) {
|
||||
request.requestId = KmdSysman::Requests::Power::CurrentPowerLimit4Ac;
|
||||
memcpy_s(request.dataBuffer, sizeof(uint32_t), &pSustained[i].limit, sizeof(uint32_t));
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
WddmPowerImp::WddmPowerImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -32,6 +32,7 @@ class WddmPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
|
||||
|
||||
protected:
|
||||
KmdSysManager *pKmdSysManager = nullptr;
|
||||
uint32_t powerLimitCount = 0;
|
||||
};
|
||||
|
||||
} // namespace Sysman
|
||||
|
||||
Reference in New Issue
Block a user