Skip to content

Commit 8aeaa54

Browse files
committed
GPU: Simplify __OPENCL__ macros using __OPENCL1__
1 parent bdb39f6 commit 8aeaa54

20 files changed

+43
-40
lines changed

GPU/Common/GPUCommonConstants.h

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

1818
#include "GPUCommonDef.h"
1919

20-
#if !defined(__OPENCL__) || defined(__OPENCLCPP__)
20+
#if !defined(__OPENCL1__)
2121
namespace GPUCA_NAMESPACE::gpu::gpu_common_constants
2222
{
2323
static CONSTEXPR const float kCLight = 0.000299792458f;

GPU/Common/GPUCommonDef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//Some GPU configuration settings, must be included first
3131
#include "GPUCommonDefSettings.h"
3232

33-
#if (!defined(__OPENCL__) || defined(__OPENCLCPP__)) && (!(defined(__CINT__) || defined(__ROOTCINT__)) || defined(__CLING__)) && defined(__cplusplus) && __cplusplus >= 201103L
33+
#if !defined(__OPENCL1__) && (!(defined(__CINT__) || defined(__ROOTCINT__)) || defined(__CLING__)) && defined(__cplusplus) && __cplusplus >= 201103L
3434
#define GPUCA_NOCOMPAT // C++11 + No old ROOT5 + No old OpenCL
3535
#ifndef __OPENCL__
3636
#define GPUCA_NOCOMPAT_ALLOPENCL // + No OpenCL at all
@@ -82,7 +82,7 @@
8282
#define GPUCA_NAMESPACE o2
8383
#endif
8484

85-
#if (defined(__CUDACC__) && defined(GPUCA_CUDA_NO_CONSTANT_MEMORY)) || (defined(__HIPCC__) && defined(GPUCA_HIP_NO_CONSTANT_MEMORY)) || (defined(__OPENCL__) && !defined(__OPENCLCPP__) && defined(GPUCA_OPENCL_NO_CONSTANT_MEMORY)) || (defined(__OPENCLCPP__) && defined(GPUCA_OPENCLCPP_NO_CONSTANT_MEMORY))
85+
#if (defined(__CUDACC__) && defined(GPUCA_CUDA_NO_CONSTANT_MEMORY)) || (defined(__HIPCC__) && defined(GPUCA_HIP_NO_CONSTANT_MEMORY)) || (defined(__OPENCL1__) && defined(GPUCA_OPENCL_NO_CONSTANT_MEMORY)) || (defined(__OPENCLCPP__) && defined(GPUCA_OPENCLCPP_NO_CONSTANT_MEMORY))
8686
#define GPUCA_NO_CONSTANT_MEMORY
8787
#elif defined(__CUDACC__) || defined(__HIPCC__)
8888
#define GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM

GPU/Common/GPUCommonMath.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <cstdint>
3232
#endif
3333

34-
#if !defined(__OPENCL__) || defined(__OPENCLCPP__)
34+
#if !defined(__OPENCL1__)
3535
namespace GPUCA_NAMESPACE
3636
{
3737
namespace gpu
@@ -220,7 +220,7 @@ GPUdi() uint32_t GPUCommonMath::Float2UIntReint(const float& x)
220220
{
221221
#if defined(GPUCA_GPUCODE_DEVICE) && (defined(__CUDACC__) || defined(__HIPCC__))
222222
return __float_as_uint(x);
223-
#elif defined(GPUCA_GPUCODE_DEVICE) && (defined(__OPENCL__) || defined(__OPENCLCPP__))
223+
#elif defined(GPUCA_GPUCODE_DEVICE) && defined(__OPENCL__)
224224
return as_uint(x);
225225
#else
226226
return reinterpret_cast<const uint32_t&>(x);
@@ -289,7 +289,7 @@ GPUhdi() void GPUCommonMath::SinCosd(double x, double& s, double& c)
289289

290290
GPUdi() uint32_t GPUCommonMath::Clz(uint32_t x)
291291
{
292-
#if (defined(__GNUC__) || defined(__clang__) || defined(__CUDACC__) || defined(__HIPCC__)) && (!defined(__OPENCL__) || defined(__OPENCLCPP__))
292+
#if (defined(__GNUC__) || defined(__clang__) || defined(__CUDACC__) || defined(__HIPCC__)) && !defined(__OPENCL1__)
293293
return x == 0 ? 32 : CHOICE(__builtin_clz(x), __clz(x), __builtin_clz(x)); // use builtin if available
294294
#else
295295
for (int32_t i = 31; i >= 0; i--) {
@@ -303,7 +303,7 @@ GPUdi() uint32_t GPUCommonMath::Clz(uint32_t x)
303303

304304
GPUdi() uint32_t GPUCommonMath::Popcount(uint32_t x)
305305
{
306-
#if (defined(__GNUC__) || defined(__clang__) || defined(__CUDACC__) || defined(__HIPCC__)) && (!defined(__OPENCL__) /*|| defined(__OPENCLCPP__)*/) // TODO: remove OPENCLCPP workaround when reported SPIR-V bug is fixed
306+
#if (defined(__GNUC__) || defined(__clang__) || defined(__CUDACC__) || defined(__HIPCC__)) && (!defined(__OPENCL__) /* !defined(__OPENCL1__)*/) // TODO: exclude only OPENCLC (not CPP) when reported SPIR-V bug is fixed
307307
// use builtin if available
308308
return CHOICE(__builtin_popcount(x), __popc(x), __builtin_popcount(x));
309309
#else
@@ -563,7 +563,7 @@ GPUdii() void GPUCommonMath::AtomicMinInternal(GPUglobalref() GPUgeneric() GPUAt
563563

564564
#undef CHOICE
565565

566-
#if !defined(__OPENCL__) || defined(__OPENCLCPP__)
566+
#if !defined(__OPENCL1__)
567567
}
568568
}
569569
#endif

GPU/Common/GPUCommonTypeTraits.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#ifndef GPUCA_GPUCODE_COMPILEKERNELS
2222
#include <type_traits>
2323
#endif
24-
#elif !defined(__OPENCL__) || defined(__OPENCLCPP__)
24+
#elif !defined(__OPENCL1__)
2525
// We just reimplement some type traits in std for the GPU
2626
namespace std
2727
{

GPU/GPUTracking/Base/GPUParam.inc

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

1818
#include "GPUParam.h"
1919
#include "GPUTPCGMMergedTrackHit.h"
20-
#if !defined(__OPENCL__) || defined(__OPENCLCPP__)
20+
#if !defined(__OPENCL1__)
2121
#include "GPUTPCClusterOccupancyMap.h"
2222
#endif
2323

@@ -228,7 +228,7 @@ GPUdi() void MEM_LG(GPUParam)::UpdateClusterError2ByState(int16_t clusterState,
228228
MEM_CLASS_PRE()
229229
GPUdi() float MEM_LG(GPUParam)::GetUnscaledMult(float time) const
230230
{
231-
#if !defined(__OPENCL__) || defined(__OPENCLCPP__)
231+
#if !defined(__OPENCL1__)
232232
if (!occupancyMap) {
233233
return 0.f;
234234
}

GPU/GPUTracking/Base/opencl-common/GPUReconstructionOCL.cl

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

1515
// clang-format off
1616
#define __OPENCL__
17+
#if defined(__cplusplus) && __cplusplus >= 201703L
18+
#define __OPENCLCPP__
19+
#else
20+
#define __OPENCL1__
21+
#endif
1722
#define GPUCA_GPUTYPE_OPENCL
1823

1924
#ifdef __OPENCLCPP__

GPU/GPUTracking/Base/opencl2/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ set(OCL_DEFINECL "-D$<JOIN:$<TARGET_PROPERTY:O2::GPUTracking,COMPILE_DEFINITIONS
3232
-I${CMAKE_SOURCE_DIR}/Detectors/TRD/base/src
3333
-I${CMAKE_SOURCE_DIR}/Detectors/Base/src
3434
-I${CMAKE_SOURCE_DIR}/DataFormats/Reconstruction/src
35-
-I${CMAKE_SOURCE_DIR}/Detectors/ITSMFT/ITS/tracking/cuda/include
36-
-D__OPENCLCPP__
3735
)
3836

3937
set(SRCS GPUReconstructionOCL2.cxx)

GPU/GPUTracking/DataTypes/GPUDataTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ namespace gpu
125125
#define GPUCA_RECO_STEP GPUDataTypes
126126
#endif
127127

128-
#if defined(__OPENCL__) && !defined(__OPENCLCPP__)
128+
#if defined(__OPENCL1__)
129129
MEM_CLASS_PRE() // Macro with some template magic for OpenCL 1.2
130130
#endif
131131
class GPUTPCTrack;

GPU/GPUTracking/DataTypes/GPUO2DataTypes.h

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

1818
// Pull in several O2 headers with basic data types, or load a header with empty fake classes if O2 headers not available
1919

20-
#if defined(GPUCA_HAVE_O2HEADERS) && (!defined(__OPENCL__) || defined(__OPENCLCPP__))
20+
#if defined(GPUCA_HAVE_O2HEADERS) && !defined(__OPENCL1__)
2121
#include "DataFormatsTPC/ClusterNative.h"
2222
#include "DataFormatsTPC/Digit.h"
2323
#include "DetectorsBase/MatLayerCylSet.h"
@@ -27,7 +27,7 @@
2727
#include "GPUO2FakeClasses.h"
2828
#endif
2929

30-
#if !defined(__OPENCL__) || defined(__OPENCLCPP__)
30+
#if !defined(__OPENCL1__)
3131
#include "GPUdEdxInfo.h"
3232
#endif
3333

GPU/GPUTracking/DataTypes/GPUSettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class GPUSettings
4545
RejectionStrategyA = 1,
4646
RejectionStrategyB = 2 };
4747

48-
#if !defined(__OPENCL__) || defined(__OPENCLCPP__)
48+
#if !defined(__OPENCL1__)
4949
static CONSTEXPR const uint32_t TPC_MAX_TF_TIME_BIN = ((256 * 3564 + 2 * 8 - 2) / 8);
5050
#endif
5151
};

0 commit comments

Comments
 (0)