Skip to content

Require UnsafeAtomics 0.4 and remove the Metal extension - #85

Merged
maleadt merged 3 commits into
mainfrom
tb/unsafeatomics-0.4
Oct 5, 2026
Merged

maleadt merged 3 commits into
mainfrom
tb/unsafeatomics-0.4

Conversation

@maleadt

@maleadt maleadt commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

UnsafeAtomics 0.4 keeps the parts of the API that Atomix uses (the orderings, right, load, store!, cas! and modify!), and emits plain LLVM atomics, which GPUCompiler 2.12 lowers for Metal. This PR requires it, and removes AtomixMetalExt: on Metal, Atomix now uses its generic implementation through UnsafeAtomics, like it already did for get/set! on CUDA and oneAPI. Requiring 0.4 is what makes that safe: UnsafeAtomics 0.4 requires LLVM.jl 10 and (as a weak dependency) GPUCompiler 2.12, which rules out every Metal.jl release that can't compile the generic path. This also unblocks JuliaGPU/Metal.jl#977.

Behavior change on Metal: the extension ignored the requested ordering and always used relaxed atomics, while the generic path honors it. @atomic therefore defaults to sequentially consistent at system scope, which GPUCompiler implements with fences before MSL 4.1.

Compatibility: no released Metal.jl, oneAPI.jl or OpenCL.jl supports LLVM.jl 10 yet, so their users stay on Atomix 1.2 until those packages release; released CUDA.jl (6.4.2) works. Until then, the Buildkite jobs and test/runtests.jl install those three back-ends from their main branches, which should be reverted once they're released. As dropping UnsafeAtomics 0.1–0.3 narrows compatibility, this bumps the version to 1.3.0.

Tested on an M1, with Metal.jl main (1.12.0-DEV), GPUCompiler 2.12.0 and UnsafeAtomics 0.4.0, without the extension: Atomix's Metal tests on Julia 1.10 and 1.12 (running the Buildkite job's commands), and the CPU test suite including Aqua on 1.12.

Atomix only uses the parts of UnsafeAtomics' API that 0.4 keeps: the
orderings, load, store!, cas! and modify!. The LLVM-based implementation
is no longer a package extension (UnsafeAtomicsLLVM), so stop referring
to it.
UnsafeAtomics 0.4 emits plain LLVM atomics, which GPUCompiler 2.12 lowers
for Metal, so Atomix's generic implementation works on Metal and honors
the requested ordering, unlike the extension, which always used relaxed
atomics. UnsafeAtomics 0.4 requires LLVM.jl 10 and GPUCompiler 2.12, so
requiring it rules out the Metal.jl releases the extension was needed for.

No released Metal.jl, oneAPI.jl or OpenCL.jl supports LLVM.jl 10 yet, so
test against their development branches for now.
@maleadt
maleadt force-pushed the tb/unsafeatomics-0.4 branch from 05d828f to caade3d Compare October 5, 2026 18:36
@maleadt maleadt changed the title Allow UnsafeAtomics 0.4 Require UnsafeAtomics 0.4 and remove the Metal extension Oct 5, 2026
@maleadt
maleadt merged commit 4a92fdc into main Oct 5, 2026
6 of 7 checks passed
@maleadt
maleadt deleted the tb/unsafeatomics-0.4 branch October 5, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant