Skip to content

Commit 8aec6f6

Browse files
ariedel-cerndavidrohr
authored andcommitted
Fix: expose gpu error names with static function
1 parent 7b8b2e7 commit 8aec6f6

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

GPU/GPUTracking/Global/GPUErrors.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ GPUd() void GPUErrors::raiseError(uint32_t code, uint32_t param1, uint32_t param
3636
#ifndef GPUCA_GPUCODE
3737

3838
#include <cstring>
39+
#include <unordered_map>
3940

4041
uint32_t GPUErrors::getMaxErrors()
4142
{
@@ -47,9 +48,20 @@ void GPUErrors::clear()
4748
memset(mErrors, 0, GPUCA_MAX_ERRORS * sizeof(*mErrors));
4849
}
4950

51+
const 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+
5061
bool GPUErrors::printErrors(bool silent, uint64_t mask)
5162
{
5263
bool retVal = 0;
64+
const auto& errorNames = getErrorNames();
5365
for (uint32_t i = 0; i < std::min(*mErrors, GPUCA_MAX_ERRORS); i++) {
5466
uint32_t errorCode = mErrors[4 * i + 1];
5567
const auto& it = errorNames.find(errorCode);

GPU/GPUTracking/Global/GPUErrors.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,14 @@
1616
#define GPUERRORS_H
1717

1818
#include "GPUCommonDef.h"
19-
#include "GPUDefMacros.h"
19+
20+
#ifndef GPUCA_GPUCODE
2021
#include <unordered_map>
22+
#endif
2123

2224
namespace o2::gpu
2325
{
2426

25-
static std::unordered_map<uint32_t, const char*> errorNames = {
26-
#define GPUCA_ERROR_CODE(num, name, ...) {num, GPUCA_M_STR(name)},
27-
#include "GPUErrorCodes.h"
28-
#undef GPUCA_ERROR_CODE
29-
};
30-
3127
class GPUErrors
3228
{
3329
public:
@@ -42,6 +38,7 @@ class GPUErrors
4238
void setMemory(GPUglobalref() uint32_t* m) { mErrors = m; }
4339
void clear();
4440
bool printErrors(bool silent = false, uint64_t mask = 0);
41+
static const std::unordered_map<uint32_t, const char*>& getErrorNames();
4542
uint32_t getNErrors() const;
4643
const uint32_t* getErrorPtr() const;
4744
static uint32_t getMaxErrors();

0 commit comments

Comments
 (0)