Repository navigation
rdna2spirv: ds_cmpst_f32 and the global/buffer fcmpswap atomics - #3153
Conversation
|
Tested 9c70c02 (merged on current main) on RTX 3090, driver 616.56, Windows 11 23H2: pass. With this translator change, AI-assisted test run. |
|
Tested
Translator: 1 shader translated, spirv-val clean — the |
|
Tested fbe9cc1 on AMD Radeon RX 9060 XT (RDNA4), AMD driver 26.10.44 (LLPC, Vulkan driver 2.0.395), Windows 11 Pro 10.0.26300, subgroup 32..64: pass. The checks above have no AMD run from outside the author; this adds an AMD card with native 64-wide subgroups.
Test programs: an MSVC 14.44 build of main ec8ec4c; this PR's runtime C++ and CMake are identical to that commit, and the translator, runner and |
fbe9cc1 to
ff21d15
Compare
|
Rebased onto
|
|
Tested Ran the PR’s synthetic fixture through
AI-assisted verification with synthetic inputs. |
aa174ba to
052333d
Compare
ds_cmpst_f32 / ds_cmpst_rtn_f32, global_atomic_fcmpswap and buffer_atomic_fcmpswap raised Unsupported. They store DATA when M equals CMP as binary32 (-0 == +0, NaN never matches), which is not the bit compare OpAtomicCompareExchange does, so float_cmpswap_loop runs a CAS loop (initial read an OpAtomicLoad): read M, pick DATA or M by the float compare, swap that in if M is unchanged. Operands follow ds_cmpst_b32 / cmpswap; bounds, alignment, glc and inactive lanes follow their integer siblings. tests/semantic/test_float_cmpswap.py covers all four, incl. 32 lanes on one dword. GPU fixture runtime/test/shaders/cs_w32_fcmpswap.asm (with its CPU test). docs/design.md row added.
|
Tested 052333d (the current head, newer than the runs above) on AMD Radeon 610M (RDNA2 iGPU, AMD 26.11.2 / 32.0.21045.29003, subgroup 32..64) and NVIDIA GeForce RTX 5070 Ti Laptop GPU (Blackwell, 621.24, subgroup 32..32), Windows 11 Home 26200: pass. Same laptop, one GPU at a time through
So the fixture gives the same eight words on RDNA2 with AMD's Windows driver and on Blackwell, natively and under wave64 emulation. I did not run the CPU tests of this PR. One run of each. No game files. AI-assisted (Claude Code). |
|
Tested
Counts and pass/fail only; no game data. No code changes. AI-assisted. |
|
Tested
New in this PR:
Every other test has the same result as on |
|
Tested
No game files. AI-assisted (Claude Code). |
|
Thanks @Kev-Ball, @Etr0p (Radeon 610M, RTX 5070 Ti native and emulated), @bobcatchris, @junaydirfan (Raptor Lake ANV, RTX 4080 Laptop) and @jimokulou2-ops. |
|
Tested
One run of each. No game files. AI-assisted (Claude Code). |
|
Thanks @lunarminus (Radeon 760M, RDNA3, RADV 26.3.1), on the current head |
# Conflicts: # runtime/test/shaders/check.py # scripts/run_gpu_tests.py # tests/semantic/regen_fixtures.py
shayderrr
left a comment
There was a problem hiding this comment.
Review
Reviewed change in PR #3153: rdna2spirv: ds_cmpst_f32 and the global/buffer fcmpswap atomics.
Scope: docs/design.md, runtime/test/shaders/check.py, runtime/test/shaders/cs_w32_fcmpswap.asm, +6 more
Diff: +396 / -10 across 9 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 @LouisRiverstone - I went through rdna2spirv: ds_cmpst_f32 and the global/buffer fcmpswap atomics and the diff around |
|
Tested b8440e8 on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: pass.
No runtime C++ changes in this PR; tested from the PR worktree against the existing main runtime build. AI-assisted (OpenCode). |
|
Corpus check on a second copy of the same package (26,503 disasm listings, counts only): ds_cmpst_f32 has 0 occurrences (the only ds_cmpst in the corpus is 2x ds_cmpst_rtn_b32), and fcmpswap has 0 occurrences (the 46 buffer_atomic_cmpswap and 1 image_atomic_cmpswap are the integer forms, which print without the f). The new f32 compare paths are latent on the game corpus, consistent with GPU-fixture-only coverage here. Counted with grep -o on Windows, AI-assisted. |
|
Tested b8440e8 on two Vulkan devices, Windows 11, Vulkan SDK 1.4.363, MSVC 14.50, llvm-mc 23.1.6 (AMDGPU, LLVM-MinGW build):
AI-assisted. No game files. |
ds_cmpst_f32/ds_cmpst_rtn_f32,global_atomic_fcmpswapandbuffer_atomic_fcmpswapraisedUnsupported. #2495 has the LDS f32 min/max but notcmpst_f32, and #2653 covers only the image form.Semantics (RDNA2 ISA):
tmp = M; M = (tmp == CMP) ? DATA : tmp, with the returning forms givingtmp. The compare is a float compare: −0 == +0 matches, and a NaN never matches, even with identical bits.Implementation:
OpAtomicCompareExchangecompares bits, which differs exactly in those cases. SoGen.float_cmpswap_loopruns a compare-and-swap loop:OpFOrdEqualThis is exact under contention.
ds_cmpst_f32takes CMP then DATA, asds_cmpst_b32. The global and buffer forms takevdataas {DATA, CMP}, ascmpswap.glc: as for the integer siblings.OpPhifix: the resultOpPhiinglobal_atomicandbuffer_atomicnow names the block that actually branches to the merge. For the existing ops that's the same_doblock as before, so their code is unchanged. For fcmpswap it's the loop's exit block._x2forms stayUnsupported.Tests:
tests/semantic/test_float_cmpswap.py, for all four ops:glcvdataand_x2rejectedWithout the change the file fails (30 errors); with it, 6/6 pass.
test_global_atomics.pyandtest_lds_atomics_values.pystill pass.python -I -m unittest discover -s tests/semantic: 4148 tests OK (4 skipped).docs/design.md: new row afterds_cmpst_b32.GPU test (added after the first review):
runtime/test/shaders/cs_w32_fcmpswap.asm. Lane 0 of a wave32 group runsds_cmpst_rtn_f32,ds_cmpst_f32andbuffer_atomic_fcmpswap(with and withoutglc): −0 against +0, a NaN against its own bits, and a value one ulp off. It is registered incheck.py,run_gpu_tests.pyandregen_fixtures.py.tests/semantic/test_fcmpswap_fixture.pyruns it on the CPU and checks that both runners expect the same eight words. The global form isn't in the fixture, because it needs the heap setup from #1760.The new GPU fixture hasn't been run on hardware by me; CI's llvmpipe job will run it. No game files. Claimed on #2891 before starting.
AI-assisted (Claude Code): I reviewed and ran the change and the tests.