Skip to content

Commit 4e56226

Browse files
committed
ReconstructionDataFormats: place shared constants in the constant address space
MSL requires every variable at program scope, class-scope statics included, to name an address space. GPUglobalconstexpr() expands to constexpr everywhere except Metal, so this is a no-op for host, CUDA, HIP, OpenCL and cling.
1 parent 8284702 commit 4e56226

4 files changed

Lines changed: 67 additions & 64 deletions

File tree

‎DataFormats/Reconstruction/include/ReconstructionDataFormats/GlobalTrackID.h‎

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

19+
#include "GPUCommonDef.h"
20+
1921
#include "GPUCommonBitSet.h"
2022
#include "CommonDataFormat/AbstractRef.h"
2123
#include "DetectorsCommonDataFormats/DetID.h"
@@ -78,8 +80,8 @@ class GlobalTrackID : public AbstractRef<25, 5, 2>
7880
static constexpr std::string_view NONE{"none"}; ///< keywork for no sources
7981
static constexpr std::string_view ALL{"all"}; ///< keywork for all sources
8082
#endif
81-
static constexpr mask_t MASK_ALL = (1u << NSources) - 1;
82-
static constexpr mask_t MASK_NONE = 0;
83+
static GPUglobalconstexpr() mask_t MASK_ALL = (1u << NSources) - 1;
84+
static GPUglobalconstexpr() mask_t MASK_NONE = 0;
8385

8486
// methods for detector level manipulations
8587
GPUdi() static constexpr DetID::mask_t getSourceDetectorsMask(int i);

‎DataFormats/Reconstruction/include/ReconstructionDataFormats/PID.h‎

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace o2cp = o2::constants::physics;
3333
namespace pid_constants // GPUs currently cannot have static constexpr array members
3434
{
3535
typedef uint8_t ID;
36-
static constexpr ID NIDsTot = 19;
36+
static GPUglobalconstexpr() ID NIDsTot = 19;
3737

3838
#if !defined(GPUCA_GPUCODE_DEVICE) || defined(GPUCA_GPU_DEBUG_PRINT)
3939
GPUconstexpr() const char* sNames[NIDsTot + 1] = ///< defined particle names
@@ -49,24 +49,24 @@ GPUconstexpr() const float sMasses[NIDsTot] = ///< defined particle masses
4949

5050
GPUconstexpr() const float sMasses2[NIDsTot] = ///< defined particle masses^2
5151
{o2cp::MassElectron * o2cp::MassElectron,
52-
o2cp::MassMuon* o2cp::MassMuon,
53-
o2cp::MassPionCharged* o2cp::MassPionCharged,
54-
o2cp::MassKaonCharged* o2cp::MassKaonCharged,
55-
o2cp::MassProton* o2cp::MassProton,
56-
o2cp::MassDeuteron* o2cp::MassDeuteron,
57-
o2cp::MassTriton* o2cp::MassTriton,
58-
o2cp::MassHelium3* o2cp::MassHelium3,
59-
o2cp::MassAlpha* o2cp::MassAlpha,
60-
o2cp::MassPionNeutral* o2cp::MassPionNeutral,
61-
o2cp::MassPhoton* o2cp::MassPhoton,
62-
o2cp::MassKaonNeutral* o2cp::MassKaonNeutral,
63-
o2cp::MassLambda* o2cp::MassLambda,
64-
o2cp::MassHyperTriton* o2cp::MassHyperTriton,
65-
o2cp::MassHyperhydrog4* o2cp::MassHyperhydrog4,
66-
o2cp::MassXiMinus* o2cp::MassXiMinus,
67-
o2cp::MassOmegaMinus* o2cp::MassOmegaMinus,
68-
o2cp::MassHyperHelium4* o2cp::MassHyperHelium4,
69-
o2cp::MassHyperHelium5* o2cp::MassHyperHelium5};
52+
o2cp::MassMuon * o2cp::MassMuon,
53+
o2cp::MassPionCharged * o2cp::MassPionCharged,
54+
o2cp::MassKaonCharged * o2cp::MassKaonCharged,
55+
o2cp::MassProton * o2cp::MassProton,
56+
o2cp::MassDeuteron * o2cp::MassDeuteron,
57+
o2cp::MassTriton * o2cp::MassTriton,
58+
o2cp::MassHelium3 * o2cp::MassHelium3,
59+
o2cp::MassAlpha * o2cp::MassAlpha,
60+
o2cp::MassPionNeutral * o2cp::MassPionNeutral,
61+
o2cp::MassPhoton * o2cp::MassPhoton,
62+
o2cp::MassKaonNeutral * o2cp::MassKaonNeutral,
63+
o2cp::MassLambda * o2cp::MassLambda,
64+
o2cp::MassHyperTriton * o2cp::MassHyperTriton,
65+
o2cp::MassHyperhydrog4 * o2cp::MassHyperhydrog4,
66+
o2cp::MassXiMinus * o2cp::MassXiMinus,
67+
o2cp::MassOmegaMinus * o2cp::MassOmegaMinus,
68+
o2cp::MassHyperHelium4 * o2cp::MassHyperHelium4,
69+
o2cp::MassHyperHelium5 * o2cp::MassHyperHelium5};
7070

7171
GPUconstexpr() const float sMasses2Z[NIDsTot] = ///< defined particle masses / Z
7272
{o2cp::MassElectron, o2cp::MassMuon,
@@ -91,34 +91,34 @@ class PID
9191
// particle identifiers, continuos starting from 0
9292
typedef pid_constants::ID ID;
9393

94-
static constexpr ID Electron = 0;
95-
static constexpr ID Muon = 1;
96-
static constexpr ID Pion = 2;
97-
static constexpr ID Kaon = 3;
98-
static constexpr ID Proton = 4;
99-
static constexpr ID Deuteron = 5;
100-
static constexpr ID Triton = 6;
101-
static constexpr ID Helium3 = 7;
102-
static constexpr ID Alpha = 8;
94+
static GPUglobalconstexpr() ID Electron = 0;
95+
static GPUglobalconstexpr() ID Muon = 1;
96+
static GPUglobalconstexpr() ID Pion = 2;
97+
static GPUglobalconstexpr() ID Kaon = 3;
98+
static GPUglobalconstexpr() ID Proton = 4;
99+
static GPUglobalconstexpr() ID Deuteron = 5;
100+
static GPUglobalconstexpr() ID Triton = 6;
101+
static GPUglobalconstexpr() ID Helium3 = 7;
102+
static GPUglobalconstexpr() ID Alpha = 8;
103103

104-
static constexpr ID First = Electron;
105-
static constexpr ID Last = Alpha; ///< if extra IDs added, update this !!!
106-
static constexpr ID NIDs = Last + 1; ///< number of defined IDs
104+
static GPUglobalconstexpr() ID First = Electron;
105+
static GPUglobalconstexpr() ID Last = Alpha; ///< if extra IDs added, update this !!!
106+
static GPUglobalconstexpr() ID NIDs = Last + 1; ///< number of defined IDs
107107

108108
// PID for derived particles
109-
static constexpr ID PI0 = 9;
110-
static constexpr ID Photon = 10;
111-
static constexpr ID K0 = 11;
112-
static constexpr ID Lambda = 12;
113-
static constexpr ID HyperTriton = 13;
114-
static constexpr ID Hyperhydrog4 = 14;
115-
static constexpr ID XiMinus = 15;
116-
static constexpr ID OmegaMinus = 16;
117-
static constexpr ID HyperHelium4 = 17;
118-
static constexpr ID HyperHelium5 = 18;
119-
static constexpr ID FirstExt = PI0;
120-
static constexpr ID LastExt = HyperHelium5;
121-
static constexpr ID NIDsTot = pid_constants::NIDsTot; ///< total number of defined IDs
109+
static GPUglobalconstexpr() ID PI0 = 9;
110+
static GPUglobalconstexpr() ID Photon = 10;
111+
static GPUglobalconstexpr() ID K0 = 11;
112+
static GPUglobalconstexpr() ID Lambda = 12;
113+
static GPUglobalconstexpr() ID HyperTriton = 13;
114+
static GPUglobalconstexpr() ID Hyperhydrog4 = 14;
115+
static GPUglobalconstexpr() ID XiMinus = 15;
116+
static GPUglobalconstexpr() ID OmegaMinus = 16;
117+
static GPUglobalconstexpr() ID HyperHelium4 = 17;
118+
static GPUglobalconstexpr() ID HyperHelium5 = 18;
119+
static GPUglobalconstexpr() ID FirstExt = PI0;
120+
static GPUglobalconstexpr() ID LastExt = HyperHelium5;
121+
static GPUglobalconstexpr() ID NIDsTot = pid_constants::NIDsTot; ///< total number of defined IDs
122122
static_assert(NIDsTot == LastExt + 1, "Incorrect NIDsTot, please update!");
123123

124124
GPUdDefault() PID() = default;
@@ -159,7 +159,8 @@ class PID
159159

160160
GPUdi() static constexpr ID nameToID(char const* name, ID id)
161161
{
162-
return id > LastExt ? id : sameStr(name, pid_constants::sNames[id]) ? id : nameToID(name, id + 1);
162+
return id > LastExt ? id : sameStr(name, pid_constants::sNames[id]) ? id
163+
: nameToID(name, id + 1);
163164
}
164165
#endif
165166

‎DataFormats/Reconstruction/include/ReconstructionDataFormats/TrackLTIntegral.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace track
2828
class TrackLTIntegral
2929
{
3030
public:
31-
static constexpr float NeglectTime = -1.; // if 1st mT slot contains this, don't fill time
31+
static GPUglobalconstexpr() float NeglectTime = -1.; // if 1st mT slot contains this, don't fill time
3232

3333
GPUdDefault() TrackLTIntegral() = default;
3434
GPUdDefault() TrackLTIntegral(const TrackLTIntegral& stc) = default;

‎DataFormats/Reconstruction/include/ReconstructionDataFormats/TrackParametrization.h‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ enum DirType : int { DirInward = -1,
9797
DirAuto = 0,
9898
DirOutward = 1 };
9999

100-
constexpr int kNParams = 5, kCovMatSize = 15, kLabCovMatSize = 21;
100+
GPUglobalconstexpr() int kNParams = 5, kCovMatSize = 15, kLabCovMatSize = 21;
101101

102-
constexpr float kCY2max = 100 * 100, // SigmaY<=100cm
103-
kCZ2max = 100 * 100, // SigmaZ<=100cm
104-
kCSnp2max = 1 * 1, // SigmaSin<=1
105-
kCTgl2max = 1 * 1, // SigmaTan<=1
106-
kC1Pt2max = 100 * 100, // Sigma1/Pt<=100 1/GeV
107-
kMostProbablePt = 0.6f, // Most Probable Pt (GeV), for running with Bz=0
108-
kCalcdEdxAuto = -999.f; // value indicating request for dedx calculation
102+
GPUglobalconstexpr() float kCY2max = 100 * 100, // SigmaY<=100cm
103+
kCZ2max = 100 * 100, // SigmaZ<=100cm
104+
kCSnp2max = 1 * 1, // SigmaSin<=1
105+
kCTgl2max = 1 * 1, // SigmaTan<=1
106+
kC1Pt2max = 100 * 100, // Sigma1/Pt<=100 1/GeV
107+
kMostProbablePt = 0.6f, // Most Probable Pt (GeV), for running with Bz=0
108+
kCalcdEdxAuto = -999.f; // value indicating request for dedx calculation
109109

110110
// access to covariance matrix by row and column
111111
GPUconstexpr() int CovarMap[kNParams][kNParams] = {{0, 1, 3, 6, 10},
@@ -117,13 +117,13 @@ GPUconstexpr() int CovarMap[kNParams][kNParams] = {{0, 1, 3, 6, 10},
117117
// access to covariance matrix diagonal elements
118118
GPUconstexpr() int DiagMap[kNParams] = {0, 2, 5, 9, 14};
119119

120-
constexpr float HugeF = o2::constants::math::VeryBig;
121-
constexpr float MaxPT = 100000.; // do not allow pTs exceeding this value (to avoid NANs)
122-
constexpr float MinPTInv = 1. / MaxPT; // do not allow q/pTs less this value (to avoid NANs)
123-
constexpr float ELoss2EKinThreshInv = 1. / 0.025; // do not allow E.Loss correction step with dE/Ekin above the inverse of this value
124-
constexpr int MaxELossIter = 50; // max number of iteration for the ELoss to account for BB dependence on beta*gamma
125-
constexpr float DefaultDCA = 999.f; // default DCA value
126-
constexpr float DefaultDCACov = 999.f; // default DCA cov value
120+
GPUglobalconstexpr() float HugeF = o2::constants::math::VeryBig;
121+
GPUglobalconstexpr() float MaxPT = 100000.; // do not allow pTs exceeding this value (to avoid NANs)
122+
GPUglobalconstexpr() float MinPTInv = 1. / MaxPT; // do not allow q/pTs less this value (to avoid NANs)
123+
GPUglobalconstexpr() float ELoss2EKinThreshInv = 1. / 0.025; // do not allow E.Loss correction step with dE/Ekin above the inverse of this value
124+
GPUglobalconstexpr() int MaxELossIter = 50; // max number of iteration for the ELoss to account for BB dependence on beta*gamma
125+
GPUglobalconstexpr() float DefaultDCA = 999.f; // default DCA value
126+
GPUglobalconstexpr() float DefaultDCACov = 999.f; // default DCA cov value
127127

128128
// uncomment this to enable correction for BB dependence on beta*gamma via BB derivative
129129
// #define _BB_NONCONST_CORR_
@@ -277,7 +277,7 @@ class TrackParametrization
277277

278278
private:
279279
//
280-
static constexpr value_t InvalidX = -99999.f;
280+
static GPUglobalconstexpr() value_t InvalidX = -99999.f;
281281
value_t mX = 0.f; /// X of track evaluation
282282
value_t mAlpha = 0.f; /// track frame angle
283283
value_t mP[kNParams] = {0.f}; /// 5 parameters: Y,Z,sin(phi),tg(lambda),q/pT

0 commit comments

Comments
 (0)