Skip to content

Commit 1e21f73

Browse files
ktfalibuild
andauthored
TPC: place shared constants in the Metal constant address space (#15802)
* TPC: place shared constants in the Metal constant address space MSL requires namespace-scope constexpr to live in the constant address space. Generic pointers do not help here: constant is explicitly not among the address spaces MSL 4.1 makes generic, so the annotation is required whatever the language version. Guarded on __METAL__, so no other build changes. * Please consider the following formatting changes --------- Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 0860f6f commit 1e21f73

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

DataFormats/Detectors/TPC/include/DataFormatsTPC/Constants.h

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

20+
#include "GPUCommonDef.h"
21+
2022
namespace o2
2123
{
2224
namespace tpc
@@ -25,17 +27,17 @@ namespace constants
2527
{
2628

2729
// the number of sectors
28-
constexpr int MAXSECTOR = 36;
30+
GPUglobalconstexpr() int MAXSECTOR = 36;
2931

3032
// the number of global pad rows
3133
#if defined(GPUCA_STANDALONE) && defined(GPUCA_RUN2)
32-
constexpr int MAXGLOBALPADROW = 159; // Number of pad rows in Run 2, used for GPU TPC tests with Run 2 data
34+
GPUglobalconstexpr() int MAXGLOBALPADROW = 159; // Number of pad rows in Run 2, used for GPU TPC tests with Run 2 data
3335
#else
34-
constexpr int MAXGLOBALPADROW = 152; // Correct number of pad rows in Run 3
36+
GPUglobalconstexpr() int MAXGLOBALPADROW = 152; // Correct number of pad rows in Run 3
3537
#endif
3638

3739
// number of LHC bunch crossings per TPC time bin (40 MHz / 5 MHz)
38-
constexpr int LHCBCPERTIMEBIN = 8;
40+
GPUglobalconstexpr() int LHCBCPERTIMEBIN = 8;
3941
} // namespace constants
4042
} // namespace tpc
4143
} // namespace o2

GPU/Common/GPUCommonDefAPI.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#define GPUglobal() // global memory variable declaration (only used for kernel input pointers)
4949
#define GPUconstant() // constant memory variable declaraion
5050
#define GPUconstexpr() static constexpr // constexpr on GPU that needs to be instantiated for dynamic access (e.g. arrays), becomes __constant on GPU
51+
#define GPUglobalconstexpr() constexpr // constexpr variable at program scope, needs the constant address space in MSL
5152
#define GPUprivate() // private memory variable declaration
5253
#define GPUgeneric() // reference / ptr to generic address space
5354
#define GPUbarrier() // synchronize all GPU threads in block
@@ -160,6 +161,7 @@
160161
#define GPUglobal() device
161162
#define GPUconstant() constant // TODO: possibly add const __restrict where possible later!
162163
#define GPUconstexpr() constant
164+
#define GPUglobalconstexpr() constant constexpr
163165
#define GPUprivate() thread
164166
#define GPUgeneric()
165167
#define GPUglobalref() device
@@ -255,6 +257,9 @@
255257
#ifndef GPUconstexprref
256258
#define GPUconstexprref()
257259
#endif
260+
#ifndef GPUglobalconstexpr
261+
#define GPUglobalconstexpr() constexpr
262+
#endif
258263

259264
#define GPUrestrict() __restrict__
260265

@@ -277,5 +282,5 @@
277282
#define get_group_id(dim) iBlock
278283
#endif
279284

280-
// clang-format on
285+
// clang-format on
281286
#endif

0 commit comments

Comments
 (0)