Skip to content

GPU: Apple Metal backend, off by default - #15814

Draft
ktf wants to merge 2 commits into
AliceO2Group:devfrom
ktf:pr15814
Draft

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

Conversation

@ktf

@ktf ktf commented Sep 17, 2026

Copy link
Copy Markdown
Member

The backend itself: the Objective-C++ host side, the .metal kernel source and
its build rules, plus the CMake to enable them.

Off unless asked for. FindO2GPU.cmake leaves ENABLE_METAL=OFF on macOS and the
subdirectory is gated on METAL_ENABLED, so macOS keeps running on the CPU
until the whole chain is validated. An earlier draft forced AUTO
unconditionally, which both enabled the backend on every Mac and silently
overrode an explicit -DENABLE_METAL=OFF.

Apple toolchain only. The source goes .metal -> AIR through xcrun metal and
nothing else; the draft's clang --target=vulkan1.4 SPIR-V route is removed
rather than left commented, as it would pull in the LLVM-SPIRV translator and
a second frontend Apple neither ships nor supports.

Requires -std=metal4.1, stated in METAL_FLAGS. This is not merely a minimum:
MSL 4.0 resolves an unannotated this as thread rather than generic, so an
older toolchain would not fail, it would build the wrong thing. MSL 4.1
targets macOS 27, and Xcode 26.6 stops at metal4.0.


Stack created with Sapling. Best reviewed with ReviewStack.

ktf added 2 commits September 17, 2026 16:59
Adds sLibMETAL and the DeviceType::METAL dispatch, plus the METAL_ENABLED
cmakedefine. The loader is constructed unconditionally, as the others are,
and only resolves its symbols when that device type is actually requested --
so this builds and links without the backend present.
The backend itself: the Objective-C++ host side, the .metal kernel source and
its build rules, plus the CMake to enable them.

Off unless asked for. FindO2GPU.cmake leaves ENABLE_METAL=OFF on macOS and the
subdirectory is gated on METAL_ENABLED, so macOS keeps running on the CPU
until the whole chain is validated. An earlier draft forced AUTO
unconditionally, which both enabled the backend on every Mac and silently
overrode an explicit -DENABLE_METAL=OFF.

Apple toolchain only. The source goes .metal -> AIR through xcrun metal and
nothing else; the draft's clang --target=vulkan1.4 SPIR-V route is removed
rather than left commented, as it would pull in the LLVM-SPIRV translator and
a second frontend Apple neither ships nor supports.

Requires -std=metal4.1, stated in METAL_FLAGS. This is not merely a minimum:
MSL 4.0 resolves an unannotated this as thread rather than generic, so an
older toolchain would not fail, it would build the wrong thing. MSL 4.1
targets macOS 27, and Xcode 26.6 stops at metal4.0.
@ktf
ktf requested review from a team and davidrohr as code owners September 17, 2026 15:04
@ktf
ktf marked this pull request as draft September 17, 2026 15:05
@ktf

ktf commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

This is my old attempt + some automated changes for Metal 4.1, which is actually where I had to stop last time. Draft for now, since it requires XCode 27, which none of the CI builders have.

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.

1 participant