Repository navigation
rdna2spirv: GFX10.1 scalar atomics (s_atomic_*, s_buffer_atomic_*), once per wave - #3676
evilclanker9000 wants to merge 8 commits into
Conversation
…rd*) s_store_dword/x2/x4 and s_buffer_store_dword/x2/x4 exist on gfx1010-gfx1013 (the console) only. They now write SDATA as PhysicalStorageBuffer stores at the address an s_load / s_buffer_load of the same operands reads, with the buffer bound; a lane-mask source is refused. Scalar atomics stay Unsupported. Not measurable on the gfx1036 oracle. GPU fixture cs_w32_scalar_store, semantic test ScalarStores, design.md row; the old contract test that expected Unsupported now checks the emitted stores. AI-assisted.
s_atomic_* and s_buffer_atomic_* (the 32-bit buffer atomic kinds, inc/dec, cmpswap, and the and/or/xor/swap _x2 forms as one 32-bit atomic per dword) are performed by the invocation in hardware lane 0 of the wave, at the s_load / s_buffer_load address; with glc the old value is shuffled to every lane (an exchange round under --wave64-emulate). Compute and mesh only. GPU fixtures cs_w32_scalar_atomic / cs_w64_scalar_atomic, semantic test ScalarAtomics. AI-assisted.
AI-assisted.
…omic AI-assisted.
# Conflicts: # docs/design.md
|
Independent CPU review at
AI-assisted. |
kacper-serewis
left a comment
There was a problem hiding this comment.
CPU review at 5c7c476; 88ef3e8 changes only docs/design.md relative to the tested tree. With two logical wave32s in one synthetic 64-wide subgroup, two adds of 3 correctly move 100 to 106 but both waves receive old value 100. The return shuffle at rdna2spirv.py:8974 reads lane 0 for both; the second logical wave needs lane 32. With 32-wide subgroups the returns are 100 and 103. Separately the _x2 lowering near line 8944 uses independent 32-bit atomics, allowing a torn pair under contention (source finding). Preserve 64-bit atomicity or explicitly reject unsupported forms. Three focused CPU tests passed. AI-assisted; no GPU execution.
|
Tested
No game files. AI-assisted (Claude Code). |
runtime/test/shaders/check.py scripts/run_gpu_tests.py tools/rdna2spirv.py AI-assisted.
|
Tested 4458ea1 on NVIDIA RTX 4080, driver 610.88, Windows 11: pass This head is the merge of
Not run here: native GFX10.1 hardware. The description notes the gfx1036 oracle can't assemble scalar atomics. Review: no new findings. The AI-assisted. |
Conflicts: docs/design.md, tools/rdna2spirv.py AI-assisted.
|
Tested
Per-fixture verdicts differ from
Python: Before the change: the same tests on this head with Circularity: the fixtures' words come from the same reading of the ISA as the translator, so I checked them separately. A plain-Python model of add/sub/inc/cmpswap/or_x2 written from the instruction descriptions gives exactly the words of both fixtures. Hardware: scalar stores and atomics are GFX10.1 only; Concern (the open review finding, reproduced on the 780M): for a wave32 shader whose workgroup of 64 lands in one 64-wide subgroup ( Synthetic inputs only, no game data. AI-assisted. |
|
Tested b9e2804 on Intel UHD 630 (CFL GT2, subgroup 8..32), Mesa 25.2.8 ANV, Ubuntu 24.04, LEONIDA_VK_DEVICE=Intel: pass.
The wave64 scalar atomic fixture cannot run on this GPU, so the 64-wide claim is not tested here. AI-assisted. |
|
Tested b9e2804 on Tesla V100 (Volta) + RTX 4090 (Ada), Linux: pass Machines: Tesla V100-SXM2-32GB (Volta, 32-wide, NVIDIA 580.95.05, Ubuntu 24.04) and RTX 4090 (Ada, 32-wide, NVIDIA 570.153.02 user-space Vulkan driver in a Linux container, Vulkan 1.4.303). The 4090 has mesh shaders and fragment barycentrics, so it runs the mesh/barycentric tests the V100 skips. Each run is the PR diff applied to
Not covered here: AMD hardware (native wave64), Windows. AI-assisted (Claude Code). |
docs/design.md scripts/run_gpu_tests.py tests/semantic/regen_fixtures.py AI-assisted.
|
Tested 0900164 on CachyOS, RADV/Mesa 26.3.1, LLVM 23.1.5: pass.
AI-assisted. |
shayderrr
left a comment
There was a problem hiding this comment.
Review
Reviewed change in PR #3676: rdna2spirv: GFX10.1 scalar atomics (s_atomic_, s_buffer_atomic_), once per wave.
Scope: docs/design.md, runtime/test/shaders/check.py, runtime/test/shaders/cs_w32_scalar_atomic.asm, +10 more
Diff: +449 / -22 across 13 file(s).
The change stays inside the stated scope and the touched files line up with the description. No unrelated production paths are pulled in, and the stated behavior is directly exercised by the diff. I'm approving this one.
Reviewed by shayderrr via automated batch review.
|
Thanks @evilclanker9000 - I went through rdna2spirv: GFX10.1 scalar atomics (s_atomic_, s_buffer_atomic_), once per wave and the diff around |
Requested by Lucas · project thread
Claimed in the coordination issue as: EGEN-SMEM-ATOMIC, #3574 (comment)
Depends on: #3589 (scalar stores). This branch is stacked on it, and only the last two commits are new here.
What and why
s_atomic_*ands_buffer_atomic_*raisedUnsupported. Like the scalar stores, they exist on GFX10.1 only (gfx1010-gfx1013, which includes the console). Each one is a single atomic per wave, at the address ans_load/s_buffer_loadof the same operands reads. Withglc, SDATA gets the value from before the op.Change (
tools/rdna2spirv.py,Gen.scalar_load(..., atomic=kind)andGen.scalar_atomic):--wave64-emulateand when a wave64 spans two 32-wide subgroups. Other stages raiseUnsupported.glc). Every lane gets lane 0's value, throughOpGroupNonUniformShufflefrom lane 0, or through an exchange round (x_round) under--wave64-emulate. A wave64 on 32-wide subgroups without emulation gets the value in lanes 0-31 only, the same known cross-half approximation as the other cross-lane ops._x2forms are translated as one 32-bit atomic per dword, asbuffer_atomic_*_x2does._x2forms stayUnsupported.s_buffer_atomicwhose element ends past the V# limit does nothing and returns 0, as the load reads 0 there. This is inferred.s_storefollowed by ans_atomicon the same address in one wave can see the store land after the atomic. This is documented in the scalar-store row, and the semantics are unchanged.Not measured natively. The gfx1036 oracle has no scalar atomics (
llvm-mcrejects them for gfx1030/gfx1036). An RDNA1 part (gfx1010-gfx1013) could check them natively, for example the V540 farm announced in the coordination issue.New contract row in
docs/design.md. The scalar-store row now points to it.Tested
Windows 11, LLVM
llvm-mc(-mcpu=gfx1013),VK_LOADER_LAYERS_DISABLE=~implicit~, one GPU at a time,python -I scripts/run_gpu_tests.py --filter scalar_atomic. Thevk_compute_testdevice lines wereAMD Radeon(TM) Graphics (subgroup 32..64)(withcompute subgroup size: 64for wave64) andNVIDIA GeForce RTX 5080 (subgroup 32..32).cs_w32_scalar_atomiccs_w64_scalar_atomic100 7 240 5 103 5 15 6100 100 240 5 103 15 255 261LEONIDA_W64_EMULATE=1, same words (SKIP without: no 64-wide subgroup)runtime/test/shaders/cs_w32_scalar_atomic.asm: add, sub, cmpswap and inc, withs_buffer_atomicands_atomic, returned values read in lane 31.cs_w64_scalar_atomic.asm: add, cmpswap andor_x2, returned values read in lanes 0 and 63.check.py,run_gpu_tests.pyandregen_fixtures.py.ScalarAtomicsintest_value_semantics.pyruns every lane of one wave (wave64 on a 64-wide subgroup), checks the words against a plain-Python reference, and checks the refusals (a pixel shader,s_atomic_add_x2).Unsupported: s_atomic_addands_buffer_atomic_add.ScalarAtomicsfails, and on the Radeon both fixtures fail, with the add target at196(100 + 32 × 3) and292(100 + 64 × 3). Then I reverted it.python -m unittest discover -s tests/semantic,python tests/semantic/regen_fixtures.py --check(clean),python -I tests/test_shader_checks.py, andpytest tests/test_docs_design_rows.py tests/test_run_gpu_tests.py tests/test_shader_meta.py.AI-assisted.
Checklist
docs/design.md, with how it was confirmed.