mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Updated all the getHandle routines to use the following
algorithm:
n = min(*pCount, available)
if (*pCount == 0 || *pCount > available) {
*pCount = available;
}
if (pArrayn != nullptr) {
for(i = 0; i < n; i++) {
pArray[i] = handle[i];
}
}
Change-Id: I3b2a2170c2b52d1651bddae4f85f361fd86167a0
Signed-off-by: Bill Jordan <bill.jordan@intel.com>
47 lines
1.1 KiB
C++
47 lines
1.1 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;
|
|
}
|
|
}
|
|
|
|
ze_result_t EngineHandleContext::init() {
|
|
Engine *pEngine = new EngineImp(pOsSysman);
|
|
if (pEngine->initSuccess == true) {
|
|
handleList.push_back(pEngine);
|
|
} else {
|
|
delete pEngine;
|
|
}
|
|
return ZE_RESULT_SUCCESS;
|
|
}
|
|
|
|
ze_result_t EngineHandleContext::engineGet(uint32_t *pCount, zet_sysman_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
|