tests: GPU fixtures for the ds_wrxchg2_rtn_b32 pair cases and ds_wrxchg2st64_rtn_b32 (TEST-WRXCHG2-B32-EXT) #857
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!857
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/857/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ohshitwaddup on GitHub · 2026-11-24 14:40 UTC · original
ohshitwaddup:tests/gpu-wrxchg2-b32→main· +201 −5 · 4 files · 1 commits · merged 2026-11-25 21:28 UTCClaimed in the coordination issue as: TEST-WRXCHG2-B32-EXT
Depends on: #413 (conflicts only — it rewrites this row's prose and I add fixtures plus runner lists; if it lands first I rebase onto it and re-check the row text).
What and why
docs/design.md'sds_wrxchg2_rtn_b32row namescs_w32_new_opsas its GPU fixture. That fixture compares only the first returned word anddata1in LDS — so four things the same row states had never run on a GPU:data0as the second exchange's return when both offsets name one dword,vdstaliasing the data VGPRs (the data must be read before the result is written),st64step at all (the row records it from a gfx1100 measurement, not from a fixture).Two branchless, one-lane fixtures (32 lanes on one LDS address would race — which lane's exchange runs first is up to the hardware, as the existing
cs_w32_new_opsheader notes):cs_w32_wrxchg2_ext.asm1/1on one dword: first exchange returns the old word, second returnsdata0(not the word the first wrote),M[0x204]ends asdata1, a seeded neighbour at0x700is untouched; thenvdstaliased onto the data VGPRscs_w32_wrxchg2st64.asmst64= 256 bytes: base0x80offsets1/2must address0x180/0x280The
st64fixture is built so the stride is proven, not assumed: it seeds0x84/0x88(where a 4-byte step would land) and0x140/0x2c0(one 256-byte step either side of the real elements), and requires all four to come back untouched. A translator that used the wrong unit fails on those words rather than passing by luck.Both judge all eight words in hex, and are registered in
runtime/test/shaders/check.py(CS_DUMPS,WAVE32_DUMPS,WAVE32_LANE_DUMPS) andscripts/run_gpu_tests.py(the shared branch, itscs_dump_wants, the wave32-waiver list and the hex list).Scope note: this deliberately does not edit the
docs/design.mdrow's prose — #413 is rewriting that row and owns it. Once #413 lands, the row can name these two fixtures in the same pass that names the others.Tested
On current
maind0da7da(the branch's base), Radeon RX 6900 XT (RDNA2 / GFX1030, Navi 21), RADV Mesa 26.2.4, Vulkan 1.4.354, Nobara Linux 44 (kernel 7.2.10), llvm-mc 22.1.8, SPIRV-Tools v2026.1, GCC 16.2.1:Both new fixtures pass in all four runs, with every word exact (16/16). Before this commit the same suite was 231/249 passed, 16 skipped, 2 failed on this card — the
+2 passedis exactly these two fixtures.The two failures in the full runs are
cs_imgload_tfeandcs_imgload_d16_tfe("r32 sint (sint view): 64 bad, texel(5,3) = 2071") — the pre-existing SHADER-1266 / #31 pair, reproduced from stockmainand unchanged by this commit.LEONIDA_W64_EMULATE=1gives byte-identical verdicts, as expected for single-lane shaders with no cross-lane operation.Also:
python -I scripts/check_no_game_data.pyon all four changed files is clean,python -m compileallontools tests scriptsand the two edited Python files passes, and the fixtures are LF with a trailing newline like the neighbouring.asmfiles.ctest/translator suite not run — no translator or runtime C++ change.GPUs tested: AMD Radeon RX 6900 XT (RDNA2, GFX1030, Navi 21, PCI 1002:73bf), RADV / Mesa 26.2.4, Vulkan 1.4.354, Nobara Linux 44 (Fedora 44), kernel 7.2.10-200.nobara.fc44.x86_64.
AI-assisted: yes (Hermes Agent) — wrote the two fixtures, derived their expected words from the ISA and the row, ran them, and registered them in both runners.
Checklist
mainand merges cleanly.docs/design.md— n/a, no translator change.docs/design.md's ds_wrxchg2_rtn_b32 row names cs_w32_new_ops as its fixture, and that fixture compares only the first returned word and data1 in LDS. Four things the row states were therefore never checked on a GPU: the second returned word, data0, the st64 step, and vdst aliasing the data VGRs. The row's own note also records the non-st64 step indirectly only on gfx1100. Two branchless fixtures, one lane each (32 lanes on one LDS address would race): cs_w32_wrxchg2_ext both offsets on one dword: the first exchange returns the old word and the second returns data0, not the word the first wrote; a neighbouring LDS word is untouched; with vdst aliased onto the data VGPRs the data is read before the result is written, so vdst gets the old pair and LDS the new one. cs_w32_wrxchg2st64 the st64 unit is 64 dwords: base 0x80 with offsets 1/2 addresses 0x180 and 0x280. 0x84/0x88 (where a 4-byte step would land) and 0x140/0x2c0 (one step either side of the real elements) are seeded and must come back untouched, which is what pins the stride rather than assuming it. Both are registered in check.py (CS_DUMPS, WAVE32_DUMPS, WAVE32_LANE_DUMPS) and scripts/run_gpu_tests.py, and judge all eight words in hex. Measured on a Radeon RX 6900 XT (RDNA2, GFX1030, RADV Mesa 26.2.4, Nobara Linux 44), maind0da7da: build.py 283 shaders: 283 translated, 283 pass spirv-val check.py 217 of 222 pass, 3 skipped, 2 failed run_gpu_tests.py 233/251 passed, 16 skipped, 2 failed (native and LEONIDA_W64_EMULATE=1 alike) --filter wrxchg2 2/2 PASS both modes, every word exact (16/16) The two failures in the full runs are cs_imgload_tfe and cs_imgload_d16_tfe, the pre-existing SHADER-1266/#31 pair, unchanged by this commit. No game files, nothing online. AI-assisted (Hermes Agent).@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-24 14:41 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@abnalstlll-byte on GitHub · 2026-11-24 14:43 UTC · original · approved these changes
Audited and verified. Adds synthetic GPU test fixtures cs_w32_wrxchg2_ext.asm and cs_w32_wrxchg2st64.asm along with runner integrations in
untime/test/shaders/check.py and scripts/run_gpu_tests.py, exercising 2-element LDS exchange return pairs, register aliasing, and stride-64 scaling. Clean-room compliant with zero game data. Approved.
@abnalstlll-byte on GitHub · 2026-11-24 14:44 UTC · original · approved these changes
Clean-Room Audit & Shader Verification — PR #857 (
TEST-WRXCHG2-B32-EXT)Excellent GPU and runner conformance fixtures for dual-word LDS exchanges.
Technical Verification
cs_w32_wrxchg2_ext.asmandcs_w32_wrxchg2st64.asmthoroughly exercise dual-word return values, offset aliasing on a single dword, and vdst/data register overlap fords_wrxchg2_rtn_b32andds_wrxchg2st64_rtn_b32.WAVE32_LANE_DUMPS,cs_dump_wants, andjudge_cs_dumpinruntime/test/shaders/check.pyandscripts/run_gpu_tests.py.Verdict: APPROVED
@Timon360SB on GitHub · 2026-11-24 15:12 UTC · original
Independent verification — Turing and Blackwell
PR head:
5ce143e8b5321c5a6e613504817fa48d20500ab6Environment
Vulkan validation, GPU-assisted validation and synchronization validation enabled.
Three repetitions with and without the wave64 emulation setting on each GPU.
Results
cs_w32_wrxchg2_extcs_w32_wrxchg2st64Both shaders translated successfully and passed spirv-val in every run.
All 192 output words matched the expected values exactly across the 24 test executions.
The shaders remain wave32 in both configurations, as confirmed by the generated index metadata.
GPU-assisted validation failure
Despite exact output values, every execution reports one shared-memory data race:
The reported instruction pairs are identical across both GPUs and all repetitions:
cs_w32_wrxchg2_ext%637 OpAtomicExchange%875 OpLoadcs_w32_wrxchg2st64%335 OpAtomicExchange%505 OpLoadTotal: 24 validation errors across 24 test executions.
Conclusion
Synthetic fixtures only. No game files used.
AI-assisted test automation and result analysis.
@ohshitwaddup on GitHub · 2026-11-25 05:36 UTC · original
Thanks for this — 192 words exact across 24 executions on two NVIDIA generations (Turing 2060 SUPER and Blackwell 5070) is a stronger portability result than I could get alone. One correction to my own framing up front: I had been calling that "cross-vendor", which is wrong — both of your cards are NVIDIA. It is two architectures from one vendor.
Same SPIR-V, two vendors: 16/16 words identical
Since your run was all NVIDIA, I measured the other side myself. I built both fixtures on Linux, then ran the identical
.spvfiles on an AMD card and an NVIDIA card:VKC_SUBGROUP_SIZE=32VKC_SUBGROUP_SIZE=3216 of 16 words identical. Because both runs used the same
.spvbytes — I shipped the Linux build to the Windows box rather than re-translating there — this is one module executed by two drivers. What it shows is that executing the same translated SPIR-V produces bit-identical output buffers (out[0..7]) on RADV and NVIDIA; it does not compare two translator versions. For provenance: the fixtures were built from my branchfix857(a9761ab2), andvk_compute_teston the Windows box was built from currentmain, so the two binaries are not the same commit.That does not speak to the validation warning — values matching and the layer complaining are separate observations, which is exactly why your report is useful.
I believe it is not a cross-invocation race (static analysis, unconfirmed)
I could not reproduce the GPUAV report.
VK_LAYER_KHRONOS_validationis not installed on this host, so everything below is a reading of the module, not a validation run. You have the layer; your run is the authority.What the reported pair most likely is
Your message names the colliding operations as
OpAtomicExchangevsOpLoad, and adds "(Likely against unknown invocation)". I cannot tell from that whether the layer actually observed a second invocation or merely could not identify one — those are different claims and only you can see which the layer meant. Setting that aside, the operation pair has an obvious source in the fixture itself.Both fixtures do an atomic exchange on a workgroup word and then a plain load of the same word, to read back what the exchange stored. The first of the two cases in
cs_w32_wrxchg2_extis (lines elided between the two excerpts):Same word
0x204, one invocation, one after the other. A detector that tracks atomic and non-atomic accesses to a word separately could report that as "a data race ... while performing a load or store operation" without two invocations being involved. The operation kinds match — I cannot map%637/%875to my build, so this is a candidate explanation, not an identification.cs_w32_new_ops, already merged, does the same thing (its header: "out[6]= LDS word at offset1:5 after the exchange"), so this is not new in my fixtures.Why I do not think two invocations are involved
Both fixtures cut EXEC to lane 0 with
v_cmpx_eq_u32_e32 0, v0, which the translator lowers to a per-invocation boolean:%110has exactly one store, so its%trueinitialiser is the only prior value, and after that store it is true for invocation 0 and false for the other 31 (LocalSize 32 1 1).Every workgroup access is behind a real
OpBranchConditionalon a load of%110— control flow, not anOpSelectof the result. In the modules I built: 10 of 10 blocks touching the workgroup array forcs_w32_wrxchg2_ext, 13 of 13 forcs_w32_wrxchg2st64. Neither module has a loop, a barrier, a phi, or more than oneOpReturn, so no path reaches a workgroup access without crossing an EXEC-true edge. In the module I built, a second invocation cannot reach the atomic.Disclosures
5ce143e8. Of the four IDs you quoted, only%335is the same instruction kind here (anOpAtomicExchange, on the 0x280 word that is later plainly read).%637,%875and%505areOpBitwiseAnd,OpShiftRightArithmeticandOpULessThanin my build, so the rest of my argument is about structure, not those specific instructions.cs_w32_wrxchg2st64uses its own EXEC variable (%114), not%110.One test would narrow it a lot
Run one fixture with a single invocation — change
; group: 32,1,1to; group: 1,1,1and rebuild:With one invocation there is no second invocation to race with. If the error still fires, it cannot be a cross-invocation race, and the mixed atomic/plain access above becomes the likely trigger. If it goes quiet, that removes support from the single-invocation explanation — it would not by itself tell us what the guard is doing, since a detector that only flags when more than one invocation exists would also fall silent.
Two controls, in order of usefulness:
cs_w32_new_ops(already merged) — same lane-0 cut, sameds_wrxchg2_rtn_b32, a plain read of the exchanged word, and only 1 plain workgroup load against 2 exchanges.cs_lds_xchg64_ext(already merged) — 10OpAtomicExchangeand 12 plain workgroup loads, also EXEC-guarded.I would not use
cs_lds_atomics_extas a control: it has noOpAtomicExchangeat all, and both merged LDS fixtures contain CAS loops (OpLoopMerge) that mine do not. Its LDS blocks are EXEC-dominated, but not every predecessor is conditional — the CAS-loop headers are entered by a plainOpBranch.What these runs would and would not show
If the merged fixtures report the same warning, that shows the finding predates this PR — it does not by itself show the warning is spurious, because a shared translator bug would produce the same result. So "two runs would narrow it", not "settle it". If they are clean and mine report, then my fixtures differ from the merged ones in some way that matters and I would want the two modules' workgroup blocks compared instruction by instruction before anyone argues for merging.
I am not asking you to accept this as proven, and I would rather keep the warning visible in the fixture headers than quietly drop it.
AI-assisted (Hermes Agent): built five fixtures, ran the two under review on an RX 6900 XT (RADV) and an RTX 5090 (NVIDIA) from the same SPIR-V, traced the EXEC guard and enumerated the workgroup blocks, and identified the atomic-then-plain-load pattern; could not run GPUAV here without the validation layer.
@CodingRule on GitHub · 2026-11-25 12:20 UTC · original
GPU test on an NVIDIA Ada card, for the record: this passes on an RTX 4090.
a9761ab2merged ontomain0d80bc5d(clean merge), test programs built from thatmainwithscripts\build_runtime.ps1.python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_wrxchg2, once native and once withLEONIDA_W64_EMULATE=1.spirv-valclean, 2/2 passed in both modes, with the expected words/pixels from the fixture header. Nothing skipped.scripts\build_llvm_mc.ps1), SPIRV-Tools v2026.4, MSVC 14.44.35207.Only the filtered fixture(s) were run for this PR, not the full suite or ctest; the full-suite baseline for this card on
mainis in #1777. Synthetic fixtures only, no game files. AI-assisted (Claude Code ran the tests and wrote this comment).@aslan2142 on GitHub · 2026-11-25 21:28 UTC · original
Merged, thanks! The new test fails on
mainand passes with this.Non-blocking nit: one continuation line in
scripts/run_gpu_tests.py(around line 1214) lost its indentation.Checked on
mainfb5796b8e+a9761ab2f: the semantic suite passes (491 files, 6,312 tests, 0 files failed);test_run_gpu_tests,test_shader_checkspass; the 15 docs and writer tests pass;check_no_game_data.pyis clean on the 4 changed files.AI-assisted (Claude Code, Claude Opus 5.5).