tests: image atomics guard keeps a dynamic EXEC case #394

Manually merged
github merged 1 commit from gh-pr/394/head into gh-pr/394/base 2026-11-26 08:57:36 +00:00
Owner

@⁠Okamizs on GitHub · 2026-11-24 04:28 UTC · original
Okamizs:test-image-atomics-dynamic-exec → main · +41 −0 · 1 files · 1 commits · merged 2026-11-24 05:08 UTC

Claimed in the coordination issue as: TEST-ATOMIC-GUARD follow-up (finding comment in #14)

What and why

Before: since #20 (by @⁠wavehs), find_guarded_texel_block accepts the folded if (%true) guard when a shader never writes EXEC. Every case in test_image_atomics_guard.py leaves EXEC alone, so all 49 subtests take that path and the check that a lane switched off at run time skips the image atomic was never exercised.

After: a new test, test_dynamic_exec_keeps_the_real_active_guard, switches lanes off before the atomic with v_cmp_gt_u32 + s_and_saveexec_b32 and with v_cmpx_gt_u32, covering image_atomic_add, swap, inc and cmpswap on 2D and 3D images (16 subtests). Each case asserts the module stores to %active and the atomic's block is entered through a branch on the loaded %active, then swaps that condition for %true and asserts the helper rejects it.

Test only: one file, 41 lines added. No translator change, so no new rule for docs/design.md. Builds on #20 and does not change it. Stays off SHADER-1264: the EXEC writes here come from per-lane compares, not a computed SGPR value.

Tested

  • python -m pytest tests/semantic/test_image_atomics_guard.py: before 49 subtests passed, after 65.
  • Mutation check: forcing the helper's exec_is_constant_true to True makes the 16 new subtests fail while the old 49 still pass.
  • python -I scripts/run_semantic_tests.py tests/semantic -j 4: 6103 tests before, 6104 after. The same 2 files failed in both runs (see limitations).
  • python -m pytest tests/test_semantic_translator_use.py: 3 passed.

Ran on the CPU only, in a Linux container with Python 3.13.

GPUs tested: n/a

Known limitations

  • Unverified: spirv-as and spirv-val weren't installed locally, so test_sopc_validation and test_unary_f16_validation failed before and after, and the new cases weren't run through spirv-val. CI has SPIRV-Tools.
  • The test checks the emitted structure, not execution, because spirv_wave_interp.py doesn't model storage images yet.
  • Wave32 forms only; no wave64 variant.

AI-assisted: yes (Claude helped write the test and this description)

**@⁠Okamizs** on GitHub · 2026-11-24 04:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/394) `Okamizs:test-image-atomics-dynamic-exec` → `main` · +41 −0 · 1 files · 1 commits · merged 2026-11-24 05:08 UTC Claimed in the coordination issue as: TEST-ATOMIC-GUARD follow-up (finding comment in #14) ### What and why Before: since #20 (by @⁠wavehs), `find_guarded_texel_block` accepts the folded `if (%true)` guard when a shader never writes EXEC. Every case in `test_image_atomics_guard.py` leaves EXEC alone, so all 49 subtests take that path and the check that a lane switched off at run time skips the image atomic was never exercised. After: a new test, `test_dynamic_exec_keeps_the_real_active_guard`, switches lanes off before the atomic with `v_cmp_gt_u32` + `s_and_saveexec_b32` and with `v_cmpx_gt_u32`, covering `image_atomic_add`, `swap`, `inc` and `cmpswap` on 2D and 3D images (16 subtests). Each case asserts the module stores to `%active` and the atomic's block is entered through a branch on the loaded `%active`, then swaps that condition for `%true` and asserts the helper rejects it. Test only: one file, 41 lines added. No translator change, so no new rule for `docs/design.md`. Builds on #20 and does not change it. Stays off SHADER-1264: the EXEC writes here come from per-lane compares, not a computed SGPR value. ### Tested - `python -m pytest tests/semantic/test_image_atomics_guard.py`: before 49 subtests passed, after 65. - Mutation check: forcing the helper's `exec_is_constant_true` to `True` makes the 16 new subtests fail while the old 49 still pass. - `python -I scripts/run_semantic_tests.py tests/semantic -j 4`: 6103 tests before, 6104 after. The same 2 files failed in both runs (see limitations). - `python -m pytest tests/test_semantic_translator_use.py`: 3 passed. Ran on the CPU only, in a Linux container with Python 3.13. GPUs tested: n/a ### Known limitations - Unverified: `spirv-as` and `spirv-val` weren't installed locally, so `test_sopc_validation` and `test_unary_f16_validation` failed before and after, and the new cases weren't run through `spirv-val`. CI has SPIRV-Tools. - The test checks the emitted structure, not execution, because `spirv_wave_interp.py` doesn't model storage images yet. - Wave32 forms only; no wave64 variant. AI-assisted: yes (Claude helped write the test and this description)
Every case in test_image_atomics_guard.py leaves EXEC alone, so since #20
the helper takes the folded if (%true) path everywhere and the real %active
guard was never checked. Add cases that switch lanes off with
s_and_saveexec_b32 and v_cmpx before image_atomic_add/swap/inc/cmpswap on
2D and 3D images, and check the helper rejects %true there.

Follow-up to TEST-ATOMIC-GUARD (#14), building on #20 by wavehs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:57:34 +00:00
github manually merged commit b3eaa3d7b0 into gh-pr/394/base 2026-11-26 08:57:36 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.