Skip to content

Commit 7b8b2e7

Browse files
ariedel-cerndavidrohr
authored andcommitted
Feat: movde error names to GPUErrors.h
1 parent b83d673 commit 7b8b2e7

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

Detectors/TPC/qc/include/TPCQC/GPUErrorQA.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ class GPUErrorQA
5454
void resetHistograms();
5555

5656
/// return histograms
57-
const std::unordered_map<std::string, std::unique_ptr<TH1>>& getMapHist() const { return mMapHist; };
57+
const std::unordered_map<std::string, std::unique_ptr<TH1>>& getMapHist() const { return mMapHist; }
5858

5959
/// Dump results to a file
6060
void dumpToFile(std::string filename);
6161

6262
private:
6363
std::unordered_map<std::string, std::unique_ptr<TH1>> mMapHist;
6464

65-
ClassDefNV(GPUErrorQA, 1);
65+
ClassDefNV(GPUErrorQA, 2);
6666
};
6767
} // namespace o2::tpc::qc
6868

Detectors/TPC/qc/src/GPUErrorQA.cxx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
// o2 includes
1919
#include "TPCQC/GPUErrorQA.h"
20-
#include "GPUDefMacros.h"
20+
#include "GPUErrors.h"
2121

2222
ClassImp(o2::tpc::qc::GPUErrorQA);
2323

@@ -28,21 +28,13 @@ void GPUErrorQA::initializeHistograms()
2828
{
2929
TH1::AddDirectory(false);
3030

31-
// get gpu error names
32-
// copied from GPUErrors.h
33-
static std::unordered_map<uint32_t, const char*> errorNames = {
34-
#define GPUCA_ERROR_CODE(num, name, ...) {num, GPUCA_M_STR(name)},
35-
#include "GPUErrorCodes.h"
36-
#undef GPUCA_ERROR_CODE
37-
};
38-
3931
// 1D histogram counting all reported errors
40-
mMapHist["ErrorCounter"] = std::make_unique<TH1I>("ErrorCounter", "ErrorCounter", errorNames.size(), -0.5, errorNames.size() - 0.5);
32+
mMapHist["ErrorCounter"] = std::make_unique<TH1I>("ErrorCounter", "ErrorCounter", o2::gpu::errorNames.size(), -0.5, o2::gpu::errorNames.size() - 0.5);
4133
mMapHist["ErrorCounter"]->GetXaxis()->SetTitle("Error Codes");
4234
mMapHist["ErrorCounter"]->GetYaxis()->SetTitle("Entries");
4335
// for convienence, label each bin with the error name
4436
for (size_t bin = 1; bin < mMapHist["ErrorCounter"]->GetNbinsX(); bin++) {
45-
auto const& it = errorNames.find(bin);
37+
auto const& it = o2::gpu::errorNames.find(bin);
4638
mMapHist["ErrorCounter"]->GetXaxis()->SetBinLabel(bin, it->second);
4739
}
4840
}
@@ -68,7 +60,7 @@ void GPUErrorQA::dumpToFile(const std::string filename)
6860
auto f = std::unique_ptr<TFile>(TFile::Open(filename.data(), "recreate"));
6961
TObjArray arr;
7062
arr.SetName("GPUErrorQA_Hists");
71-
for (const auto& [name, hist] : mMapHist) {
63+
for ([[maybe_unused]] const auto& [name, hist] : mMapHist) {
7264
arr.Add(hist.get());
7365
}
7466
arr.Write(arr.GetName(), TObject::kSingleKey);

GPU/GPUTracking/Global/GPUErrors.cxx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ 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>
4039

4140
uint32_t GPUErrors::getMaxErrors()
4241
{
@@ -48,12 +47,6 @@ void GPUErrors::clear()
4847
memset(mErrors, 0, GPUCA_MAX_ERRORS * sizeof(*mErrors));
4948
}
5049

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-
5750
bool GPUErrors::printErrors(bool silent, uint64_t mask)
5851
{
5952
bool retVal = 0;

GPU/GPUTracking/Global/GPUErrors.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@
1616
#define GPUERRORS_H
1717

1818
#include "GPUCommonDef.h"
19+
#include "GPUDefMacros.h"
20+
#include <unordered_map>
1921

2022
namespace o2::gpu
2123
{
2224

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+
2331
class GPUErrors
2432
{
2533
public:

0 commit comments

Comments
 (0)