Repository navigation
M1 and M2 build the GPU program again: a32_load_acq reads through Metal's volatile local, as a32_load does - #1274
Merged
nicolas-abril merged 1 commit intoOct 2, 2026
Conversation
…al's volatile local, as a32_load does 87a1e9c turned a32_load_acq's a32_load(p) into atomic_load_explicit(A32(p), ACQ), which gives the host its acquire but skips the volatile local Metal's a32_load reads through. Without it the M1 (g13) and M2 (g14) pipeline builds die in MTLCompilerService, so every program with a `!` fails to build there since 2.0.29. On the device ACQ is RLX, so a32_load is the same relaxed load and FENCE; the host keeps its acquire. Fixes bendlang#1154 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.
Fixes #1154.
Cause
comp.ts already works around an Apple GPU compiler bug: "Metal's a32_load reads through a volatile local, or the M1 pipeline build dies." 87a1e9c (in 2.0.29) changed
a32_load_acqfroma32_load(p)toatomic_load_explicit(A32(p), ACQ). That gave the host a real acquire, since itsFENCE()is a no-op, but it also skipped the volatile local on Metal. Since then,MTLCompilerServicecrashes building the pipeline for any program with a!on M1 (g13, abort) and M2 (g14, SIGSEGV). M3 and M4 (g15/g16) are unaffected, which is why the gates and our M4s never saw it.Fix
ACQisRLX(Metal has nomemory_order_acquire), so this is the same relaxed atomic load followed by the same seq_cst device fence. The IR has the sameair.atomic.global.loadandair.atomic.fencecalls; the only addition is the store and reload through a thread-private local. clang drops the dead branch even at-O0. CUDA expands to the same text as before.memory_order_acquire.Verification
metal-tt, targetingapplegpu_g14swith Metal 3.2 / macOS 15, the bisect lands on 87a1e9c. Restoring only the volatile local makes 87a1e9c, v2.0.32 and main build; removing only it from the last good commit makes that one crash.134209536.gates/test.tspassed 1526 / 1526 (together with an unrelated change in that run).gates/repo.ts: comp.ts is already over its cap on main (64,274 > 64,000 ttok); this adds 9.🤖 Generated with Claude Code