Repository navigation
Translator: ds_cmpst_b32 (compare-and-store without return) - #814
Merged
Merged
Conversation
spirv_mini_interp ran 32-bit atomics on physical-storage-buffer pointers only, so the LDS atomics the translator emits (ds_add/sub/min/max/and/or/xor, ds_wrxchg_rtn_b32, ds_cmpst_rtn_b32) had no value test. With one invocation an atomic is read-combine-write on any pointer, so it now also takes the variable-element pointers OpLoad/OpStore use (Workgroup = LDS since ItsNotRexed#592, Function); push constants stay read-only. tests/semantic/test_lds_atomics_values.py runs compute listings as one invocation and checks the returned and stored words against a plain-Python model of each RDNA2 DS atomic.
ds_cmpst_b32 raised Unsupported while ds_cmpst_rtn_b32 was translated. It is the same OpAtomicCompareExchange (M = (M == data0) ? data1 : M) with the old value dropped; operands are vaddr, data0, data1. tests/semantic/test_lds_atomics_values.py checks a match, a mismatch and vdst left untouched.
ItsNotRexed
added a commit
that referenced
this pull request
Nov 22, 2026
2 tasks done
quackottu
reviewed
Nov 22, 2026
quackottu
left a comment
Contributor
There was a problem hiding this comment.
Tested dd301d3 on NVIDIA GeForce RTX 5070 (subgroup 32), driver 621.24, Windows 11 Pro (26300), Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 (built with scripts/build_llvm_mc.ps1), scripts/run_gpu_tests.py:
- native: 71/98 passed, 27 skipped (
main8df277f here: 64/91 passed, 27 skipped, all wave64 tests needing a 64-wide subgroup) LEONIDA_W64_EMULATE=1: 98/98 passed (mainhere: 91/91)python -m unittest discover -s tests/semantic: Ran 981 tests in 187.752s OK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on: #812 (LDS atomics in
spirv_mini_interp.py), which depends on #592. Until they land, this PR's diff also shows their commits. My change is the last commit.tools/rdna2spirv.pytranslatesds_cmpst_rtn_b32but raisesUnsupportedon the non-returningds_cmpst_b32. It isn't in the translated corpus, so this is future-proofing. Claimed in #634.Change
tools/rdna2spirv.py:ds_cmpst_b32 vaddr, data0, data1is the sameOpAtomicCompareExchangeas the_rtn_form,M = (M == data0) ? data1 : M(RDNA2 ISA, DS_CMPST_B32). The old value is dropped. Only the operand positions differ, because there's no vdst.tests/semantic/test_lds_atomics_values.py: one more test runsds_cmpst_b32as one invocation on the CPU. It covers a match, a mismatch and the sign-bit value, and checks that vdst stays untouched.Tested
python -I -m unittest discover -s tests/semantic: all pass. With only the translator change reverted, the new test has 3 errors (Unsupported: ds_cmpst_b32).python -m compileall -q tools testspasses. Not run on a GPU, and no game files used.AI-assisted (Claude Code): it wrote the change and the test, and ran the checks listed above.