Skip to content

Commit 016490e

Browse files
committed
DetectorsBase: 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 b423d23 commit 016490e

4 files changed

Lines changed: 19 additions & 17 deletions

File tree

‎Detectors/Base/include/DetectorsBase/MatCell.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ namespace base
2626
struct MatCell {
2727
// small struct to hold <X/X0> and <rho> of the voxel
2828

29-
static constexpr int NParams = 2; // number of material parameters described
30-
float meanRho; ///< mean density, g/cm^3
31-
float meanX2X0; ///< fraction of radiaton lenght
29+
static GPUglobalconstexpr() int NParams = 2; // number of material parameters described
30+
float meanRho; ///< mean density, g/cm^3
31+
float meanX2X0; ///< fraction of radiaton lenght
3232

3333
GPUd() MatCell() : meanRho(0.f), meanX2X0(0.f) {}
3434
GPUdDefault() MatCell(const MatCell& src) = default;
@@ -51,8 +51,8 @@ struct MatCell {
5151
struct MatBudget : MatCell {
5252

5353
// small struct to hold <X/X0>, <rho> and length traversed by track in the voxel
54-
static constexpr int NParams = 3; // number of material parameters described
55-
float length; ///< length in material
54+
static GPUglobalconstexpr() int NParams = 3; // number of material parameters described
55+
float length; ///< length in material
5656

5757
GPUd() MatBudget() : length(0.f) {}
5858
GPUdDefault() MatBudget(const MatBudget& src) = default;

‎Detectors/Base/include/DetectorsBase/MatLayerCylSet.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ class MatLayerCylSet : public o2::gpu::FlatObject
145145
static constexpr size_t getBufferAlignmentBytes() { return 8; }
146146
#endif // !GPUCA_GPUCODE
147147

148-
static constexpr float LayerRMax = 500; // maximum value of R lookup (corresponds to last layer of MatLUT)
149-
static constexpr float VoxelRDelta = 0.05; // voxel spacing for layer lookup; seems a natural choice - corresponding ~ to smallest spacing
150-
static constexpr float InvVoxelRDelta = 1.f / VoxelRDelta;
151-
static constexpr int NumVoxels = int(LayerRMax / VoxelRDelta);
152-
static constexpr uint16_t VoxelAmbiguousBit = 0x8000u;
153-
static constexpr uint16_t VoxelSegmentMask = 0x7fffu;
148+
static GPUglobalconstexpr() float LayerRMax = 500; // maximum value of R lookup (corresponds to last layer of MatLUT)
149+
static GPUglobalconstexpr() float VoxelRDelta = 0.05; // voxel spacing for layer lookup; seems a natural choice - corresponding ~ to smallest spacing
150+
static GPUglobalconstexpr() float InvVoxelRDelta = 1.f / VoxelRDelta;
151+
static GPUglobalconstexpr() int NumVoxels = int(LayerRMax / VoxelRDelta);
152+
static GPUglobalconstexpr() uint16_t VoxelAmbiguousBit = 0x8000u;
153+
static GPUglobalconstexpr() uint16_t VoxelSegmentMask = 0x7fffu;
154154

155155
uint16_t mLayerVoxelLU[NumVoxels]; //! first interval based on known radius, plus the ambiguity flag (static dimension for easy copy to GPU)
156156
bool mInitializedLayerVoxelLU = false; //! if the voxels have been initialized

‎Detectors/Base/include/DetectorsBase/Propagator.h‎

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

19+
#include "GPUCommonDef.h"
20+
1921
#include "GPUCommonRtypes.h"
2022
#include "CommonConstants/PhysicsConstants.h"
2123
#include "ReconstructionDataFormats/Track.h"
@@ -69,8 +71,8 @@ class PropagatorImpl
6971
USEMatCorrLUT
7072
}; // flag to use LUT for material queries (user must provide a pointer
7173

72-
static constexpr float MAX_SIN_PHI = 0.85f;
73-
static constexpr float MAX_STEP = 2.0f;
74+
static GPUglobalconstexpr() float MAX_SIN_PHI = 0.85f;
75+
static GPUglobalconstexpr() float MAX_STEP = 2.0f;
7476

7577
GPUd() bool PropagateToXBxByBz(TrackParCov_t& track, value_type x,
7678
value_type maxSnp = MAX_SIN_PHI, value_type maxStep = MAX_STEP, MatCorrType matCorr = MatCorrType::USEMatCorrLUT,
@@ -201,7 +203,7 @@ class PropagatorImpl
201203
PropagatorImpl(bool uninitialized = false);
202204
~PropagatorImpl() = default;
203205
#endif
204-
static constexpr value_type Epsilon = 0.00001; // precision of propagation to X
206+
static GPUglobalconstexpr() value_type Epsilon = 0.00001; // precision of propagation to X
205207
template <typename T>
206208
GPUd() void getFieldXYZImpl(const math_utils::Point3D<T> xyz, T* bxyz) const;
207209
template <typename T>

‎Detectors/Base/include/DetectorsBase/Ray.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class Ray
4242

4343
public:
4444
using vecF3 = float[3];
45-
static constexpr float MinDistToConsider = 1e-4; // treat as 0 lenght distance below this
46-
static constexpr float InvalidT = -1e9;
47-
static constexpr float Tiny = 1e-9;
45+
static GPUglobalconstexpr() float MinDistToConsider = 1e-4; // treat as 0 lenght distance below this
46+
static GPUglobalconstexpr() float InvalidT = -1e9;
47+
static GPUglobalconstexpr() float Tiny = 1e-9;
4848

4949
GPUd() Ray() : mP{0.f}, mD{0.f}, mDistXY2(0.f), mDistXY2i(0.f), mDistXYZ(0.f), mXDxPlusYDy(0.f), mXDxPlusYDyRed(0.f), mXDxPlusYDy2(0.f), mR02(0.f), mR12(0.f)
5050
{

0 commit comments

Comments
 (0)