GPU fixture cs_imgatomic_ext: image_atomic_{swap,inc,dec,fmin,fmax,fcmpswap} (GPU-IMG-ATOMIC-EXT) #345

Manually merged
github merged 1 commit from gh-pr/345/head into gh-pr/345/base 2026-11-26 08:54:28 +00:00
Owner

@⁠milk4sale on GitHub · 2026-11-24 03:39 UTC · original
milk4sale:gpu-test/image-atomics → main · +325 −1 · 3 files · 1 commits · merged 2026-11-24 16:16 UTC

Claimed in the coordination issue as: GPU-IMG-ATOMIC-EXT (#14)

What and why

The image_atomic_{swap,inc,dec,fmin,fmax,fcmpswap} row in docs/design.md was CPU-checked only (tests/semantic/test_image_atomics_32.py) and ended with "Not GPU-verified on RDNA2.". This adds the GPU fixture. It runs through vk_store_test ... words and check.py's STORE_WORDS, like cs_imgatomic and cs_imgatomic3d, so run_gpu_tests.py, check.py and test_shader_checks.py pick it up with no other change.

runtime/test/shaders/cs_imgatomic_ext.asm covers, on the 2D r32 uint image (binding 4) and the volume (binding 7):

  • swap with and without glc;
  • inc/dec on both sides of their wrap (M = D, M > D, M = 0), plus a D that is negative as a signed number (cases 19 and 20), so a signed compare shows;
  • fmin/fmax both ways and with a NaN in the data register;
  • fcmpswap with an equal and an unequal comparand, +0 against -0, and a NaN;
  • contention: inc, dec, fmin and fmax from all 64 threads on one texel each, which runs the translator's CAS loops under contention;
  • inactive lanes: every lane sets trap coordinates and data before v_cmpx, and the trap texels (uint 26, volume 62) must keep their fills.

The header lists every case and the word it leaves, derived from the RDNA2 ISA rules it quotes. The cases leave out what the ISA and SPIR-V leave open: no NaN or denormal texel for fmin/fmax/fcmpswap, and no +0 against -0 for fmin/fmax (NMin/NMax may return either, and native RDNA2 behaviour there is unmeasured). The row now says so.

Tested

On main ece4ba5b3 plus this commit, CachyOS (kernel 7.3.3), llvm-mc 23.1.4, SPIRV-Tools v2026.4, GCC 16.2.1, implicit Vulkan layers off:

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

Negative controls. In a throwaway worktree I planted five translator faults in emit_image_atomic_extra (tools/rdna2spirv.py), one at a time. Each fails the fixture on both GPUs in both modes:

Planted fault First failing word
signed instead of unsigned inc/dec compare uint 19: got 0, want 0x78
fmin and fmax exchanged uint 9
fcmpswap without the +0/-0 rule uint 17
no inactive-lane guard uint 26 (the trap): got 1, want 0x7e
swap ignoring glc sint 0

The first version of the fixture did not catch the missing guard on the Radeon. The inactive lanes landed on the fmin contention texel, and the lockstep order there ended on the right value. That is why the trap texel exists.

Other checks:

  • Full run_gpu_tests.py on both GPUs, native and emulated: 249 shaders. The only failures are cs_imgload_tfe and cs_imgload_d16_tfe, which are #31 and fixed by #98. cs_imgatomic and cs_imgatomic3d still pass.
  • Every standard-library tests/test_*.py: pass. The 30 pytest-based files were not run, since pytest is not installed here.
  • scripts/run_semantic_tests.py tests/semantic: 463 files, 6,075 tests, 0 failed.
  • ctest: 70/70, with 2 skipped as on main.
  • scripts/check_no_game_data.py on the fixture: clean.
  • Not run under the Khronos validation layer, which isn't installed here.

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. (No new rule: this GPU-confirms the existing row.)

🤖 Generated with Claude Code

**@⁠milk4sale** on GitHub · 2026-11-24 03:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/345) `milk4sale:gpu-test/image-atomics` → `main` · +325 −1 · 3 files · 1 commits · merged 2026-11-24 16:16 UTC Claimed in the coordination issue as: GPU-IMG-ATOMIC-EXT (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why The `image_atomic_{swap,inc,dec,fmin,fmax,fcmpswap}` row in `docs/design.md` was CPU-checked only (`tests/semantic/test_image_atomics_32.py`) and ended with "**Not GPU-verified on RDNA2.**". This adds the GPU fixture. It runs through `vk_store_test ... words` and `check.py`'s `STORE_WORDS`, like `cs_imgatomic` and `cs_imgatomic3d`, so `run_gpu_tests.py`, `check.py` and `test_shader_checks.py` pick it up with no other change. `runtime/test/shaders/cs_imgatomic_ext.asm` covers, on the 2D r32 uint image (binding 4) and the volume (binding 7): - **swap** with and without `glc`; - **inc/dec** on both sides of their wrap (M = D, M > D, M = 0), plus a D that is negative as a signed number (cases 19 and 20), so a signed compare shows; - **fmin/fmax** both ways and with a NaN in the data register; - **fcmpswap** with an equal and an unequal comparand, +0 against -0, and a NaN; - **contention**: inc, dec, fmin and fmax from all 64 threads on one texel each, which runs the translator's CAS loops under contention; - **inactive lanes**: every lane sets trap coordinates and data before `v_cmpx`, and the trap texels (uint 26, volume 62) must keep their fills. The header lists every case and the word it leaves, derived from the RDNA2 ISA rules it quotes. The cases leave out what the ISA and SPIR-V leave open: no NaN or denormal texel for fmin/fmax/fcmpswap, and no +0 against -0 for fmin/fmax (`NMin`/`NMax` may return either, and native RDNA2 behaviour there is unmeasured). The row now says so. ### Tested On `main` `ece4ba5b3` plus this commit, CachyOS (kernel 7.3.3), llvm-mc 23.1.4, SPIRV-Tools v2026.4, GCC 16.2.1, implicit Vulkan layers off: | GPU | Driver | native | `LEONIDA_W64_EMULATE=1` | |---|---|---|---| | Radeon 610M, Ryzen 9 7900X iGPU (gfx1036, RDNA2, subgroup 32..64) | RADV Mesa 26.2.6 | PASS, every word of all three images exact | PASS | | NVIDIA RTX 4070 Ti (Ada, subgroup 32) | 620.70.06 | PASS | PASS | **Negative controls.** In a throwaway worktree I planted five translator faults in `emit_image_atomic_extra` (`tools/rdna2spirv.py`), one at a time. Each fails the fixture on both GPUs in both modes: | Planted fault | First failing word | |---|---| | signed instead of unsigned inc/dec compare | uint 19: got 0, want 0x78 | | fmin and fmax exchanged | uint 9 | | fcmpswap without the +0/-0 rule | uint 17 | | no inactive-lane guard | uint 26 (the trap): got 1, want 0x7e | | swap ignoring `glc` | sint 0 | The first version of the fixture did not catch the missing guard on the Radeon. The inactive lanes landed on the fmin contention texel, and the lockstep order there ended on the right value. That is why the trap texel exists. Other checks: - Full `run_gpu_tests.py` on both GPUs, native and emulated: 249 shaders. The only failures are `cs_imgload_tfe` and `cs_imgload_d16_tfe`, which are #31 and fixed by #98. `cs_imgatomic` and `cs_imgatomic3d` still pass. - Every standard-library `tests/test_*.py`: pass. The 30 pytest-based files were not run, since pytest is not installed here. - `scripts/run_semantic_tests.py tests/semantic`: 463 files, 6,075 tests, 0 failed. - `ctest`: 70/70, with 2 skipped as on main. - `scripts/check_no_game_data.py` on the fixture: clean. - Not run under the Khronos validation layer, which isn't installed here. AI-assisted: yes (Claude Code) ### Checklist - [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`, with how it was confirmed. (No new rule: this GPU-confirms the existing row.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The row for the six remaining 32-bit MIMG image atomics was CPU-checked
only (tests/semantic/test_image_atomics_32.py) and said "Not GPU-verified
on RDNA2". This adds the GPU fixture, judged through vk_store_test's
"words" mode and check.py's STORE_WORDS like cs_imgatomic/cs_imgatomic3d:

- all six ops on the 2D r32 uint image (binding 4) and the volume
  (binding 7); inc/dec on both sides of their wrap and with a D that is
  negative as a signed number; fmin/fmax with a NaN data register;
  fcmpswap equal, unequal, +0 against -0 and NaN; glc and non-glc
- inc/dec/fmin/fmax from all 64 threads on one texel, which runs the
  translator's CAS loops under contention
- inactive lanes held on a trap texel that must keep its fill

The cases leave out what the ISA and SPIR-V leave open: NaN or denormal
texels for fmin/fmax/fcmpswap and +0 against -0 for fmin/fmax.

Exact on a Radeon 610M (gfx1036, RDNA2, RADV Mesa 26.2.6) and an RTX
4070 Ti (NVIDIA 620.70.06), native and LEONIDA_W64_EMULATE=1. Five
planted translator faults (signed inc/dec compare, fmin/fmax exchanged,
fcmpswap without the +0/-0 rule, no inactive-lane guard, no glc return
from swap) each fail it on both. docs/design.md records the GPU check.

AI-assisted. No game files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:54:26 +00:00
github manually merged commit 367d91ef23 into gh-pr/345/base 2026-11-26 08:54:28 +00:00
Author
Owner

@⁠Sangonapou on GitHub · 2026-11-24 05:05 UTC · original

Tested a31cb813 on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass

Runtime built at this head with scripts\build_runtime.ps1 (MSVC 19.51, VS Build Tools 2026); llvm-mc 23.1.6 (conda-forge), SPIRV-Tools 2026.4, Vulkan SDK 1.4.363.0. No game files.

  • run_gpu_tests.py --filter cs_imgatomic_ext --require-pass: PASS native and with LEONIDA_W64_EMULATE=1 ("all 64 words of the uint image, the sint image and the volume exact").
  • Full suite: 258 shaders, 258 translated, 258 pass spirv-val; native 198/249 passed, 49 skipped; emulated 230/249 passed, 17 skipped, i.e. main plus this fixture. The only failures, cs_imgload_tfe and cs_imgload_d16_tfe, fail identically on main ece4ba5b on this card (main: native 197/248, emulated 229/248), the same pair as #31 / #336.
**@⁠Sangonapou** on GitHub · 2026-11-24 05:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/345#issuecomment-7122622261) Tested a31cb813 on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass Runtime built at this head with `scripts\build_runtime.ps1` (MSVC 19.51, VS Build Tools 2026); `llvm-mc` 23.1.6 (conda-forge), SPIRV-Tools 2026.4, Vulkan SDK 1.4.363.0. No game files. - `run_gpu_tests.py --filter cs_imgatomic_ext --require-pass`: PASS native and with `LEONIDA_W64_EMULATE=1` ("all 64 words of the uint image, the sint image and the volume exact"). - Full suite: 258 shaders, 258 translated, 258 pass spirv-val; native 198/249 passed, 49 skipped; emulated 230/249 passed, 17 skipped, i.e. `main` plus this fixture. The only failures, `cs_imgload_tfe` and `cs_imgload_d16_tfe`, fail identically on `main` `ece4ba5b` on this card (main: native 197/248, emulated 229/248), the same pair as #31 / #336.
Author
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-24 07:42 UTC · original

Tested f5ef1e2d (cherry-picked onto main d42773d0) on an NVIDIA GeForce RTX 4080 (Ada, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Home (build 26300): pass.

Runtime built from main d42773d0 with scripts\build_runtime.ps1 (MSVC 14.44, VS 2022 Build Tools); this PR does not touch runtime/ C++. llvm-mc 21.1.8 (built by scripts\build_llvm_mc.ps1), SPIRV-Tools v2026.4, Vulkan SDK 1.4.363.0. No game files.

run_gpu_tests.py --filter cs_imgatomic --require-pass: 3/3 passed natively and 3/3 with LEONIDA_W64_EMULATE=1. cs_imgatomic_ext, cs_imgatomic and cs_imgatomic3d each report "all 64 words of the uint image, the sint image and the volume exact".

Not run: the negative controls and the full suite with this commit.

AI-assisted (Claude Code ran the tests and wrote this comment).

**@⁠quartz-heron-58** on GitHub · 2026-11-24 07:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/345#issuecomment-7125286155) Tested f5ef1e2d (cherry-picked onto main d42773d0) on an NVIDIA GeForce RTX 4080 (Ada, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Home (build 26300): pass. Runtime built from main d42773d0 with `scripts\build_runtime.ps1` (MSVC 14.44, VS 2022 Build Tools); this PR does not touch `runtime/` C++. llvm-mc 21.1.8 (built by `scripts\build_llvm_mc.ps1`), SPIRV-Tools v2026.4, Vulkan SDK 1.4.363.0. No game files. `run_gpu_tests.py --filter cs_imgatomic --require-pass`: 3/3 passed natively and 3/3 with `LEONIDA_W64_EMULATE=1`. `cs_imgatomic_ext`, `cs_imgatomic` and `cs_imgatomic3d` each report "all 64 words of the uint image, the sint image and the volume exact". Not run: the negative controls and the full suite with this commit. AI-assisted (Claude Code ran the tests and wrote this comment).
Author
Owner

@⁠trigger337 on GitHub · 2026-11-24 08:28 UTC · original

Tested f5ef1e2d on AMD Radeon RX 6900 XT (RADV NAVI21 / GFX1030, Mesa 26.2.5, Linux 7.3.1 CachyOS, Vulkan 1.4.328, subgroup 32..64): pass.

Discrete desktop RDNA2 verification:

  • python3 scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_imgatomic_ext --require-pass: PASS natively and with LEONIDA_W64_EMULATE=1 ("all 64 words of the uint image, the sint image and the volume exact").
  • python3 scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_imgatomic --require-pass: 3/3 passed natively and 3/3 under LEONIDA_W64_EMULATE=1 (cs_imgatomic, cs_imgatomic3d, cs_imgatomic_ext).
  • Full GPU suite:
    • Native: 231/249 passed, 16 skipped.
    • Emulated (LEONIDA_W64_EMULATE=1): 231/249 passed, 16 skipped.
    • The only failures (cs_imgload_tfe and cs_imgload_d16_tfe) fail identically on main on this GPU (#31).
  • Unit and semantic tests:
    • python3 -m unittest discover -s tests/semantic -p test_image_atomics_32.py: 3/3 passed.
    • python3 -I tests/test_shader_checks.py: 87/87 passed.
    • python3 -I tests/test_run_gpu_tests.py: 62/62 passed.
  • scripts/check_no_game_data.py: clean. No game files.

AI-assisted: yes
agent: yes

**@⁠trigger337** on GitHub · 2026-11-24 08:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/345#issuecomment-7126171862) Tested f5ef1e2d on AMD Radeon RX 6900 XT (RADV NAVI21 / GFX1030, Mesa 26.2.5, Linux 7.3.1 CachyOS, Vulkan 1.4.328, subgroup 32..64): pass. Discrete desktop RDNA2 verification: - `python3 scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_imgatomic_ext --require-pass`: PASS natively and with `LEONIDA_W64_EMULATE=1` ("all 64 words of the uint image, the sint image and the volume exact"). - `python3 scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_imgatomic --require-pass`: 3/3 passed natively and 3/3 under `LEONIDA_W64_EMULATE=1` (`cs_imgatomic`, `cs_imgatomic3d`, `cs_imgatomic_ext`). - Full GPU suite: - Native: 231/249 passed, 16 skipped. - Emulated (`LEONIDA_W64_EMULATE=1`): 231/249 passed, 16 skipped. - The only failures (`cs_imgload_tfe` and `cs_imgload_d16_tfe`) fail identically on `main` on this GPU (#31). - Unit and semantic tests: - `python3 -m unittest discover -s tests/semantic -p test_image_atomics_32.py`: 3/3 passed. - `python3 -I tests/test_shader_checks.py`: 87/87 passed. - `python3 -I tests/test_run_gpu_tests.py`: 62/62 passed. - `scripts/check_no_game_data.py`: clean. No game files. AI-assisted: yes agent: yes
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 16:15 UTC · original

Tested 367d91ef (merged locally onto main 0af7753c) on RDNA3 and on an RDNA2 iGPU: pass.

Setup:

  • AMD Radeon RX 7900 XTX (RDNA3, gfx1100)
  • Ryzen 9 7950X3D iGPU (RDNA2, gfx1036)
  • Mesa llvmpipe
  • RADV Mesa 26.3.1, Linux
  • Runtime built from main; this PR doesn't change any runtime/ C++. No game files.

Results:

  • run_gpu_tests.py --filter cs_imgatomic_ext --require-pass passed 3/3 native and 3/3 with LEONIDA_W64_EMULATE=1 on each GPU, and 1/1 on llvmpipe. Every run printed "all 64 words of the uint image, the sint image and the volume exact".
  • --filter imgatomic passed 4/4 on both GPUs (cs_imgatomic, cs_imgatomic3d, cs_imgatomic_ext, ps_imgatomic).

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

**@⁠aslan2142** on GitHub · 2026-11-24 16:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/345#issuecomment-7137380763) Tested 367d91ef (merged locally onto main 0af7753c) on RDNA3 and on an RDNA2 iGPU: pass. Setup: - AMD Radeon RX 7900 XTX (RDNA3, gfx1100) - Ryzen 9 7950X3D iGPU (RDNA2, gfx1036) - Mesa llvmpipe - RADV Mesa 26.3.1, Linux - Runtime built from main; this PR doesn't change any runtime/ C++. No game files. Results: - run_gpu_tests.py --filter cs_imgatomic_ext --require-pass passed 3/3 native and 3/3 with LEONIDA_W64_EMULATE=1 on each GPU, and 1/1 on llvmpipe. Every run printed "all 64 words of the uint image, the sint image and the volume exact". - --filter imgatomic passed 4/4 on both GPUs (cs_imgatomic, cs_imgatomic3d, cs_imgatomic_ext, ps_imgatomic). AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.