Skip to content

docs/design.md: name the GPU fixtures of six atomics rows (DOC-GPU-VERIFIED-ATOMICS) - #413

Merged
ubiquitarianism merged 3 commits into
ProjectLeonida:mainfrom
milk4sale:docs/gpu-verified-atomics
Nov 25, 2026
Merged

ubiquitarianism merged 3 commits into
ProjectLeonida:mainfrom
milk4sale:docs/gpu-verified-atomics

Conversation

@milk4sale

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: DOC-GPU-VERIFIED-ATOMICS (#14 (comment))

Depends on: #186, #65 - conflicts only; nothing here builds on them. #186 edits the ds_wrxchg_rtn_b64 row, which sits between two rows changed here, and #65 inserts its Flat memory row right after the 8/16-bit global row. Both resolve by keeping both sides.

What and why

Six contract rows in docs/design.md ended with "Not GPU-verified.", but GPU fixtures on main already run them through scripts/run_gpu_tests.py and runtime/test/shaders/check.py, and no row named its fixture. Each row now names its fixture, says which forms and cases it compares and on which GPUs it passed, and keeps a Not GPU-verified: list of what is still unchecked. Docs only: six lines of one file.

Row Fixture Compared Still not GPU-verified
8/16-bit global stores and d16 loads cs_global_mem_ext global_store_short at byte 3 (both dwords), global_load_sbyte_d16_hi the other eight ops, an inactive lane
ds_cmpst_f32, global_/buffer_atomic_fcmpswap cs_w32_fcmpswap ds_cmpst_rtn_f32 −0/+0 match and NaN no-match, ds_cmpst_f32 no-match, buffer_atomic_fcmpswap −0/+0 match with glc and a one-ulp no-match without global_atomic_fcmpswap, the ds_cmpst_f32 match, a NaN in the buffer form, bounds, inactive lanes, contention
ds_mskor_b32/_rtn_b32 cs_lds_atomics_ext both forms, a DATA2 bit outside DATA, the returned word offset:, the 32-lane case
ds_{inc,dec,rsub}_u32, ds_{min,max}_f32 cs_lds_atomics_ext, cs_lds_xchg64_ext ds_inc_rtn_u32 wrap, ds_dec_u32 from 0, ds_rsub_u32 wrap (low byte of each), ds_min_f32 with a qNaN, ds_max_rtn_f32 −0/+0 (as an XOR) five other forms, the non-wrapping cases, offset:, inactive lanes, contention
ds_wrxchg2_rtn_b32 cs_w32_new_ops the first returned word, data1 in LDS the second returned word, data0, st64, one dword twice, aliasing
ds_and/or/xor_b64 cs_lds_atomics_ext, cs_lds_xchg64_ext ds_xor_rtn_b64, ds_and_b64, ds_or_rtn_b64 (the element only) ds_and_rtn_b64, ds_or_b64, ds_xor_b64, offset:, aliasing, contention

The coverage comes from the fixture bodies, not only their headers. Three things the headers don't say:

  • cs_w32_new_ops overwrites the second VGPR of ds_wrxchg2_rtn_b32's vdst with a read before storing it.
  • cs_w32_fcmpswap's NaN buffer_atomic_fcmpswap case stores only the returned word, which is the NaN whether or not it matched.
  • cs_lds_xchg64_ext never stores ds_or_rtn_b64's returned pair, and judges ds_max_rtn_f32 as the word left XOR the returned word.

Row 279 also gets back the opening ** of "Hardware-measured natively on gfx1100", lost in 6b5fc7f, so GitHub no longer prints a stray ** there. That row had two "Not GPU-verified" clauses (a later merge added the second); the first goes.

Left out or affected:

Tested

On main ece4ba5b3 plus this commit (since rebased on d2cd6c0d9, whose ten new commits change only runtime C++ tests, not the translator, the fixtures or docs/design.md), CachyOS (kernel 7.3.3), llvm-mc 23.1.4, SPIRV-Tools v2026.4, GCC 16.2.1, implicit Vulkan layers off (VK_LOADER_LAYERS_DISABLE=~implicit~). scripts/run_gpu_tests.py --filter <fixture> for each of the five fixtures, with LEONIDA_VK_DEVICE choosing the GPU (checked against vk_compute_test's device: line):

GPU Driver native LEONIDA_W64_EMULATE=1
Radeon 610M, Ryzen 9 7900X iGPU (gfx1036, RDNA2, subgroup 32..64) RADV Mesa 26.2.6 5/5 PASS, every word exact 5/5 PASS
NVIDIA RTX 4070 Ti (Ada, subgroup 32) 620.70.06 5/5 PASS 5/5 PASS

With LEONIDA_W64_EMULATE=1 the translator writes byte-identical SPIR-V for all five (one active lane, no cross-lane operation), so the emulated runs repeat the native test. That is why the rows name only the GPUs.

Also: tests/test_docs_links.py, tests/test_docs_design_rows.py and tests/test_design_contract_rows.py pass; scripts/check_no_game_data.py docs/design.md is clean. The translator suite and ctest were not run, since no code changed.

GPUs tested: AMD Radeon 610M (gfx1036), RADV Mesa 26.2.6, CachyOS Linux; NVIDIA GeForce RTX 4070 Ti, 620.70.06, CachyOS Linux.

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • 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, with how it was confirmed. (No new rule: this names existing fixtures.)

🤖 Generated with Claude Code

…RIFIED-ATOMICS)

Six contract rows ended with "Not GPU-verified" although fixtures on main
already run them through scripts/run_gpu_tests.py and check.py:
cs_lds_atomics_ext, cs_lds_xchg64_ext, cs_global_mem_ext, cs_w32_fcmpswap
and cs_w32_new_ops. Each row now names its fixture, the forms and cases it
compares, the GPUs it passed on (Radeon 610M, RADV Mesa 26.2.6; RTX 4070 Ti,
620.70.06), and what stays unchecked.

Rows: 8/16-bit global stores and d16 loads, ds_cmpst_f32 / fcmpswap,
ds_mskor, ds_{inc,dec,rsub}_u32 / ds_{min,max}_f32, ds_wrxchg2_rtn_b32,
ds_and/or/xor_b64. Row 279 also gets back the opening ** of its
"Hardware-measured natively on gfx1100" note.

Left out: Global atomics (32-bit) and buffer_atomic_{and,or,xor,swap}_x2,
which open pull requests ProjectLeonida#191 and ProjectLeonida#174 rewrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
… six atomics rows (DOC-GPU-VERIFIED-ATOMICS)
demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
… page with ProjectLeonida#522's ds_mskor row

The keep-both resolution of ProjectLeonida#522's conflict also restored main's copies of the ds_{inc,dec,rsub}, ds_wrxchg2 and ds_mskor rows that ProjectLeonida#413 had edited (test_design_contract_rows, test_docs_design_rows). The page is now the one before the merge with ProjectLeonida#522's ds_mskor row in place, which keeps ProjectLeonida#413's GPU-fixture note, marked as measured on the earlier two-atomic emission.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milk4sale
milk4sale force-pushed the docs/gpu-verified-atomics branch from 61d11f4 to cf3951e Compare November 24, 2026 15:00
@PierreEbele

Copy link
Copy Markdown
Contributor

Reviewed cf3951e: docs-only; all five cited fixtures exist on main and match run_gpu_tests.py/check.py, and five of the six rows are accurate. One fix: the buffer_atomic_fcmpswap NaN clause describes the pre-a672a598 fixture (which the 84347bbb6 610M/4070 Ti runs executed), whereas cs_w32_fcmpswap.asm on cf3951e and main now reads back byte 0x48 into v6 (buffer_load_dword v6, overwriting the glc return) so out[7] = 0x7FC00000 verifies the word stays NaN rather than returning it. Please update that clause to match the current fixture — and if moving "whether a NaN matches in buffer_atomic_fcmpswap" out of Not GPU-verified, either rerun cs_w32_fcmpswap on those GPUs or cite post-a672a598 runs on main (GraniteRidge-9950X3D/RTX4080/RTX3060Ti). Sandbox: all six rows' semantic tests plus test_fcmpswap_fixture.py pass on both trees (2 spirv-val skips); check_no_game_data.py clean. AI-assisted review.

…(DOC-GPU-VERIFIED-ATOMICS)

Since a672a59, cs_w32_fcmpswap reads the word at byte 0x48 back after
buffer_atomic_fcmpswap, so out[7] checks that a NaN in memory and as CMP
leaves the NaN in memory (no match). It no longer checks the glc return.
The row described the older fixture.

Rerun at main 6261ca9 on the RTX 4070 Ti (NVIDIA 620.70.06), native and
with LEONIDA_W64_EMULATE=1: PASS, all eight words exact. The NaN
post-state is credited to the 4070 Ti only. "Whether a NaN matches"
leaves the Not GPU-verified list, and the value returned for a NaN joins
it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@milk4sale

Copy link
Copy Markdown
Contributor Author

@PierreEbele Thanks, you're right. My runs on the 610M and the 4070 Ti were at 84347bbb6, before a672a598, so out[7] was still the glc return, and the clause described that older fixture.

Fixed in 457bad1, a follow-up on top of cf3951e. The clause now matches the current fixture: with a NaN in memory and as CMP, buffer_atomic_fcmpswap leaves the NaN in memory. That case is credited to the RTX 4070 Ti only. "Whether a NaN matches" leaves the Not GPU-verified list, and the value returned for a NaN joins it, since the read-back now overwrites that return.

Rerun of cs_w32_fcmpswap at main 6261ca916 (which has a672a598):

  • GPU: RTX 4070 Ti, NVIDIA 620.70.06, CachyOS
  • Setup: implicit layers off, LEONIDA_VK_DEVICE=4070, matched against vk_compute_test's device: line
scripts/run_gpu_tests.py --filter cs_w32_fcmpswap
native PASS, 0 1065353216 2143289344 1065353216 2147483648 1077936128 1065353216 2143289344
LEONIDA_W64_EMULATE=1 PASS, the same words (the SPIR-V is byte-identical to native)

out[7] = 0x7FC00000: DATA (1.0) was not stored. I didn't rerun the 610M, so the row names only the 4070 Ti for this case. The other five rows are unchanged. tests/test_docs_links.py, tests/test_docs_design_rows.py and tests/test_design_contract_rows.py pass, and scripts/check_no_game_data.py docs/design.md is clean.

AI-assisted (Claude Code).

Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@PierreEbele

Copy link
Copy Markdown
Contributor

Rechecked 457bad1: the buffer_atomic_fcmpswap NaN clause in docs/design.md now matches the fixture as it is on main (runtime/test/shaders/cs_w32_fcmpswap.asm:11-12: out[7] is the memory word read back after the atomic, expected 0x7FC00000, so DATA is not stored), and moving the returned-value case to Not GPU-verified fits since the read-back overwrites that return. My earlier finding is resolved. In a sandbox on this head: tests/test_docs_links.py, tests/test_docs_design_rows.py and tests/test_design_contract_rows.py pass, scripts/check_no_game_data.py docs/design.md is clean, and git merge-tree into current main is clean. No GPU here, so the 4070 Ti words are taken from your run. AI-assisted review.

Recommendation: Merge

@ubiquitarianism
ubiquitarianism merged commit c266c26 into ProjectLeonida:main Nov 25, 2026
2 checks passed
aslan2142 added a commit to Rain156/leonida-contrib that referenced this pull request Nov 25, 2026
Fourteen commits main gained after ProjectLeonida#968: ProjectLeonida#413, ProjectLeonida#1114, ProjectLeonida#1090 and ProjectLeonida#1491. Two conflicts, both in the shader check lists: scripts/run_gpu_tests.py imports both sides' cases, and tests/test_shader_checks.py counts eight cases next to COMPUTE (main's cs_w32_salu_ext) and ProjectLeonida#939's IMAGE_STORE_CASES table in place of main's fixed seven store shaders.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@milk4sale

Copy link
Copy Markdown
Contributor Author

Local stand-in for this pull request's CI, which has been queued here since 22:31 UTC (about 580 runs waiting).

Tested: 4581d0ad3 merged with main b4b7756e8 (2026-11-25 01:13 UTC), in one tree together with #1087, #1089, #1090, #1114, next to main alone. The trees came from git merge-tree, and nothing was pushed. Each job used the workflow's own selection from ci.yml and runtime.yml.

Job main + the five pull requests main alone
check steps: compileall, make_game.py --help pass pass
stdlib-tests-linux (every standalone file, run to the end) 492 of 492 pass 491 of 491 pass
translator-tests (pytest files) 1,890 pass, 2 fail 1,886 pass, the same 2 fail
viewer-tests pass pass
semantic-tests 477 files, 6,231 tests, 0 failed
linux-gpu-tools: ctest 76 of 76 pass
linux-gpu-tools: run_gpu_tests.py, plain, LEONIDA_W64_EMULATE=1 --filter cs_, LEONIDA_BARY_FALLBACK=1 0 failures on lavapipe, 0 on the RTX 4070 Ti
no-game-data: scripts/check_no_game_data.py on this pull request's files clean

Docs only: the tests/test_docs_*.py loop and the design.md row tests pass.

The two pytest failures are main's: tests/test_translate.py on the text-only fixture cs_dpp_cmp.asm (test_gpu_samples_translate_and_validate, test_wave64_emulate_uses_no_subgroup_ops). With #1375 applied, both pass.

Not covered: the Windows and macOS jobs.

Setup: Linux (CachyOS), Python 3.14.10 (CI uses 3.12), llvm-mc 23.1.4 (CI uses 19), Node 26.13.1. GPU suite on lavapipe from Mesa 26.2.6 with GALLIUM_OVERRIDE_CPU_CAPS=avx, the code path of CI's runners, which lack AVX-512; and on an RTX 4070 Ti, NVIDIA 620.70.06.

AI-assisted (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.

3 participants