Project
Loading...
Searching...
No Matches
GPUErrors.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#include "GPUErrors.h"
16#include "GPUDataTypes.h"
17#include "GPUCommonMath.h"
18#include "GPUDefMacros.h"
19#include "GPULogging.h"
20
21using namespace o2::gpu;
22
23#define GPUCA_MAX_ERRORS 255u
24
25GPUd() void GPUErrors::raiseError(uint32_t code, uint32_t param1, uint32_t param2, uint32_t param3) const
26{
27 uint32_t pos = CAMath::AtomicAdd(mErrors, 1u);
28 if (pos < GPUCA_MAX_ERRORS) {
29 mErrors[4 * pos + 1] = code;
30 mErrors[4 * pos + 2] = param1;
31 mErrors[4 * pos + 3] = param2;
32 mErrors[4 * pos + 4] = param3;
33 }
34}
35
36#ifndef GPUCA_GPUCODE
37
38#include <cstring>
39#include <unordered_map>
40
42{
43 return GPUCA_MAX_ERRORS;
44}
45
47{
48 memset(mErrors, 0, GPUCA_MAX_ERRORS * sizeof(*mErrors));
49}
50
51static std::unordered_map<uint32_t, const char*> errorNames = {
52#define GPUCA_ERROR_CODE(num, name, ...) {num, GPUCA_M_STR(name)},
53#include "GPUErrorCodes.h"
54#undef GPUCA_ERROR_CODE
55};
56
57void GPUErrors::printErrors(bool silent)
58{
59 for (uint32_t i = 0; i < std::min(*mErrors, GPUCA_MAX_ERRORS); i++) {
60 uint32_t errorCode = mErrors[4 * i + 1];
61 const auto& it = errorNames.find(errorCode);
62 const char* errorName = it == errorNames.end() ? "INVALID ERROR CODE" : it->second;
63 if (silent && i) {
64 GPUWarning("GPU Error Code (%u:%u) %s : %u / %u / %u", i, errorCode, errorName, mErrors[4 * i + 2], mErrors[4 * i + 3], mErrors[4 * i + 4]);
65 } else if (silent) {
66 GPUAlarm("GPU Error Code (%u:%u) %s : %u / %u / %u", i, errorCode, errorName, mErrors[4 * i + 2], mErrors[4 * i + 3], mErrors[4 * i + 4]);
67 } else {
68 GPUError("GPU Error Code (%u:%u) %s : %u / %u / %u", i, errorCode, errorName, mErrors[4 * i + 2], mErrors[4 * i + 3], mErrors[4 * i + 4]);
69 }
70 }
71 if (*mErrors > GPUCA_MAX_ERRORS) {
72 if (silent) {
73 GPUWarning("Additional errors occured (codes not stored)");
74 } else {
75 GPUError("Additional errors occured (codes not stored)");
76 }
77 }
78}
79
80uint32_t GPUErrors::getNErrors() const
81{
82 return std::min(*mErrors, GPUCA_MAX_ERRORS);
83}
84
85const uint32_t* GPUErrors::getErrorPtr() const
86{
87 return mErrors + 1;
88}
89
90#endif
int32_t i
GPUd() void GPUErrors
Definition GPUErrors.cxx:25
#define GPUCA_MAX_ERRORS
Definition GPUErrors.cxx:23
uint16_t pos
Definition RawData.h:3
const uint32_t * getErrorPtr() const
Definition GPUErrors.cxx:85
static uint32_t getMaxErrors()
void printErrors(bool silent=false)
Definition GPUErrors.cxx:57
uint32_t getNErrors() const
Definition GPUErrors.cxx:80
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)