Skip to content

Commit a40eeba

Browse files
committed
DataFormatsTPC: 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 6dc952c commit a40eeba

3 files changed

Lines changed: 18 additions & 16 deletions

File tree

‎DataFormats/Detectors/TPC/include/DataFormatsTPC/CalibdEdxCorrection.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ GPUconstexpr() float TglScale[4] = {1.9, 1.5, 1.22, 1.02}; ///< Max Tgl values f
3939
class CalibdEdxCorrection
4040
{
4141
public:
42-
static constexpr int FitSize = 288; ///< Number of fitted corrections
43-
static constexpr int ParamSize = 8; ///< Number of params per fit
42+
static GPUglobalconstexpr() int FitSize = 288; ///< Number of fitted corrections
43+
static GPUglobalconstexpr() int ParamSize = 8; ///< Number of params per fit
4444

4545
#if !defined(GPUCA_GPUCODE)
4646
CalibdEdxCorrection()

‎DataFormats/Detectors/TPC/include/DataFormatsTPC/ClusterNative.h‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ struct ClusterNative {
5959
flagEdge = 0x4, // At edge of TPC sector
6060
flagSingle = 0x8 }; // Single pad or single time-bin cluster
6161

62-
static constexpr int scaleTimePacked = 64; //< ~50 is needed for 0.1mm precision, but leads to float rounding artifacts around 20ms
63-
static constexpr int scalePadPacked = 64; //< ~60 is needed for 0.1mm precision, but power of two avoids rounding
64-
static constexpr int scaleSigmaTimePacked = 32; // 1/32nd of pad/timebin precision for cluster size
65-
static constexpr int scaleSigmaPadPacked = 32;
66-
static constexpr int scaleSaturatedQtot = 8;
67-
static constexpr int maxRegularQtot = 25 * 1024;
68-
static constexpr int maxSaturatedQtot = (USHRT_MAX - maxRegularQtot) * scaleSaturatedQtot;
62+
static GPUglobalconstexpr() int scaleTimePacked = 64; //< ~50 is needed for 0.1mm precision, but leads to float rounding artifacts around 20ms
63+
static GPUglobalconstexpr() int scalePadPacked = 64; //< ~60 is needed for 0.1mm precision, but power of two avoids rounding
64+
static GPUglobalconstexpr() int scaleSigmaTimePacked = 32; // 1/32nd of pad/timebin precision for cluster size
65+
static GPUglobalconstexpr() int scaleSigmaPadPacked = 32;
66+
static GPUglobalconstexpr() int scaleSaturatedQtot = 8;
67+
static GPUglobalconstexpr() int maxRegularQtot = 25 * 1024;
68+
static GPUglobalconstexpr() int maxSaturatedQtot = (USHRT_MAX - maxRegularQtot) * scaleSaturatedQtot;
6969

7070
uint32_t timeFlagsPacked; //< Contains the time in the lower 24 bits in a packed format, contains the flags in the
7171
// upper 8 bits

‎DataFormats/Detectors/TPC/include/DataFormatsTPC/Defs.h‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef AliceO2_TPC_Defs_H
2020
#define AliceO2_TPC_Defs_H
2121

22+
#include "GPUCommonDef.h"
23+
2224
#ifndef GPUCA_GPUCODE_DEVICE
2325
#include <cmath>
2426
#endif
@@ -37,8 +39,8 @@ enum Side { A = 0,
3739
UNDEFINED = 2 };
3840
// enum class Side {A=0, C=1};
3941
// Problem with root cint. does not seem to support enum class ...
40-
constexpr unsigned char SECTORSPERSIDE = 18;
41-
constexpr unsigned char SIDES = 2;
42+
GPUglobalconstexpr() unsigned char SECTORSPERSIDE = 18;
43+
GPUglobalconstexpr() unsigned char SIDES = 2;
4244

4345
constexpr double PI = 3.14159265358979323846;
4446
constexpr double TWOPI = 2. * PI;
@@ -54,10 +56,10 @@ enum GEMstack { IROCgem = 0,
5456
OROC1gem = 1,
5557
OROC2gem = 2,
5658
OROC3gem = 3 };
57-
constexpr unsigned short GEMSTACKSPERSECTOR = 4;
58-
constexpr unsigned short GEMSPERSTACK = 4;
59-
constexpr unsigned short GEMSTACKSPERSIDE = GEMSTACKSPERSECTOR * SECTORSPERSIDE;
60-
constexpr unsigned short GEMSTACKS = GEMSTACKSPERSECTOR * SECTORSPERSIDE * SIDES;
59+
GPUglobalconstexpr() unsigned short GEMSTACKSPERSECTOR = 4;
60+
GPUglobalconstexpr() unsigned short GEMSPERSTACK = 4;
61+
GPUglobalconstexpr() unsigned short GEMSTACKSPERSIDE = GEMSTACKSPERSECTOR * SECTORSPERSIDE;
62+
GPUglobalconstexpr() unsigned short GEMSTACKS = GEMSTACKSPERSECTOR * SECTORSPERSIDE * SIDES;
6163

6264
/// Definition of the different pad subsets
6365
enum class PadSubset : char {
@@ -71,7 +73,7 @@ enum ChargeType {
7173
Max = 0,
7274
Tot = 1
7375
};
74-
constexpr unsigned short CHARGETYPES = 2;
76+
GPUglobalconstexpr() unsigned short CHARGETYPES = 2;
7577

7678
/// GEM stack identification
7779
struct StackID {

0 commit comments

Comments
 (0)