Skip to content

Commit 8171143

Browse files
committed
CommonDataFormat: 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 7f96410 commit 8171143

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

‎DataFormats/common/include/CommonDataFormat/AbstractRef.h‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <type_traits>
2323
#endif
2424

25-
2625
namespace o2::dataformats
2726
{
2827

@@ -54,10 +53,10 @@ class AbstractRef
5453
using Src_t = decltype(AbstractRef::MVAR<NBSrc>());
5554
using Flg_t = decltype(AbstractRef::MVAR<NBFlg>());
5655

57-
static constexpr Base_t BaseMask = Base_t((((0x1U << (NBIdx + NBSrc + NBFlg - 1)) - 1) << 1) + 1);
58-
static constexpr Idx_t IdxMask = Idx_t((((0x1U << (NBIdx - 1)) - 1) << 1) + 1);
59-
static constexpr Src_t SrcMask = Src_t((((0x1U << (NBSrc - 1)) - 1) << 1) + 1);
60-
static constexpr Flg_t FlgMask = Flg_t((((0x1U << (NBFlg - 1)) - 1) << 1) + 1);
56+
static GPUglobalconstexpr() Base_t BaseMask = Base_t((((0x1U << (NBIdx + NBSrc + NBFlg - 1)) - 1) << 1) + 1);
57+
static GPUglobalconstexpr() Idx_t IdxMask = Idx_t((((0x1U << (NBIdx - 1)) - 1) << 1) + 1);
58+
static GPUglobalconstexpr() Src_t SrcMask = Src_t((((0x1U << (NBSrc - 1)) - 1) << 1) + 1);
59+
static GPUglobalconstexpr() Flg_t FlgMask = Flg_t((((0x1U << (NBFlg - 1)) - 1) << 1) + 1);
6160
static constexpr int NBitsIndex() { return NBIdx; }
6261
static constexpr int NBitsSource() { return NBSrc; }
6362
static constexpr int NBitsFlags() { return NBFlg; }

‎DataFormats/common/include/CommonDataFormat/RangeReference.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ class RangeRefComp
6464
using Base = unsigned int;
6565

6666
private:
67-
static constexpr int NBitsTotal = sizeof(Base) * 8;
68-
static constexpr Base MaskN = ((0x1 << NBitsN) - 1);
69-
static constexpr Base MaskR = (~Base(0)) & (~MaskN);
67+
static GPUglobalconstexpr() int NBitsTotal = sizeof(Base) * 8;
68+
static GPUglobalconstexpr() Base MaskN = ((0x1 << NBitsN) - 1);
69+
static GPUglobalconstexpr() Base MaskR = (~Base(0)) & (~MaskN);
7070
Base mData = 0; ///< packed 1st entry reference + N entries
7171
GPUhd() void sanityCheck()
7272
{

0 commit comments

Comments
 (0)