Conversation
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.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.