Skip to content

Commit 47eb04f

Browse files
committed
GPU: Remove C++ <17 protections from GPU code
1 parent 89fbec2 commit 47eb04f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+82
-109
lines changed

GPU/Common/GPUCommonAlgorithm.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818
#include "GPUCommonDef.h"
1919

20-
#if !defined(GPUCA_GPUCODE)
21-
//&& (!defined __cplusplus || __cplusplus < 201402L) // This would enable to custom search also on the CPU if available by the compiler, but it is not always faster, so we stick to std::sort
20+
#if !defined(GPUCA_GPUCODE) // Could also enable custom search on the CPU, but it is not always faster, so we stick to std::sort
2221
#include <algorithm>
2322
#define GPUCA_ALGORITHM_STD
2423
#endif

GPU/Common/GPUCommonConstants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
namespace GPUCA_NAMESPACE::gpu::gpu_common_constants
2121
{
22-
static CONSTEXPR const float kCLight = 0.000299792458f; // TODO: Duplicate of MathConstants, fix this now that we use only OpenCL CPP
22+
static constexpr const float kCLight = 0.000299792458f; // TODO: Duplicate of MathConstants, fix this now that we use only OpenCL CPP
2323
}
2424

2525
#endif

GPU/Common/GPUCommonDef.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@
4040
#endif
4141
#endif
4242

43-
// Definitions for C++11 features
44-
#if defined(__cplusplus) && __cplusplus >= 201703L
45-
#define CONSTEXPR constexpr
46-
#else
47-
#define CONSTEXPR
48-
#endif
49-
5043
// Set AliRoot / O2 namespace
5144
#if defined(GPUCA_STANDALONE) || (defined(GPUCA_O2_LIB) && !defined(GPUCA_O2_INTERFACE)) || defined(GPUCA_ALIROOT_LIB) || defined (GPUCA_GPUCODE)
5245
#define GPUCA_ALIGPUCODE

GPU/Common/GPUCommonLogger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct DummyLogger {
4545
#define LOGP(...)
4646
// #define LOGP(...) static_assert(false, "LOGP(...) unsupported in GPU code");
4747

48-
#elif defined(GPUCA_STANDALONE) || defined(GPUCA_ALIROOT_LIB) || (!defined(__cplusplus) || __cplusplus < 201703L)
48+
#elif defined(GPUCA_STANDALONE) || defined(GPUCA_ALIROOT_LIB)
4949
#include <iostream>
5050
#include <cstdio>
5151
#define LOG(type) std::cout

GPU/Common/GPUCommonMath.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ class GPUCommonMath
7373
GPUd() static float Log(float x);
7474
GPUd() static float Exp(float x);
7575
GPUhdni() static float Copysign(float x, float y);
76-
GPUd() static CONSTEXPR float TwoPi() { return 6.2831853f; }
77-
GPUd() static CONSTEXPR float Pi() { return 3.1415927f; }
76+
GPUd() static constexpr float TwoPi() { return 6.2831853f; }
77+
GPUd() static constexpr float Pi() { return 3.1415927f; }
7878
GPUd() static float Round(float x);
7979
GPUd() static float Floor(float x);
8080
GPUd() static uint32_t Float2UIntReint(const float& x);
@@ -143,12 +143,12 @@ class GPUCommonMath
143143
GPUd() static float FMulRZ(float a, float b);
144144

145145
template <int32_t I, class T>
146-
GPUd() CONSTEXPR static T nextMultipleOf(T val);
146+
GPUd() constexpr static T nextMultipleOf(T val);
147147

148148
template <typename... Args>
149149
GPUdi() static float Sum2(float w, Args... args)
150150
{
151-
if CONSTEXPR (sizeof...(Args) == 0) {
151+
if constexpr (sizeof...(Args) == 0) {
152152
return w * w;
153153
} else {
154154
return w * w + Sum2(args...);
@@ -181,9 +181,9 @@ typedef GPUCommonMath CAMath;
181181
#endif // clang-format on
182182

183183
template <int32_t I, class T>
184-
GPUdi() CONSTEXPR T GPUCommonMath::nextMultipleOf(T val)
184+
GPUdi() constexpr T GPUCommonMath::nextMultipleOf(T val)
185185
{
186-
if CONSTEXPR (I & (I - 1)) {
186+
if constexpr (I & (I - 1)) {
187187
T tmp = val % I;
188188
if (tmp) {
189189
val += I - tmp;

GPU/GPUTracking/Base/GPUGeneralKernels.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class GPUKernelTemplate
8181
};
8282

8383
typedef GPUconstantref() GPUConstantMem processorType;
84-
GPUhdi() CONSTEXPR static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::NoRecoStep; }
84+
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::NoRecoStep; }
8585
GPUhdi() static processorType* Processor(GPUConstantMem& processors)
8686
{
8787
return &processors;
@@ -96,7 +96,7 @@ class GPUKernelTemplate
9696
class GPUMemClean16 : public GPUKernelTemplate
9797
{
9898
public:
99-
GPUhdi() CONSTEXPR static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::NoRecoStep; }
99+
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::NoRecoStep; }
100100
template <int32_t iKernel = defaultKernel>
101101
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);
102102
};
@@ -105,7 +105,7 @@ class GPUMemClean16 : public GPUKernelTemplate
105105
class GPUitoa : public GPUKernelTemplate
106106
{
107107
public:
108-
GPUhdi() CONSTEXPR static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::NoRecoStep; }
108+
GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep() { return GPUCA_RECO_STEP::NoRecoStep; }
109109
template <int32_t iKernel = defaultKernel>
110110
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);
111111
};

GPU/GPUTracking/Base/GPUParam.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ GPUdi() float GPUParam::GetSystematicClusterErrorC122(float x, float y, uint8_t
116116
if (dx > occupancyTotal * rec.tpc.sysClusErrorC12Box) {
117117
return 0.f;
118118
}
119-
CONSTEXPR float dEdgeInv = 18.f / CAMath::Pi();
119+
constexpr float dEdgeInv = 18.f / CAMath::Pi();
120120
const float dy = (sector == (GPUCA_NSLICES / 2 + 1) ? 0.5f : -0.5f) * (y / x) * dEdgeInv + 0.5f;
121121
const float errC12 = rec.tpc.sysClusErrorC12Norm * occupancyTotal * dy;
122122
return errC12 * errC12;

GPU/GPUTracking/Base/GPUProcessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class GPUProcessor
108108
if (basePtr == 0) {
109109
basePtr = 1;
110110
}
111-
CONSTEXPR const size_t maxAlign = (alignof(S) > alignment) ? alignof(S) : alignment;
111+
constexpr const size_t maxAlign = (alignof(S) > alignment) ? alignof(S) : alignment;
112112
basePtr += getAlignment<maxAlign>(basePtr);
113113
S* retVal = (S*)(basePtr);
114114
basePtr += nEntries * sizeof(S);

GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
// clang-format off
1616
#define __OPENCL__
17-
#if defined(__cplusplus) && __cplusplus >= 201703L
18-
#define __OPENCL__
19-
#endif
2017
#define GPUCA_GPUTYPE_OPENCL
2118

2219
#ifdef __OPENCL__

GPU/GPUTracking/DataCompression/GPUTPCCompressionKernels.cxx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ GPUdi() GPUTPCCompressionGatherKernels::Vec128* GPUTPCCompressionGatherKernels::
332332
template <typename T, typename S>
333333
GPUdi() bool GPUTPCCompressionGatherKernels::isAlignedTo(const S* ptr)
334334
{
335-
if CONSTEXPR (alignof(S) >= alignof(T)) {
335+
if constexpr (alignof(S) >= alignof(T)) {
336336
static_cast<void>(ptr);
337337
return true;
338338
} else {
@@ -343,10 +343,10 @@ GPUdi() bool GPUTPCCompressionGatherKernels::isAlignedTo(const S* ptr)
343343
template <>
344344
GPUdi() void GPUTPCCompressionGatherKernels::compressorMemcpy<uint8_t>(uint8_t* GPUrestrict() dst, const uint8_t* GPUrestrict() src, uint32_t size, int32_t nThreads, int32_t iThread)
345345
{
346-
CONSTEXPR const int32_t vec128Elems = CpyVector<uint8_t, Vec128>::Size;
347-
CONSTEXPR const int32_t vec64Elems = CpyVector<uint8_t, Vec64>::Size;
348-
CONSTEXPR const int32_t vec32Elems = CpyVector<uint8_t, Vec32>::Size;
349-
CONSTEXPR const int32_t vec16Elems = CpyVector<uint8_t, Vec16>::Size;
346+
constexpr const int32_t vec128Elems = CpyVector<uint8_t, Vec128>::Size;
347+
constexpr const int32_t vec64Elems = CpyVector<uint8_t, Vec64>::Size;
348+
constexpr const int32_t vec32Elems = CpyVector<uint8_t, Vec32>::Size;
349+
constexpr const int32_t vec16Elems = CpyVector<uint8_t, Vec16>::Size;
350350

351351
if (size >= uint32_t(nThreads * vec128Elems)) {
352352
compressorMemcpyVectorised<uint8_t, Vec128>(dst, src, size, nThreads, iThread);
@@ -364,9 +364,9 @@ GPUdi() void GPUTPCCompressionGatherKernels::compressorMemcpy<uint8_t>(uint8_t*
364364
template <>
365365
GPUdi() void GPUTPCCompressionGatherKernels::compressorMemcpy<uint16_t>(uint16_t* GPUrestrict() dst, const uint16_t* GPUrestrict() src, uint32_t size, int32_t nThreads, int32_t iThread)
366366
{
367-
CONSTEXPR const int32_t vec128Elems = CpyVector<uint16_t, Vec128>::Size;
368-
CONSTEXPR const int32_t vec64Elems = CpyVector<uint16_t, Vec64>::Size;
369-
CONSTEXPR const int32_t vec32Elems = CpyVector<uint16_t, Vec32>::Size;
367+
constexpr const int32_t vec128Elems = CpyVector<uint16_t, Vec128>::Size;
368+
constexpr const int32_t vec64Elems = CpyVector<uint16_t, Vec64>::Size;
369+
constexpr const int32_t vec32Elems = CpyVector<uint16_t, Vec32>::Size;
370370

371371
if (size >= uint32_t(nThreads * vec128Elems)) {
372372
compressorMemcpyVectorised<uint16_t, Vec128>(dst, src, size, nThreads, iThread);
@@ -382,8 +382,8 @@ GPUdi() void GPUTPCCompressionGatherKernels::compressorMemcpy<uint16_t>(uint16_t
382382
template <>
383383
GPUdi() void GPUTPCCompressionGatherKernels::compressorMemcpy<uint32_t>(uint32_t* GPUrestrict() dst, const uint32_t* GPUrestrict() src, uint32_t size, int32_t nThreads, int32_t iThread)
384384
{
385-
CONSTEXPR const int32_t vec128Elems = CpyVector<uint32_t, Vec128>::Size;
386-
CONSTEXPR const int32_t vec64Elems = CpyVector<uint32_t, Vec64>::Size;
385+
constexpr const int32_t vec128Elems = CpyVector<uint32_t, Vec128>::Size;
386+
constexpr const int32_t vec64Elems = CpyVector<uint32_t, Vec64>::Size;
387387

388388
if (size >= uint32_t(nThreads * vec128Elems)) {
389389
compressorMemcpyVectorised<uint32_t, Vec128>(dst, src, size, nThreads, iThread);
@@ -446,8 +446,8 @@ GPUdi() void GPUTPCCompressionGatherKernels::compressorMemcpyBuffered(V* buf, T*
446446
V* GPUrestrict() dstAligned = nullptr;
447447

448448
T* bufT = reinterpret_cast<T*>(buf);
449-
CONSTEXPR const int32_t bufSize = GPUCA_WARP_SIZE;
450-
CONSTEXPR const int32_t bufTSize = bufSize * sizeof(V) / sizeof(T);
449+
constexpr const int32_t bufSize = GPUCA_WARP_SIZE;
450+
constexpr const int32_t bufTSize = bufSize * sizeof(V) / sizeof(T);
451451

452452
for (uint32_t i = 0; i < nEntries; i++) {
453453
uint32_t srcPos = 0;

0 commit comments

Comments
 (0)