Repository navigation
Metal: stop legalizing intrinsics that front-ends emit - #1047
Merged
Merged
Conversation
`legalize_barrier_abi!` rewrote the barriers Metal.jl emits for the target AIR and MSL versions, and `legalize_atomic_abi!` did the same for `air.atomic.*` calls in their MSL 4.1 form. That makes GPUCompiler track the intrinsic forms of every front-end release it may be paired with. Metal.jl now does this next to the code that emits them (and no longer emits atomic intrinsics directly), so only legalize what is emitted here: the atomics and fences this package selects. What remains of `legalize_atomic_abi!` is the pointer element type metadata for the downgrader.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1047 +/- ##
==========================================
- Coverage 92.49% 91.34% -1.15%
==========================================
Files 31 31
Lines 7341 7257 -84
==========================================
- Hits 6790 6629 -161
- Misses 551 628 +77 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
GPUCompiler legalized two families of intrinsics that front-ends emit directly:
legalize_barrier_abi!rewrote Metal.jl's barriers for the target AIR and MSL versions (#1020), andlegalize_atomic_abi!rewroteair.atomic.*calls emitted in their MSL 4.1 form. That makes GPUCompiler track the intrinsic forms of every front-end release it may be paired with. Like LLVM's back-ends, it should only legalize what it emits itself, and leave the choice of form for the target to the front-end that emits it.legalize_barrier_abi!is removed.air.atomic.*calls for GPUCompiler to legalize anymore: Metal.jl's atomics are LLVM atomics thatlower_atomics!selects, and released Metal.jl versions rewrite their own atomic intrinsics infinish_ir!. What remains oflegalize_atomic_abi!is the pointer element type metadata for the downgrader, nowannotate_atomic_eltypes!.Compatibility: Metal.jl main needs JuliaGPU/Metal.jl#1099 to be merged before this is released. No released Metal.jl emits the AIR 2.9 barrier form: Metal ≤ 1.11.1 emits 2-operand barriers, which
legalize_barrier_abi!upgraded to the 3-operand form on AIR 2.9 only for conformance with Apple'smetal-opt. The GPU accepts them, as it did before GPUCompiler 2.15.1, so those versions keep working without a compat change.GPUCompiler's Metal tests pass on Julia 1.10 and 1.13, and Metal.jl's synchronization, simd and atomics tests pass against this with Metal.jl#1099.