Skip to content

Commit 0ad6e9b

Browse files
committed
Fix: expose gpu error names with static function
1 parent 7b5264a commit 0ad6e9b

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
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,6 +48,17 @@ void GPUErrors::clear()
4748
memset(mErrors, 0, GPUCA_MAX_ERRORS * sizeof(*mErrors));
4849
}
4950

51+
static 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+
57+
const std::unordered_map<uint32_t, const char*>& GPUErrors::getErrorNames()
58+
{
59+
return errorNames;
60+
}
61+
5062
bool GPUErrors::printErrors(bool silent, uint64_t mask)
5163
{
5264
bool retVal = 0;

GPU/GPUTracking/Global/GPUErrors.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222
namespace o2::gpu
2323
{
2424

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-
3125
class GPUErrors
3226
{
3327
public:
@@ -42,6 +36,7 @@ class GPUErrors
4236
void setMemory(GPUglobalref() uint32_t* m) { mErrors = m; }
4337
void clear();
4438
bool printErrors(bool silent = false, uint64_t mask = 0);
39+
static const std::unordered_map<uint32_t, const char*>& getErrorNames();
4540
uint32_t getNErrors() const;
4641
const uint32_t* getErrorPtr() const;
4742
static uint32_t getMaxErrors();

0 commit comments

Comments
 (0)