Repository navigation
rdna2spirv: global_atomic_add/sub_x2 and buffer_atomic_add/sub_x2 - #3065
LouisRiverstone wants to merge 1 commit into
Conversation
|
Tested The PR was CPU-only, and the interpreter runs lanes in lockstep, so I wanted the two-atomic carry scheme on hardware where the low and high atomics of different waves really interleave. I wrote a hand-written compute shader (not part of this PR), translated it with this head and ran it through
The checks: each element's final 64-bit value equals
Controls:
Also: Only wave32 was run (the translator gives this shader subgroup size 32). |
Kam471
left a comment
There was a problem hiding this comment.
Verified on the PR head: test_global_atomics_x2.py 6 OK, test_buffer_atomics_x2.py 5 OK, test_global_atomics.py 12 OK, full semantic 4,144 OK. On current main the two x2 suites fail 43 and 37 errors. The semantics are correct: x2_atomic_words gets (lo,hi) pointer/value pairs, callers build two AccessChains and read vdata+n, global_address handles scalar + 32-bit or 64-bit vaddr plus off, and the buffer form uses the 8-byte element (fmt 62). Mutations are non-vacuous (carry forced to 0: 21 global / 15 buffer failures; swapped words: 69 / 73). The PR's independent 4096-thread GPU contention pass is noted but not reproduced here. No game data or absolute paths. Approve.
Docs nit: docs/design.md and the test docstring still say "four _x2 forms" / "carrying forms stay Unsupported"; update those to the new count/behavior.
|
Tested
Tools: llvm-mc 21.1.8 with AMDGPU target, SPIRV-Tools 2026.1, GCC 13.3.0, Python 3.12.3. No code was edited or pushed; only synthetic fixtures were used. AI-assisted. |
|
Tested
Not checked: a GPU run (no GPU fixture uses these instructions) and the complete |
Both 64-bit add/sub forms raised Unsupported. They are exact with 32-bit atomics: the low dword's atomic returns its old value, which gives this op's own carry (borrow), and the high dword then takes DATA.hi + carry. Addition commutes and the carries over any order add up to the low dword's wraps, so the memory is exact under contention (as ItsNotRexed#2738 does for LDS); only the returned high dword can be torn. x2_atomic_words holds the per-dword part for the global and buffer paths. Tests: carry and borrow across the dword (global), add/sub in the value grids of test_global_atomics_x2.py / test_buffer_atomics_x2.py, and 32 lanes adding / subtracting on one element (they interleave in the interpreter) ending exact. The rejected-form lists move to min/max_x2. docs/design.md rows updated; a stale 'the _x2 forms stay Unsupported' sentence in the global atomics row goes.
5aa65eb to
7598d0b
Compare
|
CPU-side check (not the RDNA1/RADV GPU run that TEST-654 asks for): Windows, Python 3.12.0,
Revert control: with only What this does not answer: whether those modules run on RADV RDNA1 hardware — that is the half of TEST-654 that still needs a GPU owner, and I have none. AI-assisted. |
|
Tested
Tested and written by Claude (Claude Code), posting from @theswiss24's account. |
global_atomic_add_x2/sub_x2andbuffer_atomic_add_x2/sub_x2raisedUnsupported. This is the global and buffer counterpart of #2738, which does the same fords_add/sub_u64. The global and buffer_x2paths weren't in #2738, and no one had claimed them.How: two 32-bit atomics, exact without Int64 atomics.
Gen.x2_atomic_wordsnow holds the per-dword part shared byglobal_atomic_x2andbuffer_atomic_x2.DATA.loon the low dword returns its old value. From that old value this op knows its own carry:new_lo < old_lofor add,old_lo < DATA.lofor sub.DATA.hi + carry.Addition commutes, and the carries over any order of the ops add up to exactly the number of times the low dword wrapped. So the memory is exact even with other lanes on the element. Only the returned high dword can be torn, since it comes from its own atomic. The and/or/xor/swap forms are unchanged.
Tests:
test_global_atomics_x2.py:0x1_FFFFFFFF + 1,~0 + 1,0x1_00000000 - 1,0 - 1, …)MODEL)m ± 32·dexactly. With the carry forced to 0 (a sabotage I ran locally), both carry tests fail.test_buffer_atomics_x2.py: add/sub in its grid, including the bounds cases.test_global_atomics.pynow usesmin/umax/cmpswap_x2.python -I -m unittest discover -s tests/semantic: 4144 tests OK (4 skipped). The docs tests pass.docs/design.md: the global and buffer atomics rows describeadd/sub_x2. The global row also had a stale first "StillUnsupported: the_x264-bit forms …" sentence, a leftover from #1633 that contradicted the row's own_x2text; it's removed.Tested on CPU only; no GPU run. No game files. Claimed on #2891 before starting.
AI-assisted (Claude Code): I reviewed and ran the change and the tests.