Skip to content

GPU: do not place anything in the Metal constant address space - #15823

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

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

Conversation

@ktf

@ktf ktf commented Sep 21, 2026

Copy link
Copy Markdown
Member

The MSL generic address space covers device, threadgroup and thread but not
constant, so a generic member function cannot be called on an object that lives
in constant memory: 'cannot initialize object parameter of type X with an
expression of type constant X'. The shared code is generic throughout, so
constant memory is simply not usable on this backend.

Metal therefore implies GPUCA_NO_CONSTANT_MEMORY, which already exists for the
other backends and redirects GPUconstant() to GPUglobal(). GPUconstantref() has
to follow it, exactly as the OpenCL block already arranges; the Metal block
hardcoded 'constant' and so kept handing out constant references whatever the
setting. It now falls through to the unannotated, and therefore generic,
fallback.

Macro expansions are unchanged for host, CUDA, HIP, OpenCL and cling.
Takes the Metal translation unit from 333 errors to 235, of which the
constant-versus-generic diagnostics drop from 91 to 14.


Stack created with Sapling. Best reviewed with ReviewStack.

ktf added 2 commits September 21, 2026 11:03
macOS ships OpenCL 1.2, below the 2.x the OpenCL backend requires, so
find_package(OpenCL) there could never produce a usable backend: the version
check dropped it again a few lines later. Skip the lookup on Apple instead.

With that, CUDA_ENABLED, OPENCL_ENABLED and HIP_ENABLED are all necessarily
off on macOS, which makes the Darwin arm of the backend dispatch dead code.
Drop it along with its warning and unindent the rest.
The MSL generic address space covers device, threadgroup and thread but not
constant, so a generic member function cannot be called on an object that lives
in constant memory: 'cannot initialize object parameter of type X with an
expression of type constant X'. The shared code is generic throughout, so
constant memory is simply not usable on this backend.

Metal therefore implies GPUCA_NO_CONSTANT_MEMORY, which already exists for the
other backends and redirects GPUconstant() to GPUglobal(). GPUconstantref() has
to follow it, exactly as the OpenCL block already arranges; the Metal block
hardcoded 'constant' and so kept handing out constant references whatever the
setting. It now falls through to the unannotated, and therefore generic,
fallback.

Macro expansions are unchanged for host, CUDA, HIP, OpenCL and cling.
Takes the Metal translation unit from 333 errors to 235, of which the
constant-versus-generic diagnostics drop from 91 to 14.
@alibuild

alibuild commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Error while checking build/O2/fullCI_slc9 for 99542dd at 2026-09-21 21:48:

## sw/BUILD/ThePEG-latest/log
collect2: error: ld returned 1 exit status


## sw/BUILD/O2-latest/log
Error: missing ; at end of rule at /sw/SOURCES/O2/slc9_x86-64-slc9_x86-64/0/Detectors/TPC/base/src/TPCBaseLinkDef.h:75:56
Error: missing ; at end of rule at /sw/SOURCES/O2/slc9_x86-64-slc9_x86-64/0/Detectors/TPC/base/src/TPCBaseLinkDef.h:83:135
Error: missing ; at end of rule at /sw/SOURCES/O2/slc9_x86-64-slc9_x86-64/0/Detectors/TPC/base/src/TPCBaseLinkDef.h:84:135
Error: missing ; at end of rule at /sw/SOURCES/O2/slc9_x86-64-slc9_x86-64/0/Detectors/Upgrades/ALICE3/ECal/base/src/ECalBaseLinkDef.h:19:48
Error: missing ; at end of rule at /sw/SOURCES/O2/slc9_x86-64-slc9_x86-64/0/Detectors/Upgrades/ALICE3/RICH/base/src/RICHBaseLinkDef.h:18:48
Error: missing ; at end of rule at /sw/SOURCES/O2/slc9_x86-64-slc9_x86-64/0/Detectors/Upgrades/ALICE3/MID/base/src/MI3BaseLinkDef.h:18:47

Full log here.

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.

2 participants