Repository navigation
Upgrade to UnsafeAtomics 0.4 - #1135
Merged
Merged
Conversation
maleadt
added this pull request to stack #1136
October 5, 2026 20:07
UnsafeAtomics 0.4 emits every atomic and fence in device code with the scope it is given, and GPUCompiler 2.12 renames its `device` scope to AMDGPU's `agent`. Our fence overlays are therefore redundant, and the scope constants become UnsafeAtomics' public `device` and `workgroup`. They stay defined, as AcceleratedKernels' AMDGPU extension uses `syncscope_agent`. The Atomix override for `+` and `-` remains, since Atomix always uses the system scope, which keeps hardware FP atomics from being selected.
maleadt
force-pushed
the
tb/unsafeatomics-0.4
branch
from
October 6, 2026 07:34
d824f35 to
ac08d21
Compare
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.
Moves AMDGPU.jl to UnsafeAtomics 0.4, which Atomix 1.3 already requires. UnsafeAtomics 0.4 depends on LLVM.jl 10, hence the stack on the LLVM.jl 10 port. With GPUCompiler 2.12, every atomic and fence in device code now keeps the scope it is given, and GPUCompiler renames the canonical
devicescope to AMDGPU'sagent(andsubgrouptowavefront).That makes our
UnsafeAtomics.fenceoverlays redundant, so they're gone.syncscope_agentandsyncscope_workgroupare now UnsafeAtomics' publicdeviceandworkgroupscopes. They stay defined because AcceleratedKernels' AMDGPU extension usessyncscope_agent. TheAtomix.modify!override for+and-stays: Atomix always passes the system scope, and hardware FP atomics need the agent scope.Two upstream changes users may notice:
maxandminon floats follow Julia's semantics, so a NaN propagates. On AMDGPU,@atomic max(x[i], v::Float32)therefore compiles to a compare-and-swap loop instead ofatomicrmw fmax.UnsafeAtomics.fmax!/fmin!keep the IEEE behavior. Integermax/minare unchanged.UnsafeAtomics.fence()in a kernel is now afence seq_cst. Before, it emitted x86 inline assembly.Apart from those, the LLVM IR of atomic fadd/fsub/add/umax, compare-and-swap, atomic loads,
sync_workgroupand agent fences is identical to main's. The GCN assembly is the same on gfx90a, gfx942 and gfx1100. New codegen tests check the scopes on any architecture; the existing hardware FP atomics test only covers this on CDNA and RDNA3+. The full test suite passes on a gfx1036 iGPU (Julia 1.13), as do the codegen and synchronization tests on Julia 1.10 and 1.12.