Update all L0 Sysman getHandle routines to match spec.

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>
This commit is contained in:
Bill Jordan
2020-07-29 13:03:15 -04:00
committed by sys_ocldev
parent d65cdab453
commit c64eab402e
15 changed files with 140 additions and 112 deletions

View File

@@ -7,6 +7,8 @@
#include "level_zero/tools/source/sysman/temperature/temperature.h"
#include "shared/source/helpers/basic_math.h"
#include "level_zero/tools/source/sysman/temperature/temperature_imp.h"
namespace L0 {
@@ -32,18 +34,16 @@ void TemperatureHandleContext::init() {
}
ze_result_t TemperatureHandleContext::temperatureGet(uint32_t *pCount, zet_sysman_temp_handle_t *phTemperature) {
if (nullptr == phTemperature) {
*pCount = static_cast<uint32_t>(handleList.size());
return ZE_RESULT_SUCCESS;
uint32_t handleListSize = static_cast<uint32_t>(handleList.size());
uint32_t numToCopy = std::min(*pCount, handleListSize);
if (0 == *pCount || *pCount > handleListSize) {
*pCount = handleListSize;
}
uint32_t i = 0;
for (Temperature *temperature : handleList) {
if (i >= *pCount) {
break;
if (nullptr != phTemperature) {
for (uint32_t i = 0; i < numToCopy; i++) {
phTemperature[i] = handleList[i]->toHandle();
}
phTemperature[i++] = temperature->toHandle();
}
*pCount = i;
return ZE_RESULT_SUCCESS;
}