tests: GPU fixtures for the ds_wrxchg2_rtn_b32 pair cases and ds_wrxchg2st64_rtn_b32 (TEST-WRXCHG2-B32-EXT) #857

Manually merged
github merged 1 commit from gh-pr/857/head into gh-pr/857/base 2026-11-26 09:24:51 +00:00
Owner

@⁠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 UTC

Claimed 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's ds_wrxchg2_rtn_b32 row names cs_w32_new_ops as its GPU fixture. That fixture compares only the first returned word and data1 in LDS — so four things the same row states had never run on a GPU:

  • the second returned word of the pair,
  • data0 as the second exchange's return when both offsets name one dword,
  • vdst aliasing the data VGPRs (the data must be read before the result is written),
  • the st64 step 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_ops header notes):

Fixture Covers Words
cs_w32_wrxchg2_ext.asm offsets 1/1 on one dword: first exchange returns the old word, second returns data0 (not the word the first wrote), M[0x204] ends as data1, a seeded neighbour at 0x700 is untouched; then vdst aliased onto the data VGPRs 8
cs_w32_wrxchg2st64.asm st64 = 256 bytes: base 0x80 offsets 1/2 must address 0x180/0x280 8

The st64 fixture is built so the stride is proven, not assumed: it seeds 0x84/0x88 (where a 4-byte step would land) and 0x140/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) and scripts/run_gpu_tests.py (the shared branch, its cs_dump_wants, the wave32-waiver list and the hex list).

Scope note: this deliberately does not edit the docs/design.md row'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 main d0da7da (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:

build.py          283 shaders: 283 translated, 283 pass spirv-val
                  wave64 VS/PS/GS on 32-wide subgroups: tier A: 11, tier B: 8, tier C: 13
check.py          217 of 222 pass, 3 skipped, 2 failed
                  cs_w32_wrxchg2_ext   ok
                  cs_w32_wrxchg2st64   ok
run_gpu_tests.py  --filter wrxchg2:
                  native                 2/2 passed
                  LEONIDA_W64_EMULATE=1  2/2 passed
                  full suite             233/251 passed, 16 skipped, 2 failed

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 passed is exactly these two fixtures.

The two failures in the full runs are cs_imgload_tfe and cs_imgload_d16_tfe ("r32 sint (sint view): 64 bad, texel(5,3) = 2071") — the pre-existing SHADER-1266 / #31 pair, reproduced from stock main and unchanged by this commit. LEONIDA_W64_EMULATE=1 gives byte-identical verdicts, as expected for single-lane shaders with no cross-lane operation.

Also: python -I scripts/check_no_game_data.py on all four changed files is clean, python -m compileall on tools tests scripts and the two edited Python files passes, and the fixtures are LF with a trailing newline like the neighbouring .asm files. 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

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md — n/a, no translator change.
**@⁠ohshitwaddup** on GitHub · 2026-11-24 14:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/857) `ohshitwaddup:tests/gpu-wrxchg2-b32` → `main` · +201 −5 · 4 files · 1 commits · merged 2026-11-25 21:28 UTC Claimed in the coordination issue as: [TEST-WRXCHG2-B32-EXT](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) 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`'s `ds_wrxchg2_rtn_b32` row names `cs_w32_new_ops` as its GPU fixture. That fixture compares only **the first returned word and `data1` in LDS** — so four things the same row states had never run on a GPU: - the **second** returned word of the pair, - **`data0`** as the second exchange's return when both offsets name one dword, - **`vdst` aliasing the data VGPRs** (the data must be read before the result is written), - the **`st64`** step 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_ops` header notes): | Fixture | Covers | Words | |---|---|---| | `cs_w32_wrxchg2_ext.asm` | offsets `1/1` on one dword: first exchange returns the old word, second returns `data0` (not the word the first wrote), `M[0x204]` ends as `data1`, a seeded neighbour at `0x700` is untouched; then `vdst` aliased onto the data VGPRs | 8 | | `cs_w32_wrxchg2st64.asm` | `st64` = 256 bytes: base `0x80` offsets `1/2` must address `0x180`/`0x280` | 8 | The `st64` fixture is built so the stride is **proven, not assumed**: it seeds `0x84`/`0x88` (where a 4-byte step would land) and `0x140`/`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`) and `scripts/run_gpu_tests.py` (the shared branch, its `cs_dump_wants`, the wave32-waiver list and the hex list). Scope note: this deliberately does **not** edit the `docs/design.md` row'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 `main` `d0da7da` (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: ``` build.py 283 shaders: 283 translated, 283 pass spirv-val wave64 VS/PS/GS on 32-wide subgroups: tier A: 11, tier B: 8, tier C: 13 check.py 217 of 222 pass, 3 skipped, 2 failed cs_w32_wrxchg2_ext ok cs_w32_wrxchg2st64 ok run_gpu_tests.py --filter wrxchg2: native 2/2 passed LEONIDA_W64_EMULATE=1 2/2 passed full suite 233/251 passed, 16 skipped, 2 failed ``` 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 passed` is exactly these two fixtures. The two failures in the full runs are `cs_imgload_tfe` and `cs_imgload_d16_tfe` (`"r32 sint (sint view): 64 bad, texel(5,3) = 2071"`) — the pre-existing SHADER-1266 / #31 pair, reproduced from stock `main` and unchanged by this commit. `LEONIDA_W64_EMULATE=1` gives byte-identical verdicts, as expected for single-lane shaders with no cross-lane operation. Also: `python -I scripts/check_no_game_data.py` on all four changed files is clean, `python -m compileall` on `tools tests scripts` and the two edited Python files passes, and the fixtures are LF with a trailing newline like the neighbouring `.asm` files. `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 - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `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), main d0da7da:
  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).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:24:47 +00:00
github manually merged commit a9761ab2f9 into gh-pr/857/base 2026-11-26 09:24:51 +00:00
Author
Owner

@⁠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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-24 14:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/857#pullrequestreview-6041308767) · **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.
Author
Owner

@⁠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:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/857#pullrequestreview-6041362052) · **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.
Author
Owner

@⁠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

  1. LDS Atomic Exchanges:
    • Fixtures cs_w32_wrxchg2_ext.asm and cs_w32_wrxchg2st64.asm thoroughly exercise dual-word return values, offset aliasing on a single dword, and vdst/data register overlap for ds_wrxchg2_rtn_b32 and ds_wrxchg2st64_rtn_b32.
    • Lane 0 gating correctly prevents hardware execution races across wavefronts.
  2. Runner Integration:
    • Cleanly added to WAVE32_LANE_DUMPS, cs_dump_wants, and judge_cs_dump in runtime/test/shaders/check.py and scripts/run_gpu_tests.py.
  3. Clean-Room Compliance:
    • Fully documented, synthetic hand-crafted assembly with zero game assets.

Verdict: APPROVED

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:44 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/857#pullrequestreview-6041372800) · **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 1. **LDS Atomic Exchanges**: - Fixtures `cs_w32_wrxchg2_ext.asm` and `cs_w32_wrxchg2st64.asm` thoroughly exercise dual-word return values, offset aliasing on a single dword, and vdst/data register overlap for `ds_wrxchg2_rtn_b32` and `ds_wrxchg2st64_rtn_b32`. - Lane 0 gating correctly prevents hardware execution races across wavefronts. 2. **Runner Integration**: - Cleanly added to `WAVE32_LANE_DUMPS`, `cs_dump_wants`, and `judge_cs_dump` in `runtime/test/shaders/check.py` and `scripts/run_gpu_tests.py`. 3. **Clean-Room Compliance**: - Fully documented, synthetic hand-crafted assembly with zero game assets. **Verdict: APPROVED**
Author
Owner

@⁠Timon360SB on GitHub · 2026-11-24 15:12 UTC · original

Independent verification — Turing and Blackwell

PR head: 5ce143e8b5321c5a6e613504817fa48d20500ab6

Environment

Configuration RTX 2060 SUPER RTX 5070
Architecture Turing Blackwell
NVIDIA driver 621.14 621.14
Windows 11 build 28000 26200
Vulkan SDK 1.4.363.0 1.4.363.0
LLVM 21.1.8 21.1.8
SPIRV-Tools 2026.4.rc2 2026.4.rc2
Subgroup size 32 32

Vulkan validation, GPU-assisted validation and synchronization validation enabled.

Three repetitions with and without the wave64 emulation setting on each GPU.

Results

Test 2060S Native 2060S W64 setting 5070 Native 5070 W64 setting
cs_w32_wrxchg2_ext 0/3 0/3 0/3 0/3
cs_w32_wrxchg2st64 0/3 0/3 0/3 0/3

Both 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:

vkCmdDispatch(): A data race was detected on the
shared memory variable "[No OpName found, ID 5]"
in local invocation index 0 while performing
a load or store operation.
(Likely against unknown invocation)

The reported instruction pairs are identical across both GPUs and all repetitions:

Shader Atomic operation Load operation
cs_w32_wrxchg2_ext %637 OpAtomicExchange %875 OpLoad
cs_w32_wrxchg2st64 %335 OpAtomicExchange %505 OpLoad

Total: 24 validation errors across 24 test executions.

Conclusion

  • Both new fixtures produce bit-exact results on Turing and Blackwell.
  • All executions fail under GPU-assisted validation due to reported shared-memory data races.
  • The behavior is reproducible across both architectures.
  • Further investigation is needed to distinguish a translator synchronization issue from a validation-layer false positive.
  • No baseline comparison was performed because these fixtures are new.

Synthetic fixtures only. No game files used.

AI-assisted test automation and result analysis.

**@⁠Timon360SB** on GitHub · 2026-11-24 15:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/857#issuecomment-7135645663) ## Independent verification — Turing and Blackwell **PR head:** `5ce143e8b5321c5a6e613504817fa48d20500ab6` ### Environment | Configuration | RTX 2060 SUPER | RTX 5070 | | --- | --- | --- | | Architecture | Turing | Blackwell | | NVIDIA driver | 621.14 | 621.14 | | Windows 11 build | 28000 | 26200 | | Vulkan SDK | 1.4.363.0 | 1.4.363.0 | | LLVM | 21.1.8 | 21.1.8 | | SPIRV-Tools | 2026.4.rc2 | 2026.4.rc2 | | Subgroup size | 32 | 32 | Vulkan validation, GPU-assisted validation and synchronization validation enabled. Three repetitions with and without the wave64 emulation setting on each GPU. ### Results | Test | 2060S Native | 2060S W64 setting | 5070 Native | 5070 W64 setting | | --- | --- | --- | --- | --- | | `cs_w32_wrxchg2_ext` | 0/3 | 0/3 | 0/3 | 0/3 | | `cs_w32_wrxchg2st64` | 0/3 | 0/3 | 0/3 | 0/3 | Both 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: ```text vkCmdDispatch(): A data race was detected on the shared memory variable "[No OpName found, ID 5]" in local invocation index 0 while performing a load or store operation. (Likely against unknown invocation) ``` The reported instruction pairs are identical across both GPUs and all repetitions: | Shader | Atomic operation | Load operation | | --- | --- | --- | | `cs_w32_wrxchg2_ext` | `%637 OpAtomicExchange` | `%875 OpLoad` | | `cs_w32_wrxchg2st64` | `%335 OpAtomicExchange` | `%505 OpLoad` | Total: 24 validation errors across 24 test executions. ### Conclusion - Both new fixtures produce bit-exact results on Turing and Blackwell. - All executions fail under GPU-assisted validation due to reported shared-memory data races. - The behavior is reproducible across both architectures. - Further investigation is needed to distinguish a translator synchronization issue from a validation-layer false positive. - No baseline comparison was performed because these fixtures are new. Synthetic fixtures only. No game files used. AI-assisted test automation and result analysis.
Author
Owner

@⁠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 .spv files on an AMD card and an NVIDIA card:

AMD Radeon RX 6900 XT NVIDIA GeForce RTX 5090
Architecture RDNA2 / GFX1030, Navi 21 Blackwell
Driver RADV, Mesa 26.2.4, Vulkan 1.4.354 NVIDIA 617.42
Subgroup 32..64 (default 64) 32..32
Requested size VKC_SUBGROUP_SIZE=32 VKC_SUBGROUP_SIZE=32
OS Nobara Linux 44, kernel 7.2.10 Windows 11
cs_w32_wrxchg2_ext  AMD   out[0..7] = 2004318071 2290614280 2576941065 3735928559 2863311530 3149642683 305402420 1450727032
cs_w32_wrxchg2_ext  NV    out[0..7] = 2004318071 2290614280 2576941065 3735928559 2863311530 3149642683 305402420 1450727032
cs_w32_wrxchg2st64  AMD   out[0..7] = 858993459 1145324612 1431633925 1717960710 2964324484 2964324488 2964324672 2964325056
cs_w32_wrxchg2st64  NV    out[0..7] = 858993459 1145324612 1431633925 1717960710 2964324484 2964324488 2964324672 2964325056

16 of 16 words identical. Because both runs used the same .spv bytes — 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 branch fix857 (a9761ab2), and vk_compute_test on the Windows box was built from current main, 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_validation is 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 OpAtomicExchange vs OpLoad, 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_ext is (lines elided between the two excerpts):

v_mov_b32_e32 v1, 0x200
ds_wrxchg2_rtn_b32 v[12:13], v1, v4, v5 offset0:1 offset1:1   ; atomic on element 0x204
...
v_mov_b32_e32 v1, 0x204
ds_read_b32 v10, v1                                          ; plain load of 0x204

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/%875 to 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:

%235 = OpLoad %uint %221               ; this invocation's gl_LocalInvocationID.x
%236 = OpIEqual %bool %uint_0 %235     ; (0 == v0)
%238 = OpLoad %bool %110
%239 = OpLogicalAnd %bool %238 %236    ; EXEC &= (v0 == 0)
OpStore %110 %239

%110 has exactly one store, so its %true initialiser 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 OpBranchConditional on a load of %110 — control flow, not an OpSelect of the result. In the modules I built: 10 of 10 blocks touching the workgroup array for cs_w32_wrxchg2_ext, 13 of 13 for cs_w32_wrxchg2st64. Neither module has a loop, a barrier, a phi, or more than one OpReturn, 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

  • Revision mismatch. I analysed the rebased branch, not your head 5ce143e8. Of the four IDs you quoted, only %335 is the same instruction kind here (an OpAtomicExchange, on the 0x280 word that is later plainly read). %637, %875 and %505 are OpBitwiseAnd, OpShiftRightArithmetic and OpULessThan in my build, so the rest of my argument is about structure, not those specific instructions. cs_w32_wrxchg2st64 uses its own EXEC variable (%114), not %110.
  • I read the merged fixtures' SPIR-V statically (that is where the counts above come from), but I did not run any of them under GPUAV.

One test would narrow it a lot

Run one fixture with a single invocation — change ; group: 32,1,1 to ; group: 1,1,1 and rebuild:

VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT vk_compute_test cs_w32_wrxchg2_ext.spv 1 dump

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:

  1. cs_w32_new_ops (already merged) — same lane-0 cut, same ds_wrxchg2_rtn_b32, a plain read of the exchanged word, and only 1 plain workgroup load against 2 exchanges.
  2. cs_lds_xchg64_ext (already merged) — 10 OpAtomicExchange and 12 plain workgroup loads, also EXEC-guarded.

I would not use cs_lds_atomics_ext as a control: it has no OpAtomicExchange at 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 plain OpBranch.

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.

**@⁠ohshitwaddup** on GitHub · 2026-11-25 05:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/857#issuecomment-7153953786) 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 `.spv` files** on an AMD card and an NVIDIA card: | | AMD Radeon RX 6900 XT | NVIDIA GeForce RTX 5090 | |---|---|---| | Architecture | RDNA2 / GFX1030, Navi 21 | Blackwell | | Driver | RADV, Mesa 26.2.4, Vulkan 1.4.354 | NVIDIA 617.42 | | Subgroup | 32..64 (default 64) | 32..32 | | Requested size | `VKC_SUBGROUP_SIZE=32` | `VKC_SUBGROUP_SIZE=32` | | OS | Nobara Linux 44, kernel 7.2.10 | Windows 11 | ``` cs_w32_wrxchg2_ext AMD out[0..7] = 2004318071 2290614280 2576941065 3735928559 2863311530 3149642683 305402420 1450727032 cs_w32_wrxchg2_ext NV out[0..7] = 2004318071 2290614280 2576941065 3735928559 2863311530 3149642683 305402420 1450727032 cs_w32_wrxchg2st64 AMD out[0..7] = 858993459 1145324612 1431633925 1717960710 2964324484 2964324488 2964324672 2964325056 cs_w32_wrxchg2st64 NV out[0..7] = 858993459 1145324612 1431633925 1717960710 2964324484 2964324488 2964324672 2964325056 ``` **16 of 16 words identical.** Because both runs used the same `.spv` bytes — 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 branch `fix857` (`a9761ab2`), and `vk_compute_test` on the Windows box was built from current `main`, 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_validation` is 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 `OpAtomicExchange` vs `OpLoad`, 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_ext` is (lines elided between the two excerpts): ``` v_mov_b32_e32 v1, 0x200 ds_wrxchg2_rtn_b32 v[12:13], v1, v4, v5 offset0:1 offset1:1 ; atomic on element 0x204 ... v_mov_b32_e32 v1, 0x204 ds_read_b32 v10, v1 ; plain load of 0x204 ``` 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`/`%875` to 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: ```spirv %235 = OpLoad %uint %221 ; this invocation's gl_LocalInvocationID.x %236 = OpIEqual %bool %uint_0 %235 ; (0 == v0) %238 = OpLoad %bool %110 %239 = OpLogicalAnd %bool %238 %236 ; EXEC &= (v0 == 0) OpStore %110 %239 ``` `%110` has exactly one store, so its `%true` initialiser 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 `OpBranchConditional` on a load of `%110` — control flow, not an `OpSelect` of the result. In the modules I built: 10 of 10 blocks touching the workgroup array for `cs_w32_wrxchg2_ext`, 13 of 13 for `cs_w32_wrxchg2st64`. Neither module has a loop, a barrier, a phi, or more than one `OpReturn`, 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 - **Revision mismatch.** I analysed the rebased branch, not your head `5ce143e8`. Of the four IDs you quoted, only `%335` is the same instruction kind here (an `OpAtomicExchange`, on the 0x280 word that is later plainly read). `%637`, `%875` and `%505` are `OpBitwiseAnd`, `OpShiftRightArithmetic` and `OpULessThan` in my build, so the rest of my argument is about structure, not those specific instructions. `cs_w32_wrxchg2st64` uses its own EXEC variable (`%114`), not `%110`. - I read the merged fixtures' SPIR-V statically (that is where the counts above come from), but I did **not** run any of them under GPUAV. ## One test would narrow it a lot Run one fixture with a single invocation — change `; group: 32,1,1` to `; group: 1,1,1` and rebuild: ``` VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT vk_compute_test cs_w32_wrxchg2_ext.spv 1 dump ``` 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: 1. **`cs_w32_new_ops`** (already merged) — same lane-0 cut, same `ds_wrxchg2_rtn_b32`, a plain read of the exchanged word, and only 1 plain workgroup load against 2 exchanges. 2. **`cs_lds_xchg64_ext`** (already merged) — 10 `OpAtomicExchange` and 12 plain workgroup loads, also EXEC-guarded. I would **not** use `cs_lds_atomics_ext` as a control: it has no `OpAtomicExchange` at 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 plain `OpBranch`. ## 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.
Author
Owner

@⁠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.

  • Tested: this branch's head a9761ab2 merged onto main 0d80bc5d (clean merge), test programs built from that main with scripts\build_runtime.ps1.
  • Command: python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_wrxchg2, once native and once with LEONIDA_W64_EMULATE=1.
  • Result: 2/2 translated and spirv-val clean, 2/2 passed in both modes, with the expected words/pixels from the fixture header. Nothing skipped.
  • Device: NVIDIA GeForce RTX 4090 (Ada / AD102), driver 591.86, Vulkan 1.4.325, subgroup 32..32, Windows 11 Pro build 26200. llvm-mc 21.1.8 (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 main is in #1777. Synthetic fixtures only, no game files. AI-assisted (Claude Code ran the tests and wrote this comment).

**@⁠CodingRule** on GitHub · 2026-11-25 12:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/857#issuecomment-7162236113) GPU test on an NVIDIA Ada card, for the record: this passes on an **RTX 4090**. - **Tested:** this branch's head `a9761ab2` merged onto `main` `0d80bc5d` (clean merge), test programs built from that `main` with `scripts\build_runtime.ps1`. - **Command:** `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_wrxchg2`, once native and once with `LEONIDA_W64_EMULATE=1`. - **Result:** 2/2 translated and `spirv-val` clean, 2/2 passed in both modes, with the expected words/pixels from the fixture header. Nothing skipped. - **Device:** NVIDIA GeForce RTX 4090 (Ada / AD102), driver 591.86, Vulkan 1.4.325, subgroup 32..32, Windows 11 Pro build 26200. llvm-mc 21.1.8 (`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 `main` is in #1777. Synthetic fixtures only, no game files. AI-assisted (Claude Code ran the tests and wrote this comment).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 21:28 UTC · original

Merged, thanks! The new test fails on main and passes with this.

  • Non-blocking nit: one continuation line in scripts/run_gpu_tests.py (around line 1214) lost its indentation.

  • Checked on main fb5796b8e + a9761ab2f: the semantic suite passes (491 files, 6,312 tests, 0 files failed); test_run_gpu_tests, test_shader_checks pass; the 15 docs and writer tests pass; check_no_game_data.py is clean on the 4 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 21:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/857#issuecomment-7175128310) Merged, thanks! The new test fails on `main` and passes with this. - **Non-blocking nit:** one continuation line in `scripts/run_gpu_tests.py` (around line 1214) lost its indentation. - **Checked on `main` `fb5796b8e` + `a9761ab2f`:** the semantic suite passes (491 files, 6,312 tests, 0 files failed); `test_run_gpu_tests`, `test_shader_checks` pass; the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 4 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.