From 91c1d9b51af3fa79ff604207eae787c2638d93a3 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Wed, 16 Sep 2026 15:10:12 +0200 Subject: [PATCH 1/2] 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. --- .../Detectors/TPC/include/DataFormatsTPC/Constants.h | 10 ++++++---- GPU/Common/GPUCommonDefAPI.h | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/DataFormats/Detectors/TPC/include/DataFormatsTPC/Constants.h b/DataFormats/Detectors/TPC/include/DataFormatsTPC/Constants.h index 0ddf7281be866..c5423420d9fec 100644 --- a/DataFormats/Detectors/TPC/include/DataFormatsTPC/Constants.h +++ b/DataFormats/Detectors/TPC/include/DataFormatsTPC/Constants.h @@ -17,6 +17,8 @@ #ifndef AliceO2_TPC_Constants_H #define AliceO2_TPC_Constants_H +#include "GPUCommonDef.h" + namespace o2 { namespace tpc @@ -25,17 +27,17 @@ namespace constants { // the number of sectors -constexpr int MAXSECTOR = 36; +GPUglobalconstexpr() int MAXSECTOR = 36; // the number of global pad rows #if defined(GPUCA_STANDALONE) && defined(GPUCA_RUN2) -constexpr int MAXGLOBALPADROW = 159; // Number of pad rows in Run 2, used for GPU TPC tests with Run 2 data +GPUglobalconstexpr() int MAXGLOBALPADROW = 159; // Number of pad rows in Run 2, used for GPU TPC tests with Run 2 data #else -constexpr int MAXGLOBALPADROW = 152; // Correct number of pad rows in Run 3 +GPUglobalconstexpr() int MAXGLOBALPADROW = 152; // Correct number of pad rows in Run 3 #endif // number of LHC bunch crossings per TPC time bin (40 MHz / 5 MHz) -constexpr int LHCBCPERTIMEBIN = 8; +GPUglobalconstexpr() int LHCBCPERTIMEBIN = 8; } // namespace constants } // namespace tpc } // namespace o2 diff --git a/GPU/Common/GPUCommonDefAPI.h b/GPU/Common/GPUCommonDefAPI.h index 45cc987453830..61a12989481d1 100644 --- a/GPU/Common/GPUCommonDefAPI.h +++ b/GPU/Common/GPUCommonDefAPI.h @@ -48,6 +48,7 @@ #define GPUglobal() // global memory variable declaration (only used for kernel input pointers) #define GPUconstant() // constant memory variable declaraion #define GPUconstexpr() static constexpr // constexpr on GPU that needs to be instantiated for dynamic access (e.g. arrays), becomes __constant on GPU + #define GPUglobalconstexpr() constexpr // constexpr variable at program scope, needs the constant address space in MSL #define GPUprivate() // private memory variable declaration #define GPUgeneric() // reference / ptr to generic address space #define GPUbarrier() // synchronize all GPU threads in block @@ -160,6 +161,7 @@ #define GPUglobal() device #define GPUconstant() constant // TODO: possibly add const __restrict where possible later! #define GPUconstexpr() constant + #define GPUglobalconstexpr() constant constexpr #define GPUprivate() thread #define GPUgeneric() #define GPUglobalref() device @@ -255,6 +257,9 @@ #ifndef GPUconstexprref #define GPUconstexprref() #endif +#ifndef GPUglobalconstexpr +#define GPUglobalconstexpr() constexpr +#endif #define GPUrestrict() __restrict__ From 943417683999244feaae3dc1a87a47cbfb4992f8 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Wed, 16 Sep 2026 13:11:57 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- GPU/Common/GPUCommonDefAPI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/Common/GPUCommonDefAPI.h b/GPU/Common/GPUCommonDefAPI.h index 61a12989481d1..a04934304d525 100644 --- a/GPU/Common/GPUCommonDefAPI.h +++ b/GPU/Common/GPUCommonDefAPI.h @@ -282,5 +282,5 @@ #define get_group_id(dim) iBlock #endif -// clang-format on + // clang-format on #endif