Skip to content

GPU test: contended global_atomic_swap_x2 glc, dword sets exact, torn pairs counted (TEST-561) - #4964

Open
Etr0p wants to merge 3 commits into
ItsNotRexed:mainfrom
Etr0p:test/swap-x2-contention
Open

Etr0p wants to merge 3 commits into
ItsNotRexed:mainfrom
Etr0p:test/swap-x2-contention

Conversation

@Etr0p

@Etr0p Etr0p commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST-561, #4933 (comment)

What and why

global_atomic_swap_x2 had no GPU test with more than one invocation on the same element. #2821 covers the single-lane glc form, and BUILD-824 ran identical replacement pairs, which can't show whether a pair stays whole. This adds the contended case with pairs that can be told apart.

runtime/test/shaders/cs_w32_swap_x2_contend.asm (hand-written, wave32, 64 workgroups of 32): every invocation swaps its own pair (low = 0x51000000 | i, high = ~low) into one shared 64-bit element with global_atomic_swap_x2 ... glc and stores the pair it got back. Whatever order the 2,048 invocations ran in:

  • Per dword, required. The returned low dwords plus the element's final low dword are exactly the fill plus every replacement low, each once, and the same for the high dwords. A value handed out twice or never is a lost exchange. check.py and scripts/run_gpu_tests.py dispatch the shader once and fail without this.
  • Per pair, counted. A returned pair whose halves don't belong together is a torn element. tools/rdna2spirv.py swaps the two dwords with one 32-bit atomic each, and docs/design.md already calls that an approximation. The PASS line says how many pairs were torn, and runtime/test/shaders/swap_x2_contend.py <out> <build> --runs N adds the counts up over many dispatches (--strict fails on a torn pair, for a translation that swaps the element whole).

What the two GPUs show (200 dispatches each, 409,800 pairs):

Device Both dword sets exact Torn pairs
NVIDIA GeForce RTX 5070 Ti Laptop GPU (621.24) 200 of 200 396,165 (96.7%)
AMD Radeon 610M (AMD 26.11.2) 200 of 200 4,069 (1.0%)

So each half's exchange is atomic on both, and on NVIDIA a returned pair is almost never one invocation's pair. Both devices report shaderBufferInt64Atomics, so a 64-bit OpAtomicExchange path is possible there; I did not write it (see the finding in the coordination issue). No translator change in this PR.

Also in the PR: tests/test_swap_x2_contend.py (12 CPU tests of the checker and the launch), the new case in tests/test_shader_checks.py's fake harness and total, the measurement in the global atomics row of docs/design.md, and the commands in docs/testing.md.

Overlap: #2821 touches check.py and run_gpu_tests.py too. A trial merge of its head 991b691e with this branch is clean, but both add cases, so the case total in tests/test_shader_checks.py needs a look by whichever lands second.

Tested

Windows 11 Home 26200, main at 3faac557, llvm-mc 23.1.6, SPIRV-Tools v2026.4, test programs built with llvm-mingw 23.1.6; NVIDIA GeForce RTX 5070 Ti Laptop GPU (621.24, subgroup 32..32) and AMD Radeon 610M (RDNA2 iGPU, AMD 26.11.2 / 32.0.21045.29003, subgroup 32..64), one GPU at a time through LEONIDA_VK_DEVICE.

  • scripts/run_gpu_tests.py, 222 shaders translated and 222 pass spirv-val, 0 failed in every run: RTX native 171/218 (47 skipped), RTX LEONIDA_W64_EMULATE=1 202/218, 610M native 196/218, 610M LEONIDA_PC_TAIL_UBO=1 196/218. The new line, for example: PASS cs_w32_swap_x2_contend both dword sets exact; 1980 of 2049 pairs torn (RTX), 15 of 2049 (610M).
  • runtime/test/shaders/check.py on the RTX: cs_w32_swap_x2_contend ok, 154 of 189 pass, 35 skipped.
  • swap_x2_contend.py --runs 200: the table above, exit 0; with --strict, exit 1 on both devices.
  • Negative control: with the swap replaced by global_load_dwordx2 then global_store_dwordx2 (not committed), 20 of 20 dispatches fail on each device, about 2,020 of 2,049 dwords of each half never handed out.
  • CPU: tests/test_swap_x2_contend.py 12 OK, tests/test_shader_checks.py 79 OK, test_run_gpu_tests_paths.py, test_text_write_line_endings.py, test_check_no_game_data.py, test_gpu_test_timeout.py and the test_docs_* / test_design_contract_rows.py files that run under python -I OK; python -m compileall clean.
  • tests/test_rdna2_decode.py has 1 failure here (test_parity_with_llvm_mc_on_shader_fixtures, a null operand), the same on main without this change, with llvm-mc 23.1.6.

Not tested: Linux, Intel, a device with fewer than 32 lanes, and the pytest-only test files.

AI-assisted: yes (Claude Code)

Checklist

  • 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, with how it was confirmed. (Not applicable: no new rule; the existing global atomics row gains this measurement.)

🤖 Generated with Claude Code

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

At 0c1ca028, the checker accepts an impossible atomic exchange order. Invocation 0 returns the value from invocation 1. Invocation 1 returns the value from invocation 0. Both cannot be the earlier exchange on the same dword. The remaining invocations form a valid chain from the initial fill to the final value.

Run this with py -3.14 -I - from the repository root:

from pathlib import Path
import sys
sys.path.insert(0, str(Path("runtime/test/shaders").resolve()))
import check

p = [check.swap_x2_replacement(i) for i in range(check.SWAP_X2_INVOCATIONS)]
fill = (check.SWAP_X2_FILL,) * 2
for pairs in ([fill, *p], [p[1], p[0], fill, *p[2:]]):
    print(check.swap_x2_contend_words([w for pair in pairs for w in pair]))

Both cases return ('', 0). The first should pass. The second should report an invalid exchange order. Both have the expected dword counts and the same final pair.

For each half separately, start with the final value and follow each writer's returned value to its predecessor. Require the chain to visit all 2,048 writers once and end at the fill. This takes linear time and still allows the low and high halves to have different orders.

The 12 contention tests and 79 shader-check tests pass on Windows with CPython 3.14.7. This is a CPU reproduction of the checker defect.

AI-assisted.

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 0c1ca028dc734d0f9d7f082036ef1bd15995ee19 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

One dispatch of the synthetic cs_w32_swap_x2_contend fixture at 0c1ca028 on Linux RTX 5090 returned both expected dword sets exactly, with 1,470 of 2,049 pairs torn across the 2,048 returns and the final stored pair. The shader translated and passed SPIR-V validation. The count describes this dispatch only. The checked-in oracle checks each half’s values and multiplicities; exchange ordering remains unverified.

AI-assisted verification.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 0c1ca02 on Intel UHD Graphics 630 (CFL GT2, subgroup 8..32), Mesa 25.2.8 ANV, Ubuntu 24.04, LEONIDA_VK_DEVICE=Intel: pass.

  • scripts/run_gpu_tests.py --filter swap_x2: PASS cs_w32_swap_x2_contend, both dword sets exact; 1826 of 2049 pairs torn. 1/1 passed.
  • runtime/test/shaders/swap_x2_contend.py --runs 200: 200 runs of 2048 invocations: 200 kept both dword sets; 200 runs had torn pairs (307868 of 409800 pairs).
  • tests/test_swap_x2_contend.py: Ran 12 tests, OK.

--strict and the load/store negative control were not run here.

AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

Code sound, merge-ready; GPU behaviour unverified here.

Verified: 12 + 79 CPU tests, the path test, and compileall pass; negative control on origin/main with the tests copied fails 13 with AttributeError: SWAP_X2_INVOCATIONS; merge clean. The checker invariant (2049 pairs, per-dword multisets, fill 0xEEEEEEEE) reasoning-checks, shader conventions match cs_lds.asm (s4=TGID_X, v0=TID), and element word 4096 sits inside the 4104-word dump.

Two documentation inconsistencies:

  • docs/testing.md:143-144 says "its PASS line also says how many pairs were torn", but that holds only for run_gpu_tests.py; check.py:1611 discards the torn count ([0]).
  • docs/design.md:261 gains a Measured (TEST-561) clause but still ends **Not GPU-verified.**

No llvm-mc with an AMDGPU target and no built vk_compute_test here, so torn rates, the 222/222 translation and the 154/189 totals stay unconfirmed.

AI-assisted review, no game files, no game GPU.

@Etr0p

Etr0p commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, three points taken; the head is now 3f49c14c.

@shdann, the impossible order. You're right: the multiset alone accepts two invocations each holding the other's value. 51748f42 adds the chain you describe, per half: starting from the element's final value, each writer's returned dword names the writer before it, and the walk has to pass all 2,048 writers and end at the fill. The low and high halves keep their own orders. Your reproduction now gives

('', 0)
('low dwords: the exchanges are not one order: going back from the final value reaches the fill after 2046 of 2048 writers; high dwords: ...', 0)

and is in tests/test_swap_x2_contend.py (14 tests now), with a second case where only one half has the cycle. The set check runs first, so the walk only ever sees values that occur once. Rerun on both GPUs with the stricter check, 200 dispatches each: 200 of 200 pass on the RTX 5070 Ti Laptop GPU (391,375 of 409,800 pairs torn, 95.5%) and on the Radeon 610M (4,102, 1.0%). The PASS line and the script now say "both dword orders exact".

@tupacfan04, the two doc points (3f49c14c): docs/testing.md now says that scripts/run_gpu_tests.py prints the torn count and check.py only ok; and the global atomics row of docs/design.md no longer ends "Not GPU-verified" after a measurement: it says swap_x2 with glc under contention is GPU-verified and the other forms are not. The row had that ending twice, and both are changed. Since the second 200-dispatch series gave 95.5% where the first gave 96.7%, the row now gives both figures.

Data from other devices, thanks @tylerstraub and @gertify: with yours the torn share is 72% on an RTX 5090 on Linux (one dispatch), 75% on an Intel UHD 630 with ANV (200), about 96% on the RTX 5070 Ti Laptop on Windows and 1% on the Radeon 610M. Those two runs were on 0c1ca028, before the order check; the fixture is unchanged, so the same dispatches are judged, only more strictly.

Not rerun after these two commits: the full suite (only the checker and docs changed; --filter swap_x2, check.py's line, the 200-dispatch runs and the CPU and docs tests were). AI-assisted (Claude Code).

@theswiss24

Copy link
Copy Markdown

Tested the new head 3f49c14c (after the exchange-order fix) on an NVIDIA GeForce RTX 2060 SUPER (580.178.04, Ubuntu 24.04). Full scripts/run_gpu_tests.py with LEONIDA_W64_EMULATE=1, PR merged onto main 3faac557, compared with main at the same commit and test programs built from it.

Result: pass.

main PR
RTX 2060 SUPER 201/217 passed, 16 skipped 202/218 passed, 16 skipped

cs_w32_swap_x2_contend passes with the stricter checker; every other test has the same result as on main. (The earlier 0c1ca028 also passed on the MX150 and the UHD 630, Mesa ANV 25.2.8, but I haven't rerun those two at 3f49c14c.)

Tested and written by Claude (Claude Code), posting from @theswiss24's account.

@CaravelaLabs

Copy link
Copy Markdown
Contributor

Follow-up at 3f49c14c (stricter per-half order check) merged onto main 3faac557 on AMD Radeon 8060S (RADV GFX1151, RDNA 3.5), Mesa 25.2.8, Ubuntu 24.04, runtime rebuilt from this branch in a clean sandbox.

  • cs_w32_swap_x2_contend: pass — both dword orders exact; 2049 of 2049 pairs torn (one dispatch).
  • Rest of scripts/run_gpu_tests.py: 200/218 passed, 16 skipped, same two known Mesa 25.2 RADV failures as main (cs_signed_zero_nan, cs_w32_salu64, GPU test results (one comment per GPU and driver) #166).
  • Python tests this PR touches: 97 passed, 269 subtests passed.

AI-assisted (Claude Code).

@editrice

Copy link
Copy Markdown

Tested current head 3f49c14ca6e5778a9dc73b53673c13277ff92a53 on Windows 11, NVIDIA GeForce RTX 5070 (driver 621.01), AMDGPU llvm-mc 23.1.5, Python 3.15.2, and Vulkan SDK/SPIRV-Tools 1.4.363.1. The synthetic fixture translated 1/1 and passed spirv-val 1/1. tests/test_swap_x2_contend.py passed 14/14 and tests/test_shader_checks.py passed 79/79. The valid whole-swap chain still returns success; the previously reported cyclic per-dword history is now rejected for both halves after 2,046 of 2,048 writers, confirming the repaired order check.

scripts/run_gpu_tests.py --filter swap_x2_contend --require-pass passed 1/1: both dword orders exact, 1,800/2,049 returned/final pairs torn. Five repeated dispatches all preserved both dword orders and all tore (9,793/10,245 pairs torn). A two-run --strict control preserved both orders but exited 1 because 3,657/4,098 pairs were torn, as intended.

This independently validates the current-head checker and the synthetic hardware behavior on RTX 5070. It does not claim that the two-dword implementation is an atomic 64-bit swap. Synthetic inputs only, no game files. AI-assisted verification.

@Atomic258

Copy link
Copy Markdown
Contributor

Independent check — pass, live GPU fixture run on NVIDIA.

Environment: Windows 11, MSVC 19.44 (RelWithDebInfo, Ninja), NVIDIA GeForce RTX 5090 (driver 617.42), Vulkan SDK 1.4.363.0, native Windows llvm-mc (LLVM 21.1.8 + AMDGPU), LEONIDA_VK_DEVICE="rtx 5090", LEONIDA_VK_VALIDATION=1. Synthetic fixture, no game files.

  • run_gpu_tests.py --filter cs_w32_swap_x2_contend → 1/1 PASS: "both dword orders exact; 1309 of 2049 pairs torn" — the contention actually occurs and torn pairs are counted, which is exactly what the fixture is meant to measure
  • rdna2spirv.py on the fixture → 1/1 translated, spirv-val clean
  • The swap_x2_contend.py result parser is part of the diff; the run exercises it end-to-end

AI-assisted (Devin).

@mixyt

mixyt commented Nov 23, 2026

Copy link
Copy Markdown

Independent 200-dispatch run at 3f49c14ca6e5778a9dc73b53673c13277ff92a53 on GeForce GTX 1650 Mobile (Turing), Windows 11, NVIDIA 621.24, subgroup 32..32. Built vk_compute_test from this head with MSVC 19.44, x64 Release, Vulkan SDK 1.4.363.0. The synthetic cs_w32_swap_x2_contend fixture translated and passed spirv-val.

swap_x2_contend.py --runs 200 exited 0: 200/200 dispatches preserved both dword exchange orders. Torn pairs appeared in 200/200 dispatches: 388,600 / 409,800 (94.83%) returned/final pairs. This is for the current two-dword lowering, not a 64-bit atomicity pass.

AI-assisted verification; synthetic fixtures only, no game data.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 3f49c14 on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_shader_checks.py -> Ran 79 tests, OK; python -I tests/test_swap_x2_contend.py -> Ran 14 tests, OK
  • GPU .asm/cs parts not run (no GPU).

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

Etr0p added a commit to Etr0p/Leonida that referenced this pull request Nov 23, 2026
tests/test_shader_checks.py: main added cs_fmt_all where this branch adds cs_w32_swap_x2_contend;
both are kept, and TOTAL's constant becomes 15 (each side had raised 13 to 14, which merged
silently). docs/design.md: main's Global atomics row with this branch's three edits re-applied
(the TEST-561 measurement and the swap_x2 GPU-verified wording).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Etr0p

Etr0p commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Merged main 561b65a8 in 5f6d83a2, which clears both conflicts. Nothing else in the PR changed.

  • tests/test_shader_checks.py: main added cs_fmt_all where this branch adds cs_w32_swap_x2_contend. Both are kept. TOTAL's constant is now 15: each side had raised 13 to 14, and git merged that line silently, which would have undercounted by one.
  • docs/design.md: I took main's Global atomics row and re-applied this PR's three edits: the TEST-561 measurement and the two "GPU-verified only for swap_x2" phrases. Nothing else in the row differs from main.

Retested at 5f6d83a2 (Windows 11 26200, MSVC 14.44, runtime rebuilt at this commit):

AI-assisted (Claude Code).

@Etr0p

Etr0p commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

The red macos job here is BUILD-1895, which affects every PR merged with main 561b65a8: the job fails on cs_w32_permlane_fi and cs_fmt_int_narrow, and this PR touches neither. In the same job, this PR's own test passes on MoltenVK (Apple GPU): PASS cs_w32_swap_x2_contend both dword orders exact; 820 of 2049 pairs torn (log). That's the first Apple measurement for it: 40% torn, between the Radeon 610M's 0.5% and NVIDIA's 94-97%. AI-assisted (Claude Code).

@sovljanskii

Copy link
Copy Markdown
Contributor

Tested 5f6d83a merged onto main 561b65a on Apple M4 (10-core GPU, 32-wide subgroups), macOS 27.2.1, MoltenVK 1.4.2, Python 3.15.2 and 3.12.16: pass

  • What changed since 3f49c14c: only the merge of main, which brought no new conflicts here because 561b65a8 is already in the head. In the two resolved files, TOTAL's + 15 does count the new case: if check.py's results.append for it is dropped, 13 tests in test_shader_checks fail. The design row carries the three edits and nothing else.
  • New test on the M4: run_gpu_tests.py --filter swap_x2 PASSes: both dword orders exact, 1,642 of 2,049 pairs torn.
    • swap_x2_contend.py --runs 200, run twice: both dword orders held in 200/200 dispatches each time. Torn pairs: 343,100 and 343,418 of 409,800 (83.7% and 83.8%).
    • Per dispatch, over 100 more dispatches: 1,436 to 2,039 torn, median 1,704. The final element itself was torn in 193 of 200 dispatches.
    • --strict --runs 5 exits 1 as intended (8,466 of 10,245 torn).
    • The two commands in docs/testing.md (build.py <out> cs_w32_swap_x2_contend, then the script) work as written. The .spv is byte-identical to the runner's.
  • MoltenVK: vulkaninfo on the M4 reports shaderBufferInt64Atomics = false and shaderSharedInt64Atomics = false. The fixture runs here only because of the two-32-bit-atomic lowering. So the 64-bit OpAtomicExchange path in the coordination finding would have to keep the current lowering as a fallback on Apple.
  • Full suite, PR runner and main runner on the same build (the runtime C++ is identical):
    • PR: 166/233 passed, 59 skipped. Main: 165/232 passed, 59 skipped.
    • Identical per test except the new PASS. The 8 FAILs are main's known ones on this machine.
    • check.py prints cs_w32_swap_x2_contend ok.
  • The check can fail on the GPU:
    • With check.py's expectation broken (SWAP_X2_FILL = 0xEEEEEEEF, or replacement low 0x52000000 | i), the M4 run FAILs with "1 never handed out, 1 handed out twice" and "2048 never handed out" respectively.
    • With the runner's branch renamed away, --filter swap_x2 stops with "no runnable GPU test cases", so the case can't silently drop out.
  • CPU mutations, caught: dropping the order walk, an off-by-one in it (check.py:710), dropping the multiset check, inverting the torn count or forcing it to 0, judging a fill pair instead of the final element, 32 groups, and a different replacement constant. All fail test_swap_x2_contend and/or test_shader_checks.
  • CPU mutations, survived (minor):
    • SWAP_X2_FILL changed (check.py:673). The CPU heaps are built from the same constant, so they stay consistent; the GPU run catches it (above).
    • The runner's verdict forced to True (scripts/run_gpu_tests.py:977, else True). No CPU test runs that branch. A fake-harness case in tests/test_run_gpu_tests.py, fed a heap with one doubled dword, would pin it.
  • CPU tests, OK on both Pythons: test_swap_x2_contend 14, test_shader_checks 82, test_run_gpu_tests 47, test_run_gpu_tests_paths 21, test_check_no_game_data 8, test_gpu_test_timeout 8, test_text_write_line_endings 3, test_design_contract_rows and the 11 test_docs_* files. compileall and git diff --check are clean.
  • docs/design.md: the row's claim (each half's exchange is atomic, the pairs tear) matches the M4 as well.
    • Non-blocking: row 265 still holds an older second copy of its own text, from \|\| M > DATA) ? DATA : M - 1`` onward. This was already on main. That copy says and/or/xor/swap_x2` work "as one 32-bit atomic per dword: a bitwise op or an exchange leaves the same memory that way". This PR's measurement refutes that for the exchange, yet the PR's second "GPU-verified … (the measurement above)" sits in that copy.
    • Fix: delete the stale copy, or at least drop "or an exchange" there. The M4 figure (83.7%/83.8%) could go into the Measured clause.

AI-assisted.

@lunarminus

Copy link
Copy Markdown

Tested 5f6d83a2 merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • 5f6d83a2 already contains main 561b65a8, so the merge onto d0835dd9 fast-forwarded to the PR head. Against 561b65a8 the PR changes only its 8 files and no runtime C++. I rebuilt the runtime from this tree (RelWithDebInfo, Makefiles).
  • scripts/run_gpu_tests.py: 239/239 translated, 239 pass spirv-val. 217/233 passed, 16 skipped, 0 failed, both natively and with LEONIDA_W64_EMULATE=1.
    • New line, the same in both modes: PASS cs_w32_swap_x2_contend both dword orders exact; 859 of 2049 pairs torn.
  • Per-test comparison, both modes, PASS/FAIL/SKIP and name of every result line:
    • Against main 561b65a8 without the PR (216/232, 16 skipped, same machine): the only difference is the new cs_w32_swap_x2_contend.
    • Against d0835dd9 (196/210, 14 skipped): no test present in both changed result. The 23 extra names are this fixture plus 22 fixtures main added after d0835dd9: 20 PASS, and ps_live_width and ps_m2_literal SKIP.
  • runtime/test/shaders/swap_x2_contend.py --runs 200: exit 0. 200 of 200 dispatches kept both dword orders, all 200 had torn pairs, 172,478 of 409,800 pairs torn.
  • --runs 5 --strict: exit 1 as intended. 5 of 5 kept both orders, 4,295 of 10,245 pairs torn.
  • CPU, python -I (CPython 3.14.10), all OK:
    • tests/test_swap_x2_contend.py (14), tests/test_shader_checks.py (82), test_run_gpu_tests.py (47), test_run_gpu_tests_paths.py (21), test_check_no_game_data.py (8), test_design_contract_rows.py (4) and 11 of 11 test_docs_*.
    • compileall is clean. The fixture builds with llvm-mc 23.1.5 (1 translated, 1 passes spirv-val).
  • The cyclic-order reproduction from the first review is now rejected for both halves ("reaches the fill after 2046 of 2048 writers"); the valid chain still returns ('', 0).
  • Not run: the load/store negative control and check.py on its own (the suite runs its new check).

AI-assisted (Claude Code).

@itsonlysimbo

Copy link
Copy Markdown
Contributor

Tested 5f6d83a2 on RTX 4070, NVIDIA 621.14, Windows 11 (10.0.26300), Vulkan SDK 1.4.363, llvm-mc 23.1.6, test programs from main 561b65a8: pass.

AI-assisted (Claude Code).

@bunbeans2-arch

Copy link
Copy Markdown

Tested the current head 5f6d83a on an AMD Radeon RX 9070 XT (RDNA4, subgroup 32..64) with AMD's Windows driver, Windows 11 23H2 (the AMD run here so far is RADV). scripts/run_gpu_tests.py --require-pass gives 217/233 passed, 16 skipped. cs_w32_swap_x2_contend passes: "both dword orders exact; 970 of 2049 pairs torn". The changed CPU tests (tests/test_shader_checks.py, tests/test_swap_x2_contend.py) give 100 passed, 287 subtests passed.

AI-assisted (Claude Code). No game files.

… pairs counted (TEST-561)

cs_w32_swap_x2_contend has every invocation of 64 workgroups of 32 swap
its own pair (high = ~low) into one shared 64-bit element and store the
pair glc returned. Whatever order they ran in, the returned low dwords
plus the element's final low dword must be the fill plus every
replacement low, each once, and the same for the high dwords: check.py
and run_gpu_tests.py dispatch it once and fail otherwise. A pair whose
halves don't belong together is a torn element, which the
one-atomic-per-dword translation allows; the PASS line counts them, and
swap_x2_contend.py adds the counts up over many dispatches (--strict
fails on them).

Measured over 200 dispatches per device: both dword sets exact every
time; 96.7% of the pairs torn on an RTX 5070 Ti Laptop GPU (621.24) and
1.0% on a Radeon 610M (AMD 26.11.2). docs/design.md's global atomics
row gets the measurement, docs/testing.md the commands.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Etr0p and others added 2 commits November 23, 2026 19:07
…e set

The checker compared the dwords of each half as a multiset, which also
accepts two invocations each holding the other's value: every dword
occurs once, but neither exchange can have come first (review on the
pull request). Going back from the element's final value, each writer's
returned dword now has to name the writer before it, through all 2,048
to the fill, for the low half and for the high half, whose orders may
differ. Two CPU tests for the reported case; the docs and the PASS line
say "orders". Both GPUs still pass 200 of 200 dispatches.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… status is

docs/testing.md said the PASS line names the torn pairs; only
scripts/run_gpu_tests.py prints the count, check.py prints "ok". The
global atomics row of docs/design.md still ended "Not GPU-verified"
after gaining the swap_x2 measurement: it now says which form is
GPU-verified and that the others are not (review on the pull request).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Etr0p
Etr0p force-pushed the test/swap-x2-contention branch from 5f6d83a to 7135817 Compare November 23, 2026 18:12
@Etr0p

Etr0p commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main dde82f2 (3 commits, the old merge commit dropped). Conflicts in docs/design.md (Global atomics row) and tests/test_shader_checks.py (fixture count, now +16, and the fake-harness branches for cs_fmt_all and cs_w32_swap_x2_contend), resolved by keeping both sides. tests/test_swap_x2_contend.py: 14 passed. tests/test_shader_checks.py: the same 15 failures as main dde82f2 alone (its fake harness does not take the cwd argument check.py now passes), nothing new. Docs table tests pass. cs_w32_swap_x2_contend through scripts/run_gpu_tests.py: PASS on an RTX 5070 Ti Laptop GPU (621.24, 1977 of 2049 pairs torn) and on a Radeon 610M (AMD 26.11.2, 21 of 2049). AI-assisted (Claude Code).

@TG0000

TG0000 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 7135817 on AMD Radeon RX 6800 (RDNA2 gfx1030, AMD 26.11.2, Windows 11): pass

Toolchain: llvm-mingw clang++ 20261117 (Vulkan test targets only, -DLEONIDA_BUILD_WINDOWS_RUNTIME=OFF), MSYS2 ucrt64 spirv-as/spirv-val/llvm-mc. Head trial-merged onto main @ dde82f27 (clean merge).

  • run_gpu_tests.py --filter swap_x2: 1/1 translated and spirv-val-valid; cs_w32_swap_x2_contend PASS, "both dword orders exact; 499 of 2049 pairs torn". On RDNA2 the one-atomic-per-dword translation does tear about a quarter of the pairs, as the PR expects.
  • Full run_gpu_tests.py: 224/242 passed, 17 skipped, 1 failed. Only failure in the full run is ms_wave_info_s3, which also fails intermittently on bare main on this RX 6800 (it passed in my baseline run of dde82f27: 224/241, 17 skipped, 0 failed), so it is unrelated to this PR.
  • pytest tests/test_swap_x2_contend.py tests/test_shader_checks.py: 97 passed, 15 failed. All 15 failures (Wave64Checks, TypeError: harness() got an unexpected keyword argument 'cwd') are the same ones I get on bare main @ dde82f27 (83 passed, 15 failed). This PR adds 14 passing tests and no new failures.

AI-assisted check (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.