forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGPUErrors.cxx
More file actions
101 lines (87 loc) · 2.96 KB
/
GPUErrors.cxx
File metadata and controls
101 lines (87 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file GPUErrors.cxx
/// \author David Rohr
#include "GPUErrors.h"
#include "GPUDataTypes.h"
#include "GPUCommonMath.h"
#include "GPUDefMacros.h"
#include "GPULogging.h"
using namespace o2::gpu;
#define GPUCA_MAX_ERRORS 255u
GPUd() void GPUErrors::raiseError(uint32_t code, uint32_t param1, uint32_t param2, uint32_t param3) const
{
uint32_t pos = CAMath::AtomicAdd(mErrors, 1u);
if (pos < GPUCA_MAX_ERRORS) {
mErrors[4 * pos + 1] = code;
mErrors[4 * pos + 2] = param1;
mErrors[4 * pos + 3] = param2;
mErrors[4 * pos + 4] = param3;
}
}
#ifndef GPUCA_GPUCODE
#include <cstring>
#include <unordered_map>
uint32_t GPUErrors::getMaxErrors()
{
return GPUCA_MAX_ERRORS;
}
void GPUErrors::clear()
{
memset(mErrors, 0, GPUCA_MAX_ERRORS * sizeof(*mErrors));
}
const std::unordered_map<uint32_t, const char*>& GPUErrors::getErrorNames()
{
static std::unordered_map<uint32_t, const char*> errorNames = {
#define GPUCA_ERROR_CODE(num, name, ...) {num, GPUCA_M_STR(name)},
#include "GPUErrorCodes.h"
#undef GPUCA_ERROR_CODE
};
return errorNames;
}
bool GPUErrors::printErrors(bool silent, uint64_t mask)
{
bool retVal = 0;
const auto& errorNames = getErrorNames();
for (uint32_t i = 0; i < std::min(*mErrors, GPUCA_MAX_ERRORS); i++) {
uint32_t errorCode = mErrors[4 * i + 1];
const auto& it = errorNames.find(errorCode);
const char* errorName = it == errorNames.end() ? "INVALID ERROR CODE" : it->second;
static_assert(MAX_GPUCA_ERROR_NUMBER <= sizeof(mask) * 8);
if (mask & (1 << errorCode)) {
retVal = 1;
}
if (silent && i) {
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]);
} else if (silent) {
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]);
} else {
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]);
}
}
if (*mErrors > GPUCA_MAX_ERRORS) {
if (silent) {
GPUWarning("Additional errors occured (codes not stored)");
} else {
GPUError("Additional errors occured (codes not stored)");
}
}
return retVal;
}
uint32_t GPUErrors::getNErrors() const
{
return std::min(*mErrors, GPUCA_MAX_ERRORS);
}
const uint32_t* GPUErrors::getErrorPtr() const
{
return mErrors + 1;
}
#endif