Skip to content

Upgrade to UnsafeAtomics 0.4 - #1135

Merged
maleadt merged 1 commit into
tb/llvm10from
tb/unsafeatomics-0.4
Oct 6, 2026
Merged

maleadt merged 1 commit into
tb/llvm10from
tb/unsafeatomics-0.4

Conversation

@maleadt

@maleadt maleadt commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

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 device scope to AMDGPU's agent (and subgroup to wavefront).

That makes our UnsafeAtomics.fence overlays redundant, so they're gone. syncscope_agent and syncscope_workgroup are now UnsafeAtomics' public device and workgroup scopes. They stay defined because AcceleratedKernels' AMDGPU extension uses syncscope_agent. The Atomix.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:

  • Atomic max and min on 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 of atomicrmw fmax. UnsafeAtomics.fmax!/fmin! keep the IEEE behavior. Integer max/min are unchanged.
  • A plain UnsafeAtomics.fence() in a kernel is now a fence 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_workgroup and 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.

@maleadt
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
maleadt force-pushed the tb/unsafeatomics-0.4 branch from d824f35 to ac08d21 Compare October 6, 2026 07:34
@maleadt
maleadt merged commit e0a2787 into main Oct 6, 2026
0 of 2 checks passed
@maleadt
maleadt deleted the tb/unsafeatomics-0.4 branch October 6, 2026 11:17
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