Skip to content

TPC: place shared constants in the Metal constant address space - #15802

Open
ktf wants to merge 2 commits into
AliceO2Group:devfrom
ktf:pr15802
Open

ktf wants to merge 2 commits into
AliceO2Group:devfrom
ktf:pr15802

Conversation

@ktf

@ktf ktf commented Sep 16, 2026

Copy link
Copy Markdown
Member

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.

@ktf

ktf commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

@davidrohr an alternative would be to have a GPUconstexprconstant() macro which expands to constant constexpr on mac and just constexpr (and not constexpr __constant__) everywhere else.

@davidrohr

Copy link
Copy Markdown
Collaborator

So MacOS does not support constexpr variables, when they are not constant?

@ktf

ktf commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

As far as I understand it, only if they are in the (C++) global scope. They work fine if they are inside a function.

@ktf

ktf commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

If you prefer we can have a GPUglobalconstant().

@davidrohr

Copy link
Copy Markdown
Collaborator

I would add a GPUglobalconstexpr() macro, we might need the same in other places.

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.
@ktf

ktf commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

@davidrohr done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants