Files
compute-runtime/level_zero/tools/source/sysman/ras/ras.cpp
Bill Jordan c64eab402e 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>
2020-07-30 07:27:21 +02:00

47 lines
1.2 KiB
C++

/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/basic_math.h"
#include "level_zero/tools/source/sysman/ras/ras_imp.h"
namespace L0 {
RasHandleContext::~RasHandleContext() {
for (Ras *pRas : handleList) {
delete pRas;
}
}
void RasHandleContext::createHandle(zet_ras_error_type_t type) {
Ras *pRas = new RasImp(pOsSysman, type);
if (pRas->isRasErrorSupported == true) {
handleList.push_back(pRas);
} else {
delete pRas;
}
}
void RasHandleContext::init() {
createHandle(ZET_RAS_ERROR_TYPE_UNCORRECTABLE);
createHandle(ZET_RAS_ERROR_TYPE_CORRECTABLE);
}
ze_result_t RasHandleContext::rasGet(uint32_t *pCount,
zet_sysman_ras_handle_t *phRas) {
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 != phRas) {
for (uint32_t i = 0; i < numToCopy; i++) {
phRas[i] = handleList[i]->toHandle();
}
}
return ZE_RESULT_SUCCESS;
}
} // namespace L0