mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 09:58:55 +08:00
Added support for the Performance APIs in the new sysman design. Added ULTs for the Performance APIs in the new sysman design. In the black box test for performance, the API to compute the number of sub devices has been changed in order to get the sub device count regardless of the sysman initialization using zeInit or zesInit. Related-To: LOCI-4294 Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
73 lines
2.1 KiB
C++
73 lines
2.1 KiB
C++
/*
|
|
* Copyright (C) 2023 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "level_zero/sysman/source/performance/performance.h"
|
|
|
|
#include "level_zero/sysman/source/os_sysman.h"
|
|
#include "level_zero/sysman/source/performance/performance_imp.h"
|
|
|
|
#include <algorithm>
|
|
|
|
namespace L0 {
|
|
namespace Sysman {
|
|
|
|
PerformanceHandleContext::~PerformanceHandleContext() {
|
|
for (auto &pPerformance : handleList) {
|
|
if (pPerformance) {
|
|
delete pPerformance;
|
|
pPerformance = nullptr;
|
|
}
|
|
handleList.pop_back();
|
|
}
|
|
}
|
|
|
|
void PerformanceHandleContext::createHandle(bool onSubdevice, uint32_t subDeviceId, zes_engine_type_flag_t domain) {
|
|
Performance *pPerformance = new PerformanceImp(pOsSysman, onSubdevice, subDeviceId, domain);
|
|
if (pPerformance->isPerformanceEnabled == true) {
|
|
handleList.push_back(pPerformance);
|
|
} else {
|
|
delete pPerformance;
|
|
}
|
|
}
|
|
|
|
ze_result_t PerformanceHandleContext::init(uint32_t subDeviceCount) {
|
|
|
|
if (subDeviceCount > 0) {
|
|
for (uint32_t subDeviceId = 0; subDeviceId < subDeviceCount; subDeviceId++) {
|
|
createHandle(true, subDeviceId, ZES_ENGINE_TYPE_FLAG_MEDIA);
|
|
createHandle(true, subDeviceId, ZES_ENGINE_TYPE_FLAG_COMPUTE);
|
|
}
|
|
|
|
} else {
|
|
createHandle(false, 0, ZES_ENGINE_TYPE_FLAG_MEDIA);
|
|
createHandle(false, 0, ZES_ENGINE_TYPE_FLAG_COMPUTE);
|
|
}
|
|
|
|
createHandle(false, 0, ZES_ENGINE_TYPE_FLAG_OTHER);
|
|
return ZE_RESULT_SUCCESS;
|
|
}
|
|
|
|
ze_result_t PerformanceHandleContext::performanceGet(uint32_t *pCount, zes_perf_handle_t *phPerformance) {
|
|
std::call_once(initPerformanceOnce, [this]() {
|
|
this->init(pOsSysman->getSubDeviceCount());
|
|
});
|
|
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 != phPerformance) {
|
|
for (uint32_t i = 0; i < numToCopy; i++) {
|
|
phPerformance[i] = handleList[i]->toPerformanceHandle();
|
|
}
|
|
}
|
|
return ZE_RESULT_SUCCESS;
|
|
}
|
|
|
|
} // namespace Sysman
|
|
} // namespace L0
|