Skip to content

Commit 20f1352

Browse files
committed
GPU: Clean up more of C++ < 11 compatibility code
1 parent 2fef879 commit 20f1352

16 files changed

+58
-66
lines changed

GPU/GPUTracking/Base/GPUConstantMem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static constexpr size_t gGPUConstantMemBufferSize = (sizeof(GPUConstantMem) + si
9696
#endif
9797
} // namespace o2::gpu
9898
#if defined(GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM) && !defined(GPUCA_GPUCODE_HOSTONLY)
99-
GPUconstant() o2::gpu::GPUConstantMemCopyable gGPUConstantMemBuffer;
99+
GPUconstant() o2::gpu::GPUConstantMemCopyable gGPUConstantMemBuffer; // TODO: This should go into o2::gpu namespace, but then CUDA or HIP would not find the symbol
100100
#endif // GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM
101101
namespace o2::gpu
102102
{

GPU/GPUTracking/Base/GPUGeneralKernels.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class GPUKernelTemplate
7979
};
8080

8181
typedef GPUconstantref() GPUConstantMem processorType;
82-
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::NoRecoStep; }
82+
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUDataTypes::RecoStep::NoRecoStep; }
8383
GPUhdi() static processorType* Processor(GPUConstantMem& processors)
8484
{
8585
return &processors;
@@ -94,7 +94,7 @@ class GPUKernelTemplate
9494
class GPUMemClean16 : public GPUKernelTemplate
9595
{
9696
public:
97-
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::NoRecoStep; }
97+
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUDataTypes::RecoStep::NoRecoStep; }
9898
template <int32_t iKernel = defaultKernel>
9999
GPUd() static void Thread(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& smem, processorType& processors, GPUglobalref() void* ptr, uint64_t size);
100100
};
@@ -103,7 +103,7 @@ class GPUMemClean16 : public GPUKernelTemplate
103103
class GPUitoa : public GPUKernelTemplate
104104
{
105105
public:
106-
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::NoRecoStep; }
106+
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUDataTypes::RecoStep::NoRecoStep; }
107107
template <int32_t iKernel = defaultKernel>
108108
GPUd() static void Thread(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& smem, processorType& processors, GPUglobalref() int32_t* ptr, uint64_t size);
109109
};

GPU/GPUTracking/Base/GPUReconstructionCPU.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ template <class S, int32_t I, typename... Args>
134134
inline void GPUReconstructionCPU::runKernel(krnlSetup&& setup, Args&&... args)
135135
{
136136
HighResTimer* t = nullptr;
137-
GPUCA_RECO_STEP myStep = S::GetRecoStep() == GPUCA_RECO_STEP::NoRecoStep ? setup.x.step : S::GetRecoStep();
138-
if (myStep == GPUCA_RECO_STEP::NoRecoStep) {
137+
GPUDataTypes::RecoStep myStep = S::GetRecoStep() == GPUDataTypes::RecoStep::NoRecoStep ? setup.x.step : S::GetRecoStep();
138+
if (myStep == GPUDataTypes::RecoStep::NoRecoStep) {
139139
throw std::runtime_error("Failure running general kernel without defining RecoStep");
140140
}
141141
int32_t cpuFallback = IsGPU() ? (setup.x.device == krnlDeviceType::CPU ? 2 : (mRecoSteps.stepsGPUMask & myStep) != myStep) : 0;

GPU/GPUTracking/Base/GPUReconstructionKernels.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ struct classArgument {
3030
};
3131

3232
struct krnlExec {
33-
constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUReconstruction::krnlDeviceType d = GPUReconstruction::krnlDeviceType::Auto) : nBlocks(b), nThreads(t), stream(s), device(d), step(GPUCA_RECO_STEP::NoRecoStep) {}
34-
constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUCA_RECO_STEP st) : nBlocks(b), nThreads(t), stream(s), device(GPUReconstruction::krnlDeviceType::Auto), step(st) {}
35-
constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUReconstruction::krnlDeviceType d, GPUCA_RECO_STEP st) : nBlocks(b), nThreads(t), stream(s), device(d), step(st) {}
33+
constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUReconstruction::krnlDeviceType d = GPUReconstruction::krnlDeviceType::Auto) : nBlocks(b), nThreads(t), stream(s), device(d), step(GPUDataTypes::RecoStep::NoRecoStep) {}
34+
constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUDataTypes::RecoStep st) : nBlocks(b), nThreads(t), stream(s), device(GPUReconstruction::krnlDeviceType::Auto), step(st) {}
35+
constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUReconstruction::krnlDeviceType d, GPUDataTypes::RecoStep st) : nBlocks(b), nThreads(t), stream(s), device(d), step(st) {}
3636
uint32_t nBlocks;
3737
uint32_t nThreads;
3838
int32_t stream;
3939
GPUReconstruction::krnlDeviceType device;
40-
GPUCA_RECO_STEP step;
40+
GPUDataTypes::RecoStep step;
4141
};
4242
struct krnlRunRange {
4343
constexpr krnlRunRange() = default;

GPU/GPUTracking/DataTypes/GPUDataTypes.h

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ struct TPCPadGainCalib;
9696
struct TPCZSLinkMapping;
9797

9898
#include "utils/bitfield.h"
99-
#define ENUM_CLASS class
100-
#define ENUM_UINT : uint32_t
101-
#define GPUCA_RECO_STEP GPUDataTypes::RecoStep
10299

103100
class GPUTPCTrack;
104101
class GPUTPCHitId;
@@ -117,36 +114,33 @@ struct GPUSettingsTF;
117114
class GPUDataTypes
118115
{
119116
public:
120-
enum ENUM_CLASS GeometryType ENUM_UINT{RESERVED_GEOMETRY = 0, ALIROOT = 1, O2 = 2};
121-
enum DeviceType ENUM_UINT { INVALID_DEVICE = 0,
122-
CPU = 1,
123-
CUDA = 2,
124-
HIP = 3,
125-
OCL = 4 };
126-
enum ENUM_CLASS GeneralStep { Prepare = 1,
127-
QA = 2 };
117+
// clang-format off
118+
enum class GeometryType : uint32_t { RESERVED_GEOMETRY = 0, ALIROOT = 1, O2 = 2 };
119+
enum DeviceType : uint32_t { INVALID_DEVICE = 0, CPU = 1, CUDA = 2, HIP = 3, OCL = 4 };
120+
enum class GeneralStep { Prepare = 1, QA = 2 };
121+
// clang-format on
128122

129-
enum ENUM_CLASS RecoStep { TPCConversion = 1,
130-
TPCSectorTracking = 2,
131-
TPCMerging = 4,
132-
TPCCompression = 8,
133-
TRDTracking = 16,
134-
ITSTracking = 32,
135-
TPCdEdx = 64,
136-
TPCClusterFinding = 128,
137-
TPCDecompression = 256,
138-
Refit = 512,
139-
AllRecoSteps = 0x7FFFFFFF,
140-
NoRecoStep = 0 };
141-
enum ENUM_CLASS InOutType { TPCClusters = 1,
142-
OBSOLETE = 2,
143-
TPCMergedTracks = 4,
144-
TPCCompressedClusters = 8,
145-
TRDTracklets = 16,
146-
TRDTracks = 32,
147-
TPCRaw = 64,
148-
ITSClusters = 128,
149-
ITSTracks = 256 };
123+
enum class RecoStep { TPCConversion = 1,
124+
TPCSectorTracking = 2,
125+
TPCMerging = 4,
126+
TPCCompression = 8,
127+
TRDTracking = 16,
128+
ITSTracking = 32,
129+
TPCdEdx = 64,
130+
TPCClusterFinding = 128,
131+
TPCDecompression = 256,
132+
Refit = 512,
133+
AllRecoSteps = 0x7FFFFFFF,
134+
NoRecoStep = 0 };
135+
enum class InOutType { TPCClusters = 1,
136+
OBSOLETE = 2,
137+
TPCMergedTracks = 4,
138+
TPCCompressedClusters = 8,
139+
TRDTracklets = 16,
140+
TRDTracks = 32,
141+
TPCRaw = 64,
142+
ITSClusters = 128,
143+
ITSTracks = 256 };
150144
#ifndef __OPENCL__
151145
static constexpr const char* const DEVICE_TYPE_NAMES[] = {"INVALID", "CPU", "CUDA", "HIP", "OCL"};
152146
static constexpr const char* const RECO_STEP_NAMES[] = {"TPC Transformation", "TPC Sector Tracking", "TPC Track Merging and Fit", "TPC Compression", "TRD Tracking", "ITS Tracking", "TPC dEdx Computation", "TPC Cluster Finding", "TPC Decompression", "Global Refit"};
@@ -312,8 +306,6 @@ struct GPUTrackingInOutPointers {
312306
const GPUSettingsTF* settingsTF = nullptr;
313307
};
314308

315-
#undef ENUM_CLASS
316-
#undef ENUM_UINT
317309
} // namespace o2::gpu
318310

319311
#endif

GPU/GPUTracking/Global/GPUChain.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,33 @@ using namespace o2::gpu;
1818
constexpr GPUChain::krnlRunRange GPUChain::krnlRunRangeNone;
1919
constexpr GPUChain::krnlEvent GPUChain::krnlEventNone;
2020

21-
GPUChain::krnlExec GPUChain::GetGrid(uint32_t totalItems, uint32_t nThreads, int32_t stream, GPUReconstruction::krnlDeviceType d, GPUCA_RECO_STEP st)
21+
GPUChain::krnlExec GPUChain::GetGrid(uint32_t totalItems, uint32_t nThreads, int32_t stream, GPUReconstruction::krnlDeviceType d, GPUDataTypes::RecoStep st)
2222
{
2323
const uint32_t nBlocks = (totalItems + nThreads - 1) / nThreads;
2424
return {nBlocks, nThreads, stream, d, st};
2525
}
2626

27-
GPUChain::krnlExec GPUChain::GetGrid(uint32_t totalItems, int32_t stream, GPUReconstruction::krnlDeviceType d, GPUCA_RECO_STEP st)
27+
GPUChain::krnlExec GPUChain::GetGrid(uint32_t totalItems, int32_t stream, GPUReconstruction::krnlDeviceType d, GPUDataTypes::RecoStep st)
2828
{
2929
return {(uint32_t)-1, totalItems, stream, d, st};
3030
}
3131

32-
GPUChain::krnlExec GPUChain::GetGridBlk(uint32_t nBlocks, int32_t stream, GPUReconstruction::krnlDeviceType d, GPUCA_RECO_STEP st)
32+
GPUChain::krnlExec GPUChain::GetGridBlk(uint32_t nBlocks, int32_t stream, GPUReconstruction::krnlDeviceType d, GPUDataTypes::RecoStep st)
3333
{
3434
return {(uint32_t)-2, nBlocks, stream, d, st};
3535
}
3636

37-
GPUChain::krnlExec GPUChain::GetGridBlkStep(uint32_t nBlocks, int32_t stream, GPUCA_RECO_STEP st)
37+
GPUChain::krnlExec GPUChain::GetGridBlkStep(uint32_t nBlocks, int32_t stream, GPUDataTypes::RecoStep st)
3838
{
3939
return {(uint32_t)-2, nBlocks, stream, GPUReconstruction::krnlDeviceType::Auto, st};
4040
}
4141

42-
GPUChain::krnlExec GPUChain::GetGridAuto(int32_t stream, GPUReconstruction::krnlDeviceType d, GPUCA_RECO_STEP st)
42+
GPUChain::krnlExec GPUChain::GetGridAuto(int32_t stream, GPUReconstruction::krnlDeviceType d, GPUDataTypes::RecoStep st)
4343
{
4444
return {(uint32_t)-3, 0, stream, d, st};
4545
}
4646

47-
GPUChain::krnlExec GPUChain::GetGridAutoStep(int32_t stream, GPUCA_RECO_STEP st)
47+
GPUChain::krnlExec GPUChain::GetGridAutoStep(int32_t stream, GPUDataTypes::RecoStep st)
4848
{
4949
return {(uint32_t)-3, 0, stream, GPUReconstruction::krnlDeviceType::Auto, st};
5050
}

GPU/GPUTracking/Global/GPUChain.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,15 @@ class GPUChain
192192
return mRec->getTimer<T, J>(name, num);
193193
}
194194
// Get GRID with NBLOCKS minimal such that nThreads * NBLOCS >= totalItems
195-
krnlExec GetGrid(uint32_t totalItems, uint32_t nThreads, int32_t stream, GPUReconstruction::krnlDeviceType d = GPUReconstruction::krnlDeviceType::Auto, GPUCA_RECO_STEP st = GPUCA_RECO_STEP::NoRecoStep);
195+
krnlExec GetGrid(uint32_t totalItems, uint32_t nThreads, int32_t stream, GPUReconstruction::krnlDeviceType d = GPUReconstruction::krnlDeviceType::Auto, GPUDataTypes::RecoStep st = GPUDataTypes::RecoStep::NoRecoStep);
196196
// Get GRID with NBLOCKS minimal such that ideal number of threads * NBLOCKS >= totalItems
197-
krnlExec GetGrid(uint32_t totalItems, int32_t stream, GPUReconstruction::krnlDeviceType d = GPUReconstruction::krnlDeviceType::Auto, GPUCA_RECO_STEP st = GPUCA_RECO_STEP::NoRecoStep);
197+
krnlExec GetGrid(uint32_t totalItems, int32_t stream, GPUReconstruction::krnlDeviceType d = GPUReconstruction::krnlDeviceType::Auto, GPUDataTypes::RecoStep st = GPUDataTypes::RecoStep::NoRecoStep);
198198
// Get GRID with specified number of blocks, each block with ideal number of threads
199-
krnlExec GetGridBlk(uint32_t nBlocks, int32_t stream, GPUReconstruction::krnlDeviceType d = GPUReconstruction::krnlDeviceType::Auto, GPUCA_RECO_STEP st = GPUCA_RECO_STEP::NoRecoStep);
200-
krnlExec GetGridBlkStep(uint32_t nBlocks, int32_t stream, GPUCA_RECO_STEP st = GPUCA_RECO_STEP::NoRecoStep);
199+
krnlExec GetGridBlk(uint32_t nBlocks, int32_t stream, GPUReconstruction::krnlDeviceType d = GPUReconstruction::krnlDeviceType::Auto, GPUDataTypes::RecoStep st = GPUDataTypes::RecoStep::NoRecoStep);
200+
krnlExec GetGridBlkStep(uint32_t nBlocks, int32_t stream, GPUDataTypes::RecoStep st = GPUDataTypes::RecoStep::NoRecoStep);
201201
// Get GRID with ideal number of threads / blocks for GPU
202-
krnlExec GetGridAuto(int32_t stream, GPUReconstruction::krnlDeviceType d = GPUReconstruction::krnlDeviceType::Auto, GPUCA_RECO_STEP st = GPUCA_RECO_STEP::NoRecoStep);
203-
krnlExec GetGridAutoStep(int32_t stream, GPUCA_RECO_STEP st = GPUCA_RECO_STEP::NoRecoStep);
202+
krnlExec GetGridAuto(int32_t stream, GPUReconstruction::krnlDeviceType d = GPUReconstruction::krnlDeviceType::Auto, GPUDataTypes::RecoStep st = GPUDataTypes::RecoStep::NoRecoStep);
203+
krnlExec GetGridAutoStep(int32_t stream, GPUDataTypes::RecoStep st = GPUDataTypes::RecoStep::NoRecoStep);
204204

205205
inline uint32_t BlockCount() const { return mRec->mBlockCount; }
206206
inline uint32_t WarpSize() const { return mRec->mWarpSize; }

GPU/GPUTracking/SectorTracker/GPUTPCCreateTrackingData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class GPUTPCCreateTrackingData : public GPUKernelTemplate
3232
};
3333

3434
typedef GPUconstantref() GPUTPCTracker processorType;
35-
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::TPCSectorTracking; }
35+
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUDataTypes::RecoStep::TPCSectorTracking; }
3636
GPUhdi() static processorType* Processor(GPUConstantMem& processors)
3737
{
3838
return processors.tpcTrackers;

GPU/GPUTracking/SectorTracker/GPUTPCExtrapolationTracking.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class GPUTPCExtrapolationTracking : public GPUKernelTemplate
3030
};
3131

3232
typedef GPUconstantref() GPUTPCTracker processorType;
33-
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::TPCSectorTracking; }
33+
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUDataTypes::RecoStep::TPCSectorTracking; }
3434
GPUhdi() static processorType* Processor(GPUConstantMem& processors)
3535
{
3636
return processors.tpcTrackers;
@@ -50,7 +50,7 @@ class GPUTPCExtrapolationTrackingCopyNumbers : public GPUKernelTemplate
5050
{
5151
public:
5252
typedef GPUconstantref() GPUTPCTracker processorType;
53-
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::TPCSectorTracking; }
53+
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUDataTypes::RecoStep::TPCSectorTracking; }
5454
GPUhdi() static processorType* Processor(GPUConstantMem& processors)
5555
{
5656
return processors.tpcTrackers;

GPU/GPUTracking/SectorTracker/GPUTPCNeighboursCleaner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class GPUTPCNeighboursCleaner : public GPUKernelTemplate
3838
};
3939

4040
typedef GPUconstantref() GPUTPCTracker processorType;
41-
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::TPCSectorTracking; }
41+
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUDataTypes::RecoStep::TPCSectorTracking; }
4242
GPUhdi() static processorType* Processor(GPUConstantMem& processors)
4343
{
4444
return processors.tpcTrackers;

0 commit comments

Comments
 (0)