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
51const std::unordered_map<uint32_t, const char*>& GPUErrors::getErrorNames()
52{
53 static std::unordered_map<uint32_t, const char*> errorNames = {
54#define GPUCA_ERROR_CODE(num, name, ...) {num, GPUCA_M_STR(name)},
55#include "GPUErrorCodes.h"
56#undef GPUCA_ERROR_CODE
57 };
58 return errorNames;
59}
60
61bool GPUErrors::printErrors(bool silent, uint64_t mask)
62{
63 bool retVal = 0;
64 const auto& errorNames = getErrorNames();
65 for (uint32_t i = 0; i < std::min(*mErrors, GPUCA_MAX_ERRORS); i++) {
66 uint32_t errorCode = mErrors[4 * i + 1];
67 const auto& it = errorNames.find(errorCode);
68 const char* errorName = it == errorNames.end() ? "INVALID ERROR CODE" : it->second;
69 static_assert(MAX_GPUCA_ERROR_NUMBER <= sizeof(mask) * 8);
70 if (mask & (1 << errorCode)) {
71 retVal = 1;
72 }
73 if (silent && i) {
74 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]);
75 } else if (silent) {
76 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]);
77 } else {
78 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]);
79 }
80 }
81 if (*mErrors > GPUCA_MAX_ERRORS) {
82 if (silent) {
83 GPUWarning("Additional errors occured (codes not stored)");
84 } else {
85 GPUError("Additional errors occured (codes not stored)");
86 }
87 }
88 return retVal;
89}
90
91uint32_t GPUErrors::getNErrors() const
92{
93 return std::min(*mErrors, GPUCA_MAX_ERRORS);
94}
95
96const uint32_t* GPUErrors::getErrorPtr() const
97{
98 return mErrors + 1;
99}
100
101#endif
int32_t i
GPUd() void GPUErrors
Definition GPUErrors.cxx:25
#define GPUCA_MAX_ERRORS
Definition GPUErrors.cxx:23
int32_t retVal
uint16_t pos
Definition RawData.h:3
const uint32_t * getErrorPtr() const
Definition GPUErrors.cxx:96
static uint32_t getMaxErrors()
static const std::unordered_map< uint32_t, const char * > & getErrorNames()
Definition GPUErrors.cxx:51
bool printErrors(bool silent=false, uint64_t mask=0)
Definition GPUErrors.cxx:61
uint32_t getNErrors() const
Definition GPUErrors.cxx:91
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLint GLuint mask
Definition glcorearb.h:291