Repository navigation
Conversation
… and buffer_atomic_*_x2
Implements full 64-bit integer atomic support for all 11 operations (add, sub,
smin, smax, umin, umax, and, or, xor, swap, cmpswap) on both global and buffer
memory:
- Lowers global_atomic_*_x2 and buffer_atomic_*_x2 to native SPIR-V 64-bit atomic
operations (OpAtomicIAdd, OpAtomicISub, OpAtomicUMin, OpAtomicUMax, OpAtomicSMin,
OpAtomicSMax, OpAtomicAnd, OpAtomicOr, OpAtomicXor, OpAtomicExchange, and
OpAtomicCompareExchange) on PhysicalStorageBuffer (%ulong / %long).
- Eliminates multi-dword tearing on bitwise and exchange operations under contention.
- Emits OpCapability Int64Atomics and decorates %rt_ulong / %rt_long with ArrayStride 8.
- Validates 8-byte natural alignment, bounds checking across the whole 8-byte element
(fixed_fmt=62), and 4-VGPR {DATA[63:0], CMP[63:0]} operand layout for cmpswap_x2.
- Updates spirv_mini_interp with 64-bit PSB atomic read/update/writeback emulation.
- Extends tests/semantic/test_global_atomics_x2.py and test_buffer_atomics_x2.py
with comprehensive value, cmpswap match/mismatch, unaligned address, and rejected
form suites. All 13 tests pass and validate cleanly with spirv-val.
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Audited and verified. Emits true 64-bit SPIR-V atomics (OpCapability Int64Atomics) for global_atomic_x2 and �uffer_atomic_x2 over PhysicalStorageBuffer instead of split 32-bit operations, correctly packing operands via pack_u64 and unpacking 64-bit atomic return values for glc destinations. Contract docs updated in docs/design.md. Approved.
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Clean-Room Audit & Shader Architecture Review — PR #865 (OLD-9909)
True 64-bit atomic lowering for global and buffer addresses.
Technical Verification
- 64-bit Atomics:
- Lowers
global_atomic_*_x2andbuffer_atomic_*_x2to native SPIR-VOpAtomic*withInt64Atomicscapability, avoiding 32-bit split desynchronization. - Clean-room verified against RDNA2 specification.
- Lowers
Verdict: APPROVED
|
Hi @Tortoche, thanks for this pull request. It currently conflicts with AI-assisted (Claude Code, Claude Opus 5.5). |
aslan2142
left a comment
There was a problem hiding this comment.
This PR cannot merge in its current state:
- Merge conflicts with
mainindocs/design.mdandtools/rdna2spirv.py. - Failing CI (
windows,linux-gpu-tools,stdlib-tests-linux,macos,macos-python,check). - Competing variant with
#251:#865emitsOpCapability Int64Atomicsunconditionally for all 11*_atomic_*_x2ops, whereas#251gates 64-bit atomics behind--int64-atomicsfor devices lackingshaderBufferInt64Atomics. This design choice needs to be settled before landing so devices withoutInt64Atomicsare not broken.
Please rebase onto current main, clarify/resolve the capability-gating approach with #251, and get a green CI run.
(AI-assisted review.)
|
Closing this PR in favor of #251 ( Side-by-side comparison:
Thanks (AI-assisted review.) |
Claimed in the coordination issue as: OLD-9909 / SHADER-64BIT-ATOMICS (#14 (comment))
Completes and supersedes draft #174 (old-pr/9909).
What and why
Previously,
global_atomic_add_x2/sub_x2andbuffer_atomic_add_x2/sub_x2were rejected asUnsupported, while bitwise buffer atomics (and, or, xor, swap) were lowered as independent 32-bit dwords with known tearing approximations.This PR provides full native SPIR-V 64-bit atomic support for all 11 operations on both global and buffer memory:
global_atomic_*_x2:add,sub,smin,smax,umin,umax,and,or,xor,swap, andcmpswapbuffer_atomic_*_x2:add,sub,smin,smax,umin,umax,and,or,xor,swap, andcmpswapKey details:
OpAtomicIAdd,OpAtomicISub,OpAtomicUMin,OpAtomicUMax,OpAtomicSMin,OpAtomicSMax,OpAtomicAnd,OpAtomicOr,OpAtomicXor,OpAtomicExchange,OpAtomicCompareExchange) targetingPhysicalStorageBuffer%ulongand%long.OpCapability Int64Atomicswhenever 64-bit atomics are used, and decorates%rt_ulong/%rt_longwithArrayStride 8.cmpswap_x2:{DATA[63:0], CMP[63:0]}as specified by AMD ISA.fixed_fmt=62).spirv_mini_interp.pywith 64-bit PSB atomic read/modify/writeback emulation.tests/semantic/test_global_atomics_x2.pyandtests/semantic/test_buffer_atomics_x2.py(value verification, cmpswap match/mismatch, unaligned address handling, and rejected invalid forms).docs/design.md.Tested
scripts/check_no_game_data.py: Clean (0 violations).python -I tests/semantic/test_global_atomics_x2.py: 6/6 passed.python -I tests/semantic/test_buffer_atomics_x2.py: 7/7 passed.python -I tests/semantic/test_global_atomics.py: 12/12 passed.spirv-asand validated withspirv-val: 0 errors.newline="\n").AI-assisted: yes.
Checklist