Skip to content

Demote all LLVM atomic loads and stores on Metal and SPIR-V - #927

Merged
maleadt merged 1 commit into
mainfrom
tb/demote-atomics
Sep 9, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/demote-atomics

Conversation

@maleadt

@maleadt maleadt commented Sep 9, 2026

Copy link
Copy Markdown
Member

#904 demoted Julia's unordered heap-reference accesses, but codegen also stores the type tag of every heap-allocated object with release ordering, through the generic pointer the device allocator returns. Apple's back-end cannot legalize that either: on macOS 26 the pipeline compile aborts with XPC_ERROR_CONNECTION_INTERRUPTED, and metal-tt reports "unable to legalize instruction: store release (p0)". It surfaced with Float64 emulation (#926), where DomainError(::Float64, ...) in log1p's throw path is not inlined and its allocation survives to the back-end.

The same applies to SPIR-V: OpAtomicLoad/OpAtomicStore only take scalars, so a release-ordered pointer store is just as invalid there as an unordered one. Since device-side atomics go through target intrinsics rather than these instructions, every LLVM atomic load or store that reaches these back-ends is Julia GC bookkeeping, and demote_atomics! now strips all of them.

#904 demoted Julia's `unordered` heap-reference accesses, but codegen also
stores the type tag of every heap-allocated object with `release` ordering,
through the generic pointer the device allocator returns. Apple's back-end
cannot legalize that either: on macOS 26 the pipeline compile aborts with
XPC_ERROR_CONNECTION_INTERRUPTED, and metal-tt reports "unable to legalize
instruction: store release (p0)". It surfaced with Float64 emulation (#926),
where DomainError(::Float64, ...) in log1p's throw path is not inlined and
its allocation survives to the back-end.

The same applies to SPIR-V: OpAtomicLoad/OpAtomicStore only take scalars, so
a release-ordered pointer store is just as invalid there as an unordered one.
Since device-side atomics go through target intrinsics rather than these
instructions, every LLVM atomic load or store that reaches these back-ends is
Julia GC bookkeeping, and `demote_atomics!` now strips all of them.
@maleadt
maleadt merged commit c531942 into main Sep 9, 2026
91 of 124 checks passed
@maleadt
maleadt deleted the tb/demote-atomics branch September 9, 2026 12:25
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.76%. Comparing base (e9dbe53) to head (87d9450).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #927      +/-   ##
==========================================
- Coverage   85.76%   85.76%   -0.01%     
==========================================
  Files          29       29              
  Lines        5598     5597       -1     
==========================================
- Hits         4801     4800       -1     
  Misses        797      797              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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