Skip to content

Commit 397f155

Browse files
committed
Clean up some horrid #ifdef magic, and fix some more OpenCL-C++ compilation (+ fix AliRoot Compilation)
1 parent 98e2068 commit 397f155

7 files changed

Lines changed: 31 additions & 21 deletions

File tree

GPU/Common/GPUCommonDef.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
//Some GPU configuration settings, must be included first
2020
#include "GPUCommonDefSettings.h"
2121

22+
#if (!defined(__OPENCL__) || defined(__OPENCLCPP__)) && (!(defined(__CINT__) || defined(__ROOTCINT__)) || defined(__CLING__)) && defined(__cplusplus) && __cplusplus >= 201103L
23+
#define GPUCA_NOCOMPAT // C++11 + No old ROOT5 + No old OpenCL
24+
#ifndef __OPENCL__
25+
#define GPUCA_NOCOMPAT_ALLOPENCL // + No OpenCL at all
26+
#endif
27+
#ifndef __CINT__
28+
#define GPUCA_NOCOMPAT_ALLCINT // + No ROOT CINT at all
29+
#endif
30+
#endif
31+
2232
#if !(defined(__CINT__) || defined(__ROOTCINT__) || defined(__CLING__) || defined(__ROOTCLING__) || defined(G__ROOT)) //No GPU code for ROOT
2333
#if defined(__CUDACC__) || defined(__OPENCL__) || defined(__HIPCC__)
2434
#define GPUCA_GPUCODE //Compiled by GPU compiler
@@ -30,14 +40,14 @@
3040
#endif
3141

3242
//Definitions for C++11 features not supported by CINT / OpenCL
33-
#if ((defined(__CINT__) || defined(__ROOTCINT__)) && !defined(__CLING__)) || (defined(__OPENCL__) && !defined(__OPENCLCPP__))
34-
#define CON_DELETE
35-
#define CON_DEFAULT
36-
#define CONSTEXPR const
37-
#else
43+
#ifdef GPUCA_NOCOMPAT
3844
#define CON_DELETE = delete
3945
#define CON_DEFAULT = default
4046
#define CONSTEXPR constexpr
47+
#else
48+
#define CON_DELETE
49+
#define CON_DEFAULT
50+
#define CONSTEXPR const
4151
#endif
4252

4353
//Set AliRoot / O2 namespace

GPU/Common/GPUDefOpenCL12Templates.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#ifndef GPUDEFOPENCL12TEMPLATES_H
1616
#define GPUDEFOPENCL12TEMPLATES_H
1717

18-
#if (defined(__OPENCL__) && !defined(__OPENCLCPP__)) || (defined(__CINT__) && defined(ROOT_VERSION_CODE) && ROOT_VERSION_CODE < 393216) // Non-CPP OpenCL and ROOT5
19-
#define GPUCA_CPP11_INIT(...)
20-
#else
18+
#ifdef GPUCA_NOCOMPAT
2119
#define GPUCA_CPP11_INIT(...) __VA_ARGS__
20+
#else
21+
#define GPUCA_CPP11_INIT(...)
2222
#endif
2323

2424
//Special macros for OpenCL rev. 1.2 (encode address space in template parameter)

GPU/GPUTracking/Base/GPUConstantMem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "GPUTPCTracker.h"
1818
#include "GPUParam.h"
1919

20-
#if (!defined(__OPENCL__) || defined(__OPENCLCPP__)) && (!defined(GPUCA_GPULIBRARY) || !defined(GPUCA_ALIROOT_LIB)) && (!defined(__CINT__) && !defined(__ROOTCINT__))
20+
#if defined(GPUCA_NOCOMPAT_ALLCINT) && (!defined(GPUCA_GPULIBRARY) || !defined(GPUCA_ALIROOT_LIB))
2121
#include "GPUTPCConvert.h"
2222
#include "GPUTPCCompression.h"
2323
#include "GPUTPCGMMerger.h"

GPU/GPUTracking/Base/GPUDataTypes.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
#include "GPUCommonDef.h"
1818

19-
#if (!defined(__OPENCL__) || defined(__OPENCLCPP__)) && (!(defined(__CINT__) || defined(__ROOTCINT__)) || defined(__CLING__)) && defined(__cplusplus) && __cplusplus >= 201103L
20-
#define GPUDATATYPES_NOCOMPAT
19+
#ifdef GPUCA_NOCOMPAT_ALLOPENCL
2120
#include <type_traits>
2221
#include "GPUTRDDef.h"
2322

@@ -40,7 +39,7 @@ namespace GPUCA_NAMESPACE
4039
{
4140
namespace gpu
4241
{
43-
#ifdef GPUDATATYPES_NOCOMPAT
42+
#ifdef GPUCA_NOCOMPAT_ALLOPENCL
4443
#include "utils/bitfield.h"
4544
#define ENUM_CLASS class
4645
#define ENUM_UINT : unsigned int
@@ -87,7 +86,7 @@ class GPUDataTypes
8786
TRDTracklets = 16,
8887
TRDTracks = 32 };
8988

90-
#ifdef GPUDATATYPES_NOCOMPAT
89+
#ifdef GPUCA_NOCOMPAT_ALLOPENCL
9190
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" };
9291
typedef bitfield<RecoStep, unsigned int> RecoStepField;
9392
typedef bitfield<InOutType, unsigned int> InOutTypeField;
@@ -96,7 +95,7 @@ class GPUDataTypes
9695
static DeviceType GetDeviceType(const char* type);
9796
};
9897

99-
#ifdef GPUDATATYPES_NOCOMPAT
98+
#ifdef GPUCA_NOCOMPAT_ALLOPENCL
10099
struct GPURecoStepConfiguration {
101100
GPUDataTypes::RecoStepField steps = 0;
102101
GPUDataTypes::InOutTypeField inputs = 0;
@@ -134,7 +133,6 @@ struct GPUTrackingInOutPointers {
134133
unsigned int nTRDTrackletsMC = 0;
135134
friend class GPUReconstruction;
136135
};
137-
#undef GPUDATATYPES_NOCOMPAT
138136
#endif
139137

140138
#undef ENUM_CLASS

GPU/GPUTracking/Base/GPUGeneralKernels.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class GPUKernelTemplate
3838
{
3939
return &processors;
4040
}
41-
#if ((!defined(__OPENCL__) || defined(__OPENCLCPP__)) && (!(defined(__CINT__) || defined(__ROOTCINT__)) || defined(__CLING__)))
41+
#ifdef GPUCA_NOCOMPAT
4242
template <int iKernel, typename... Args>
4343
GPUd() static void Thread(int nBlocks, int nThreads, int iBlock, int iThread, GPUsharedref() GPUTPCSharedMemory& smem, processorType& processors, Args... args)
4444
{

GPU/GPUTracking/DataCompression/GPUTPCCompression.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ namespace o2
2626
{
2727
namespace tpc
2828
{
29-
struct CompressedClusters {
29+
template <class T>
30+
struct CompressedClustersPtrs_helper {
31+
};
32+
struct CompressedClustersCounters {
3033
};
34+
using CompressedClusters = CompressedClustersPtrs_helper<CompressedClustersCounters>;
3135
struct CompressedClustersPtrsOnly {
3236
};
3337
} // namespace tpc

GPU/GPUTracking/Standalone/utils/bitfield.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
#ifndef Q_BITFIELD_H
1515
#define Q_BITFIELD_H
1616

17-
#if (!defined(__OPENCL__) || defined(__OPENCLCPP__)) && (!(defined(__CINT__) || defined(__ROOTCINT__)) || defined(__CLING__)) && defined(__cplusplus) && __cplusplus >= 201103L
18-
#define Q_BITFIELD_NOCOMPAT
17+
#ifdef GPUCA_NOCOMPAT_ALLOPENCL
1918
#include <type_traits>
2019
#endif
2120

@@ -68,10 +67,9 @@ class bitfield
6867
bool isSet(const bitfield& v) const { return *this & v; }
6968
bool isSet(const S v) const { return bits & v; }
7069

71-
#ifdef Q_BITFIELD_NOCOMPAT
70+
#ifdef GPUCA_NOCOMPAT_ALLOPENCL
7271
static_assert(std::is_integral<S>::value, "Storage type non integral");
7372
static_assert(sizeof(S) >= sizeof(T), "Storage type has insufficient capacity");
74-
#undef Q_BITFIELD_NOCOMPAT
7573
#endif
7674

7775
private:

0 commit comments

Comments
 (0)