Skip to content

Commit 8727301

Browse files
committed
GPU: Remove if constexpr for C++ < 17
1 parent 1b51b1b commit 8727301

3 files changed

Lines changed: 10 additions & 14 deletions

File tree

GPU/Common/GPUCommonDef.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,14 @@
5656
#define CONSTEXPR constexpr
5757
#define CONSTEXPRRET CONSTEXPR
5858
#if defined(__cplusplus) && __cplusplus >= 201703L
59-
#define CONSTEXPRIF if constexpr
6059
#define CONSTEXPR17 constexpr
6160
#else
62-
#define CONSTEXPRIF if
6361
#define CONSTEXPR17
6462
#endif
6563
#else
6664
#define CON_DELETE
6765
#define CON_DEFAULT
6866
#define CONSTEXPR const
69-
#define CONSTEXPRIF if
7067
#define CONSTEXPR17
7168
#define CONSTEXPRRET
7269
#endif

GPU/Common/GPUCommonMath.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,15 @@ class GPUCommonMath
148148
GPUd() CONSTEXPR17 static T nextMultipleOf(T val);
149149

150150
#ifdef GPUCA_NOCOMPAT
151+
GPUdi() static float Sum2() // Needed for legacy C++, For >=17 the below if constexpr handles the case
152+
{
153+
return 0.f;
154+
}
155+
151156
template <typename... Args>
152157
GPUdi() static float Sum2(float w, Args... args)
153158
{
154-
if constexpr (sizeof...(Args) == 0) {
159+
if CONSTEXPR17 (sizeof...(Args) == 0) {
155160
return w * w;
156161
} else {
157162
return w * w + Sum2(args...);
@@ -185,16 +190,13 @@ typedef GPUCommonMath CAMath;
185190
template <int I, class T>
186191
GPUdi() CONSTEXPR17 T GPUCommonMath::nextMultipleOf(T val)
187192
{
188-
CONSTEXPRIF(I & (I - 1))
189-
{
193+
if CONSTEXPR17 (I & (I - 1)) {
190194
T tmp = val % I;
191195
if (tmp) {
192196
val += I - tmp;
193197
}
194198
return val;
195-
}
196-
else
197-
{
199+
} else {
198200
return (val + I - 1) & ~(T)(I - 1);
199201
}
200202
return 0; // BUG: Cuda complains about missing return value with constexpr if

GPU/GPUTracking/DataCompression/GPUTPCCompressionKernels.cxx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,10 @@ GPUdi() GPUTPCCompressionGatherKernels::Vec128* GPUTPCCompressionGatherKernels::
339339
template <typename T, typename S>
340340
GPUdi() bool GPUTPCCompressionGatherKernels::isAlignedTo(const S* ptr)
341341
{
342-
CONSTEXPRIF(alignof(S) >= alignof(T))
343-
{
342+
if CONSTEXPR17 (alignof(S) >= alignof(T)) {
344343
static_cast<void>(ptr);
345344
return true;
346-
}
347-
else
348-
{
345+
} else {
349346
return reinterpret_cast<size_t>(ptr) % alignof(T) == 0;
350347
}
351348
return false; // BUG: Cuda complains about missing return value with constexpr if

0 commit comments

Comments
 (0)