Files
compute-runtime/level_zero/tools/source/sysman/engine/engine.cpp
Jaime Arteaga 902fc2f6c4 level-zero v1.0 (2/N)
Change-Id: I1419231a721fab210e166d26a264cae04d661dcd
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
Signed-off-by: macabral <matias.a.cabral@intel.com>
Signed-off-by: davidoli <david.olien@intel.com>
Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@intel.com>
Signed-off-by: Spruit, Neil R <neil.r.spruit@intel.com>
Signed-off-by: Latif, Raiyan <raiyan.latif@intel.com>
Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
2020-08-03 13:11:13 +02:00

58 lines
1.5 KiB
C++

/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/sysman/engine/engine.h"
#include "shared/source/helpers/basic_math.h"
#include "level_zero/tools/source/sysman/engine/engine_imp.h"
namespace L0 {
EngineHandleContext::~EngineHandleContext() {
for (Engine *pEngine : handleList) {
delete pEngine;
}
}
void EngineHandleContext::createHandle(zes_engine_group_t type) {
Engine *pEngine = new EngineImp(pOsSysman, type);
if (pEngine->initSuccess == true) {
handleList.push_back(pEngine);
} else {
delete pEngine;
}
}
void EngineHandleContext::init() {
auto isSysmanEnabled = getenv("ZES_ENABLE_SYSMAN");
if (isSysmanEnabled != nullptr) {
auto isSysmanEnabledAsInt = atoi(isSysmanEnabled);
if (isSysmanEnabledAsInt == 1) {
createHandle(ZES_ENGINE_GROUP_COMPUTE_ALL);
}
return;
}
createHandle(ZES_ENGINE_GROUP_COMPUTE_ALL);
}
ze_result_t EngineHandleContext::engineGet(uint32_t *pCount, zes_engine_handle_t *phEngine) {
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 != phEngine) {
for (uint32_t i = 0; i < numToCopy; i++) {
phEngine[i] = handleList[i]->toHandle();
}
}
return ZE_RESULT_SUCCESS;
}
} // namespace L0