fix: Synchronize power property retrievals

Related-To: NEO-10525

Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
Bellekallu Rajkiran
2024-02-28 10:18:27 +00:00
committed by Compute-Runtime-Automation
parent 588921ed9b
commit a023b40c90
6 changed files with 71 additions and 6 deletions

View File

@@ -42,6 +42,10 @@ class LinuxPowerImp::PowerLimitRestorer : NEO::NonCopyableOrMovableClass {
uint64_t powerLimitValue = 0;
};
std::unique_lock<std::mutex> LinuxPowerImp::obtainMutex() {
return std::unique_lock<std::mutex>(this->powerLimitMutex);
}
ze_result_t LinuxPowerImp::getProperties(zes_power_properties_t *pProperties) {
pProperties->onSubdevice = isSubdevice;
pProperties->subdeviceId = subdeviceId;
@@ -60,6 +64,7 @@ ze_result_t LinuxPowerImp::getProperties(zes_power_properties_t *pProperties) {
return result;
}
auto lock = this->obtainMutex();
auto powerLimitRestorer = L0::Sysman::LinuxPowerImp::PowerLimitRestorer(pSysfsAccess, sustainedPowerLimit);
if (powerLimitRestorer != ZE_RESULT_SUCCESS) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read %s and returning error:0x%x \n", __FUNCTION__, sustainedPowerLimit.c_str(), getErrorCode(powerLimitRestorer));

View File

@@ -11,6 +11,7 @@
#include "level_zero/sysman/source/api/power/sysman_os_power.h"
#include <memory>
#include <mutex>
#include <string>
namespace L0 {
@@ -44,12 +45,14 @@ class LinuxPowerImp : public OsPower, NEO::NonCopyableOrMovableClass {
SysFsAccessInterface *pSysfsAccess = nullptr;
SysmanKmdInterface *pSysmanKmdInterface = nullptr;
SysmanProductHelper *pSysmanProductHelper = nullptr;
virtual std::unique_lock<std::mutex> obtainMutex();
private:
std::string intelGraphicsHwmonDir = {};
std::string criticalPowerLimit = {};
std::string sustainedPowerLimit = {};
std::string sustainedPowerLimitInterval = {};
std::mutex powerLimitMutex{};
bool canControl = false;
bool isSubdevice = false;
uint32_t subdeviceId = 0;