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

Closed
opened 2026-11-26 20:17:45 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/345
Author: @milk4sale
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @aslan2142

Base: main ← Head: gpu-test/image-atomics


📝 Commits (1)

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

📊 Changes

3 files changed (+325 additions, -1 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 runtime/test/shaders/check.py (+11 -0)
➕ runtime/test/shaders/cs_imgatomic_ext.asm (+313 -0)

📄 Description

Claimed in the coordination issue as: GPU-IMG-ATOMIC-EXT (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7121047536)

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/345 **Author:** [@milk4sale](https://github.com/milk4sale) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `gpu-test/image-atomics` --- ### 📝 Commits (1) - [`367d91e`](https://github.com/ubiquitarianism/leonida/commit/367d91ef238b0cc9ae2a1afb1baa3a84f6389e0b) GPU fixture cs_imgatomic_ext: image_atomic_{swap,inc,dec,fmin,fmax,fcmpswap} (GPU-IMG-ATOMIC-EXT) ### 📊 Changes **3 files changed** (+325 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `runtime/test/shaders/check.py` (+11 -0) ➕ `runtime/test/shaders/cs_imgatomic_ext.asm` (+313 -0) </details> ### 📄 Description Claimed in the coordination issue as: GPU-IMG-ATOMIC-EXT (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7121047536) ### 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:45 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#397
No description provided.