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