Skip to content

Commit 94f37bc

Browse files
committed
GPUTracking: place shared constants in the constant address space
MSL requires every variable at program scope, class-scope statics included, to name an address space and diagnoses it at the declaration, so these headers broke any device translation unit that included them regardless of whether the constants were used. GPUglobalconstexpr() expands to constexpr everywhere except Metal, where it adds constant. Last of the series: with this the Metal translation unit has no program-scope diagnostics left, down from 208.
1 parent ba4b997 commit 94f37bc

18 files changed

Lines changed: 90 additions & 73 deletions

GPU/GPUTracking/Base/GPUConstantMem.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#ifndef GPUCONSTANTMEM_H
1616
#define GPUCONSTANTMEM_H
1717

18+
#include "GPUCommonDef.h"
19+
1820
#include "GPUTPCTracker.h"
1921
#include "GPUParam.h"
2022
#include "GPUDataTypesIO.h"
@@ -87,12 +89,12 @@ union GPUConstantMemCopyable {
8789
};
8890

8991
#if defined(GPUCA_GPUCODE)
90-
static constexpr size_t gGPUConstantMemBufferSize = (sizeof(GPUConstantMem) + sizeof(uint4) - 1);
92+
static GPUglobalconstexpr() size_t gGPUConstantMemBufferSize = (sizeof(GPUConstantMem) + sizeof(uint4) - 1);
9193
#endif
9294
} // namespace o2::gpu
9395
#if defined(GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM)
9496
GPUconstant() o2::gpu::GPUConstantMemCopyable gGPUConstantMemBuffer; // TODO: This should go into o2::gpu namespace, but then CUDA or HIP would not find the symbol
95-
#endif // GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM
97+
#endif // GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM
9698
namespace o2::gpu
9799
{
98100

GPU/GPUTracking/Base/GPUParam.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace internal
4141
{
4242
template <class T, class S>
4343
struct GPUParam_t {
44-
static constexpr float dAlpha = 0.349066f;
44+
static GPUglobalconstexpr() float dAlpha = 0.349066f;
4545

4646
T rec;
4747
S par;

GPU/GPUTracking/DataCompression/GPUTPCCompression.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#ifndef GPUTPCCOMPRESSION_H
1616
#define GPUTPCCOMPRESSION_H
1717

18+
#include "GPUCommonDef.h"
19+
1820
#include "GPUDef.h"
1921
#include "GPUProcessor.h"
2022
#include "GPUCommonMath.h"
@@ -46,14 +48,14 @@ class GPUTPCCompression : public GPUProcessor
4648
void* SetPointersMemory(void* mem);
4749
#endif
4850

49-
static constexpr uint32_t P_MAX_QMAX = 1 << 10;
50-
static constexpr uint32_t P_MAX_REGULAR_QTOT = 5 * 5 * P_MAX_QMAX;
51-
static constexpr uint32_t P_MAX_SATURATED_QTOT = 1 << 16; // Need two different limits as saturated clusters use full u16 range for qTot
52-
static constexpr uint32_t P_MAX_TIME = 1 << 24;
53-
static constexpr uint32_t P_MAX_PAD = 1 << 16;
54-
static constexpr uint32_t P_MAX_SIGMA = 1 << 8;
55-
static constexpr uint32_t P_MAX_FLAGS = 1 << 8;
56-
static constexpr uint32_t P_MAX_QPT = 1 << 8;
51+
static GPUglobalconstexpr() uint32_t P_MAX_QMAX = 1 << 10;
52+
static GPUglobalconstexpr() uint32_t P_MAX_REGULAR_QTOT = 5 * 5 * P_MAX_QMAX;
53+
static GPUglobalconstexpr() uint32_t P_MAX_SATURATED_QTOT = 1 << 16; // Need two different limits as saturated clusters use full u16 range for qTot
54+
static GPUglobalconstexpr() uint32_t P_MAX_TIME = 1 << 24;
55+
static GPUglobalconstexpr() uint32_t P_MAX_PAD = 1 << 16;
56+
static GPUglobalconstexpr() uint32_t P_MAX_SIGMA = 1 << 8;
57+
static GPUglobalconstexpr() uint32_t P_MAX_FLAGS = 1 << 8;
58+
static GPUglobalconstexpr() uint32_t P_MAX_QPT = 1 << 8;
5759

5860
GPUd() static void truncateSignificantBitsCharge(uint16_t& charge, const GPUParam& param) { truncateSignificantBits(charge, param.rec.tpc.sigBitsCharge, P_MAX_REGULAR_QTOT); }
5961
GPUd() static void truncateSignificantBitsChargeMax(uint16_t& charge, const GPUParam& param) { truncateSignificantBits(charge, param.rec.tpc.sigBitsCharge, P_MAX_QMAX); }
@@ -71,7 +73,7 @@ class GPUTPCCompression : public GPUProcessor
7173
uint32_t nStoredUnattachedClusters = 0;
7274
};
7375

74-
constexpr static uint32_t NSECTORS = GPUTPCGeometry::NSECTORS;
76+
GPUglobalconstexpr() static uint32_t NSECTORS = GPUTPCGeometry::NSECTORS;
7577

7678
o2::tpc::CompressedClustersPtrs mPtrs;
7779
o2::tpc::CompressedClusters* mOutput = nullptr;

GPU/GPUTracking/DataCompression/GPUTPCDecompression.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#ifndef GPUTPCDECOMPRESSION_H
1616
#define GPUTPCDECOMPRESSION_H
1717

18+
#include "GPUCommonDef.h"
19+
1820
#include "GPUDef.h"
1921
#include "GPUProcessor.h"
2022
#include "GPUCommonMath.h"
@@ -50,7 +52,7 @@ class GPUTPCDecompression : public GPUProcessor
5052
#endif
5153

5254
protected:
53-
constexpr static uint32_t NSECTORS = GPUTPCGeometry::NSECTORS;
55+
GPUglobalconstexpr() static uint32_t NSECTORS = GPUTPCGeometry::NSECTORS;
5456
o2::tpc::CompressedClusters mInputGPU;
5557

5658
uint32_t mMaxNativeClustersPerBuffer;

GPU/GPUTracking/DataTypes/CalibdEdxTrackTopologyPol.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ class CalibdEdxTrackTopologyPol : public o2::gpu::FlatObject
197197
/// ================================================================================================
198198

199199
private:
200-
constexpr static int32_t FFits{10}; ///< total number of fits: 10 regions * 2 charge types
201-
constexpr static int32_t FDim{5}; ///< dimensions of polynomials
202-
constexpr static int32_t FDegree{3}; ///< degree of polynomials
200+
GPUglobalconstexpr() static int32_t FFits { 10 }; ///< total number of fits: 10 regions * 2 charge types
201+
GPUglobalconstexpr() static int32_t FDim { 5 }; ///< dimensions of polynomials
202+
GPUglobalconstexpr() static int32_t FDegree { 3 }; ///< degree of polynomials
203203
o2::gpu::NDPiecewisePolynomials<FDim, FDegree, false> mCalibPolsqTot[FFits]; ///< polynomial objects storage for the polynomials for qTot
204204
o2::gpu::NDPiecewisePolynomials<FDim, FDegree, false> mCalibPolsqMax[FFits]; ///< polynomial objects storage for the polynomials for qMax
205205
float mScalingFactorsqTot[FFits]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; ///< value which is used to scale the result of the polynomial for qTot (can be used for normalization)

GPU/GPUTracking/DataTypes/CalibdEdxTrackTopologySpline.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#ifndef CalibdEdxTrackTopologySpline_H
1818
#define CalibdEdxTrackTopologySpline_H
1919

20+
#include "GPUCommonDef.h"
21+
2022
#include "FlatObject.h"
2123
#include "Spline.h"
2224
#include "GPUCommonRtypes.h"
@@ -225,8 +227,8 @@ class CalibdEdxTrackTopologySpline : public o2::gpu::FlatObject
225227
#endif
226228

227229
private:
228-
constexpr static uint32_t FSplines = 10; ///< number of splines stored for each type
229-
constexpr static int32_t FDimX = 3; ///< dimensionality of the splines
230+
GPUglobalconstexpr() static uint32_t FSplines = 10; ///< number of splines stored for each type
231+
GPUglobalconstexpr() static int32_t FDimX = 3; ///< dimensionality of the splines
230232
SplineType mCalibSplinesqMax[FSplines]; ///< spline objects storage for the splines for qMax
231233
SplineType mCalibSplinesqTot[FSplines]; ///< spline objects storage for the splines for qTot
232234
float mMaxTanTheta{2.f}; ///< max tanTheta for which the correction is stored

GPU/GPUTracking/DataTypes/GPUDataTypesIO.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ typedef GPUCalibObjectsTemplate<DefaultPtr> GPUCalibObjects; // NOTE: These 2 mu
137137
typedef GPUCalibObjectsTemplate<ConstPtr> GPUCalibObjectsConst;
138138

139139
struct GPUTrackingInOutZS {
140-
static constexpr uint32_t NSECTORS = o2::tpc::constants::MAXSECTOR;
141-
static constexpr uint32_t NENDPOINTS = 20;
140+
static GPUglobalconstexpr() uint32_t NSECTORS = o2::tpc::constants::MAXSECTOR;
141+
static GPUglobalconstexpr() uint32_t NENDPOINTS = 20;
142142
struct GPUTrackingInOutZSSector {
143143
const void* const* zsPtr[NENDPOINTS];
144144
const uint32_t* nZSPtr[NENDPOINTS];
@@ -155,7 +155,7 @@ struct GPUTrackingInOutZS {
155155
};
156156

157157
struct GPUTrackingInOutDigits {
158-
static constexpr uint32_t NSECTORS = o2::tpc::constants::MAXSECTOR;
158+
static GPUglobalconstexpr() uint32_t NSECTORS = o2::tpc::constants::MAXSECTOR;
159159
const o2::tpc::Digit* tpcDigits[NSECTORS] = {nullptr};
160160
size_t nTPCDigits[NSECTORS] = {0};
161161
const GPUTPCDigitsMCInput* tpcDigitsMC = nullptr;
@@ -165,7 +165,7 @@ struct GPUTrackingInOutPointers {
165165
GPUTrackingInOutPointers() = default;
166166

167167
// TPC
168-
static constexpr uint32_t NSECTORS = o2::tpc::constants::MAXSECTOR;
168+
static GPUglobalconstexpr() uint32_t NSECTORS = o2::tpc::constants::MAXSECTOR;
169169
const GPUTrackingInOutZS* tpcZS = nullptr;
170170
const GPUTrackingInOutDigits* tpcPackedDigits = nullptr;
171171
const GPUTPCClusterData* clusterData[NSECTORS] = {nullptr};

GPU/GPUTracking/DataTypes/GPUSettings.h

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

47-
static constexpr const uint32_t TPC_MAX_TF_TIME_BIN = ((256 * 3564 + 2 * 8 - 2) / 8);
47+
static GPUglobalconstexpr() const uint32_t TPC_MAX_TF_TIME_BIN = ((256 * 3564 + 2 * 8 - 2) / 8);
4848
};
4949

5050
// Settings describing the global run parameters

GPU/GPUTracking/DataTypes/GPUTPCGMPolynomialField.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ class GPUTPCGMPolynomialField
5353

5454
void Print() const;
5555

56-
static constexpr const int32_t NTPCM = 10; // number of coefficients
57-
static constexpr const int32_t NTRDM = 20; // number of coefficients for the TRD field
58-
static constexpr const int32_t NITSM = 10; // number of coefficients for the ITS field
56+
static GPUglobalconstexpr() const int32_t NTPCM = 10; // number of coefficients
57+
static GPUglobalconstexpr() const int32_t NTRDM = 20; // number of coefficients for the TRD field
58+
static GPUglobalconstexpr() const int32_t NITSM = 10; // number of coefficients for the ITS field
5959

6060
GPUd() static void GetPolynomsTpc(float x, float y, float z, float f[NTPCM]);
6161
GPUd() static void GetPolynomsTrd(float x, float y, float z, float f[NTRDM]);

GPU/GPUTracking/DataTypes/GPUTPCGeometry.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace o2::gpu
2525
namespace gputpcgeometry_internal
2626
{
2727
#ifndef GPUCA_RUN2 // clang-format off
28-
constexpr uint32_t NREGIONS = 10;
28+
GPUglobalconstexpr() uint32_t NREGIONS = 10;
2929
GPUconstexpr() float mX[o2::tpc::constants::MAXGLOBALPADROW] = {85.225f, 85.975f, 86.725f, 87.475f, 88.225f, 88.975f, 89.725f, 90.475f, 91.225f, 91.975f, 92.725f, 93.475f, 94.225f, 94.975f, 95.725f, 96.475f, 97.225f, 97.975f, 98.725f, 99.475f, 100.225f, 100.975f,
3030
101.725f, 102.475f, 103.225f, 103.975f, 104.725f, 105.475f, 106.225f, 106.975f, 107.725f, 108.475f, 109.225f, 109.975f, 110.725f, 111.475f, 112.225f, 112.975f, 113.725f, 114.475f, 115.225f, 115.975f, 116.725f, 117.475f,
3131
118.225f, 118.975f, 119.725f, 120.475f, 121.225f, 121.975f, 122.725f, 123.475f, 124.225f, 124.975f, 125.725f, 126.475f, 127.225f, 127.975f, 128.725f, 129.475f, 130.225f, 130.975f, 131.725f, 135.2f, 136.2f, 137.2f,
@@ -61,8 +61,8 @@ GPUconstexpr() float mPadWidthRow[o2::tpc::constants::MAXGLOBALPADROW] = {.416,
6161
.604, .604, .604, .604, .604, .604, .604, .604, .604, .604, .604, .604, .604,
6262
.607, .607, .607, .607, .607, .607, .607, .607, .607, .607, .607, .607};
6363

64-
constexpr float TPC_LENGTH = 250.f;
65-
constexpr float FACTOR_T2Z = 250.f / 512.f; // Used in compression, must remain constant at 250cm, 512 time bins!
64+
GPUglobalconstexpr() float TPC_LENGTH = 250.f;
65+
GPUglobalconstexpr() float FACTOR_T2Z = 250.f / 512.f; // Used in compression, must remain constant at 250cm, 512 time bins!
6666
#else
6767
constexpr uint32_t NREGIONS = 3;
6868
GPUconstexpr() float mX[o2::tpc::constants::MAXGLOBALPADROW] = {85.195f, 85.945f, 86.695f, 87.445f, 88.195f, 88.945f, 89.695f, 90.445f, 91.195f, 91.945f, 92.695f, 93.445f, 94.195f, 94.945f, 95.695f, 96.445f, 97.195f, 97.945f, 98.695f, 99.445f, 100.195f, 100.945f, 101.695f,
@@ -101,11 +101,11 @@ GPUconstexpr() float mSectorAlpha[o2::tpc::constants::MAXSECTOR] = {0x1.65718ep-
101101

102102
class GPUTPCGeometry
103103
{
104-
static constexpr float FACTOR_Z2T = 1.f / gputpcgeometry_internal::FACTOR_T2Z;
104+
static GPUglobalconstexpr() float FACTOR_Z2T = 1.f / gputpcgeometry_internal::FACTOR_T2Z;
105105

106106
public:
107-
static constexpr uint32_t NSECTORS = o2::tpc::constants::MAXSECTOR;
108-
static constexpr uint32_t NROWS = o2::tpc::constants::MAXGLOBALPADROW;
107+
static GPUglobalconstexpr() uint32_t NSECTORS = o2::tpc::constants::MAXSECTOR;
108+
static GPUglobalconstexpr() uint32_t NROWS = o2::tpc::constants::MAXGLOBALPADROW;
109109

110110
#ifndef GPUCA_RUN2
111111
GPUd() static constexpr int32_t GetRegion(int32_t row) { return gputpcgeometry_internal::mRegion[row]; }
@@ -121,7 +121,8 @@ class GPUTPCGeometry
121121
GPUd() static constexpr int32_t MaxNPadsPerRow() { return 138; }
122122
GPUd() static constexpr float PadWidth(int32_t row) { return (gputpcgeometry_internal::mPadWidthRow[row]); }
123123
#else
124-
GPUd() static constexpr int32_t GetRegion(int32_t row) { return (row < 63 ? 0 : row < 63 + 64 ? 1 : 2); }
124+
GPUd() static constexpr int32_t GetRegion(int32_t row) { return (row < 63 ? 0 : row < 63 + 64 ? 1
125+
: 2); }
125126
GPUd() static constexpr int32_t GetRegionRows(int32_t region) { return 0; } // dummy
126127
GPUd() static constexpr int32_t GetRegionStart(int32_t region) { return 0; } // dummy
127128
GPUd() static constexpr int32_t GetROC(int32_t row) { return GetRegion(row); }

0 commit comments

Comments
 (0)