Files
compute-runtime/level_zero/tools/source/sysman/power/power.cpp
Mayank Raghuwanshi e1ad48ccb5 Pass device handles to sysman power module
Signed-off-by: Mayank Raghuwanshi <mayank.raghuwanshi@intel.com>
2021-10-05 20:47:21 +02:00

52 lines
1.3 KiB
C++

/*
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/sysman/power/power.h"
#include "shared/source/helpers/basic_math.h"
#include "level_zero/tools/source/sysman/power/power_imp.h"
namespace L0 {
PowerHandleContext::~PowerHandleContext() {
for (Power *pPower : handleList) {
delete pPower;
}
}
void PowerHandleContext::createHandle(ze_device_handle_t deviceHandle) {
Power *pPower = new PowerImp(pOsSysman, deviceHandle);
if (pPower->initSuccess == true) {
handleList.push_back(pPower);
} else {
delete pPower;
}
}
ze_result_t PowerHandleContext::init(std::vector<ze_device_handle_t> &deviceHandles) {
for (const auto &deviceHandle : deviceHandles) {
createHandle(deviceHandle);
}
return ZE_RESULT_SUCCESS;
}
ze_result_t PowerHandleContext::powerGet(uint32_t *pCount, zes_pwr_handle_t *phPower) {
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
uint32_t numToCopy = std::min(*pCount, handleListSize);
if (0 == *pCount || *pCount > handleListSize) {
*pCount = handleListSize;
}
if (nullptr != phPower) {
for (uint32_t i = 0; i < numToCopy; i++) {
phPower[i] = handleList[i]->toHandle();
}
}
return ZE_RESULT_SUCCESS;
}
} // namespace L0