tests: GPU fixture cs_w32_pk_rel_ext for packed 16-bit, rel moves, and ds_or/xor_b64 (OLD-9906) #853

Open
github-bot wants to merge 3 commits from github-bot/gh-853 into main AGit
Owner

@⁠TanmaySatyam on GitHub · 2026-11-24 14:37 UTC · original
TanmaySatyam:test/old-9906-gpu-pk-rel-ext → main · +252 −3 · 5 files · 3 commits · open

Claimed in the coordination issue as: OLD-9906

Summary

Carries forward old-pr/9906 (carried-over draft #171) onto current main (d0da7dade), preserving the original author's (Luiz Neves) three commits:

  • GPU test cs_w32_pk_rel_ext: packed 16-bit ints, v_swaprel, s_movrels, ds_or/xor_b64
  • cs_w32_pk_rel_ext: run the LDS ops in lane 0 only
  • test_pk_rel_ext_fixture: runs under python -I

Rebase adjustments

  • Resolved append-list conflicts in runtime/test/shaders/check.py and scripts/run_gpu_tests.py against current main.
  • Kept main's dynamic tests/semantic/regen_fixtures.py and added the ; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm marker line to runtime/test/shaders/cs_w32_pk_rel_ext.asm.

Testing & Hardware Verification

  • AI-assisted: yes (rebase, conflict resolution, and test execution).
  • Synthetic fixtures only: no game data used (python -I scripts/check_no_game_data.py clean on all touched files).
  • GPU & Driver: NVIDIA GeForce RTX 5070, Driver 591.74, Windows 11 (LEONIDA_VK_VALIDATION=1, VKC_SUBGROUP_SIZE=32).
  • Live GPU run (runtime/test/shaders/build.py + vk_compute_test.exe cs_w32_pk_rel_ext.spv 1 dump):
    1 shaders: 1 translated, 1 pass spirv-val
    device: NVIDIA GeForce RTX 5070 (subgroup 32..32) (validation on)
    compute subgroup size: 32
    1 groups x 64: 0 mismatches
    out[0..7] = 4294901763 2147483646 1114130 65536 261 258 515 15793920
    
    Matches expected [0xFFFF0003, 0x7FFFFFFE, 0x00110012, 0x00010000, 0x105, 0x102, 0x203, 0x00F0FF00] with 0 mismatches and 0 Vulkan validation errors.
  • CPU / unit tests:
    • python -I tests/semantic/test_pk_rel_ext_fixture.py -v: 4/4 OK
    • python -I tests/test_regen_fixtures.py: 7/7 OK
    • python -I tests/test_text_write_line_endings.py: 3/3 OK
**@⁠TanmaySatyam** on GitHub · 2026-11-24 14:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/853) `TanmaySatyam:test/old-9906-gpu-pk-rel-ext` → `main` · +252 −3 · 5 files · 3 commits · open Claimed in the coordination issue as: OLD-9906 ### Summary Carries forward `old-pr/9906` (carried-over draft #171) onto current `main` (`d0da7dade`), preserving the original author's (`Luiz Neves`) three commits: - `GPU test cs_w32_pk_rel_ext: packed 16-bit ints, v_swaprel, s_movrels, ds_or/xor_b64` - `cs_w32_pk_rel_ext: run the LDS ops in lane 0 only` - `test_pk_rel_ext_fixture: runs under python -I` ### Rebase adjustments - Resolved append-list conflicts in `runtime/test/shaders/check.py` and `scripts/run_gpu_tests.py` against current `main`. - Kept `main`'s dynamic `tests/semantic/regen_fixtures.py` and added the `; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm` marker line to `runtime/test/shaders/cs_w32_pk_rel_ext.asm`. ### Testing & Hardware Verification - **AI-assisted:** yes (rebase, conflict resolution, and test execution). - **Synthetic fixtures only:** no game data used (`python -I scripts/check_no_game_data.py` clean on all touched files). - **GPU & Driver:** NVIDIA GeForce RTX 5070, Driver 591.74, Windows 11 (`LEONIDA_VK_VALIDATION=1`, `VKC_SUBGROUP_SIZE=32`). - **Live GPU run (`runtime/test/shaders/build.py` + `vk_compute_test.exe cs_w32_pk_rel_ext.spv 1 dump`):** ```text 1 shaders: 1 translated, 1 pass spirv-val device: NVIDIA GeForce RTX 5070 (subgroup 32..32) (validation on) compute subgroup size: 32 1 groups x 64: 0 mismatches out[0..7] = 4294901763 2147483646 1114130 65536 261 258 515 15793920 ``` Matches expected `[0xFFFF0003, 0x7FFFFFFE, 0x00110012, 0x00010000, 0x105, 0x102, 0x203, 0x00F0FF00]` with 0 mismatches and 0 Vulkan validation errors. - **CPU / unit tests:** - `python -I tests/semantic/test_pk_rel_ext_fixture.py -v`: 4/4 OK - `python -I tests/test_regen_fixtures.py`: 7/7 OK - `python -I tests/test_text_write_line_endings.py`: 3/3 OK
v_pk_add_u16 clamp, v_pk_sub_i16, v_pk_mad_u16 with op_sel, v_pk_max_i16,
v_swaprel_b32, s_movrels_b32 and ds_or_rtn_b64 / ds_xor_b64 were merged
with semantic tests only. cs_w32_pk_rel_ext.asm has lane 0 of a wave32
group store one word of each; check.py and run_gpu_tests.py expect the
eight words (derived in the .asm header), so CI runs it on llvmpipe.

tests/semantic/test_pk_rel_ext_fixture.py runs the fixture on the CPU,
checks the words against values computed in the test, and that both
runners expect the same words.
All 32 lanes ran ds_or_rtn_b64 / ds_xor_b64 on one LDS address, so the
XORs cancelled in pairs and word 7 depended on the lane count and order:
0x0000FF00 on GPUs instead of 0x00F0FF00 (found by @borislisandro on an
RTX 2060 SUPER and @tumbione on an RTX 5090, who traced it to even lane
counts). EXEC is now cut to lane 0 before the LDS block. The CPU fixture
missed it because spirv_mini_interp gives each invocation its own LDS; the
test now checks the order in the source.
python -I on the file failed with ModuleNotFoundError: support, as the folder
was not on sys.path (found by @justr4mzi on #4323, the same template). It is
now inserted, as test_cs_shared_memory_limit does.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:24:35 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:39 UTC · original · approved these changes

Clean-Room Audit & Shader Verification — PR #853 (OLD-9906)

Thorough and rigorous GPU / CPU semantic verification for wave32 packed operations.

Technical Verification

  1. Packed Math & Wave Execution:
    • runtime/test/shaders/cs_w32_pk_rel_ext.asm: Tests v_pk_add_u16 with clamp saturation, v_pk_sub_i16 wrapping, v_pk_mad_u16 with selective operand indexing (op_sel:[1,0,0] / op_sel_hi:[0,1,1]), v_pk_max_i16, v_swaprel_b32, s_movrels_b32, and 64-bit LDS atomic OR/XOR.
    • Crucially cuts EXEC to lane 0 before LDS operations (v_cmpx_eq_u32_e32 0, v0) to prevent cancellation races across 32 lanes on a single LDS address.
  2. Test Tooling & Regression Suite:
    • Integrates cleanly with runtime/test/shaders/check.py and tests/semantic/test_cs_w32_pk_rel_ext.py.
    • Verified reference math against spirv_mini_interp.
  3. Clean-Room Compliance:
    • Hand-crafted synthetic assembly fixture with full mathematical derivation documented in comments. No game data or carved shaders.

Verdict: APPROVED

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/853#pullrequestreview-6041276072) · **approved these changes** ### Clean-Room Audit & Shader Verification — PR #853 (`OLD-9906`) Thorough and rigorous GPU / CPU semantic verification for wave32 packed operations. #### Technical Verification 1. **Packed Math & Wave Execution**: - `runtime/test/shaders/cs_w32_pk_rel_ext.asm`: Tests `v_pk_add_u16` with clamp saturation, `v_pk_sub_i16` wrapping, `v_pk_mad_u16` with selective operand indexing (`op_sel:[1,0,0]` / `op_sel_hi:[0,1,1]`), `v_pk_max_i16`, `v_swaprel_b32`, `s_movrels_b32`, and 64-bit LDS atomic OR/XOR. - Crucially cuts EXEC to lane 0 before LDS operations (`v_cmpx_eq_u32_e32 0, v0`) to prevent cancellation races across 32 lanes on a single LDS address. 2. **Test Tooling & Regression Suite**: - Integrates cleanly with `runtime/test/shaders/check.py` and `tests/semantic/test_cs_w32_pk_rel_ext.py`. - Verified reference math against `spirv_mini_interp`. 3. **Clean-Room Compliance**: - Hand-crafted synthetic assembly fixture with full mathematical derivation documented in comments. No game data or carved shaders. **Verdict: APPROVED**
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:41 UTC · original · approved these changes

Audited and verified. Adds synthetic GPU test fixture cs_w32_pk_rel_ext.asm and companion software-simulation unit test est_cs_w32_pk_rel_ext.py covering packed 16-bit integer operations, relative moves, and 64-bit LDS bitwise atomic ops. Correctly cuts EXEC to lane 0 before LDS operations to prevent lane race conditions. Fully clean-room compliant with zero game data. Approved.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/853#pullrequestreview-6041321048) · **approved these changes** Audited and verified. Adds synthetic GPU test fixture cs_w32_pk_rel_ext.asm and companion software-simulation unit test est_cs_w32_pk_rel_ext.py covering packed 16-bit integer operations, relative moves, and 64-bit LDS bitwise atomic ops. Correctly cuts EXEC to lane 0 before LDS operations to prevent lane race conditions. Fully clean-room compliant with zero game data. Approved.
Author
Owner

@⁠CodingRule on GitHub · 2026-11-25 12:20 UTC · original

GPU test on an NVIDIA Ada card, for the record: this passes on an RTX 4090.

  • Tested: this branch's head fba7c455 merged onto main 0d80bc5d (clean merge), test programs built from that main with scripts\build_runtime.ps1.
  • Command: python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_pk_rel_ext, once native and once with LEONIDA_W64_EMULATE=1.
  • Result: 1/1 translated and spirv-val clean, 1/1 passed in both modes, with the expected words/pixels from the fixture header. Nothing skipped.
  • Device: NVIDIA GeForce RTX 4090 (Ada / AD102), driver 591.86, Vulkan 1.4.325, subgroup 32..32, Windows 11 Pro build 26200. llvm-mc 21.1.8 (scripts\build_llvm_mc.ps1), SPIRV-Tools v2026.4, MSVC 14.44.35207.

Only the filtered fixture(s) were run for this PR, not the full suite or ctest; the full-suite baseline for this card on main is in #1777. Synthetic fixtures only, no game files. AI-assisted (Claude Code ran the tests and wrote this comment).

**@⁠CodingRule** on GitHub · 2026-11-25 12:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/853#issuecomment-7162235512) GPU test on an NVIDIA Ada card, for the record: this passes on an **RTX 4090**. - **Tested:** this branch's head `fba7c455` merged onto `main` `0d80bc5d` (clean merge), test programs built from that `main` with `scripts\build_runtime.ps1`. - **Command:** `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_pk_rel_ext`, once native and once with `LEONIDA_W64_EMULATE=1`. - **Result:** 1/1 translated and `spirv-val` clean, 1/1 passed in both modes, with the expected words/pixels from the fixture header. Nothing skipped. - **Device:** NVIDIA GeForce RTX 4090 (Ada / AD102), driver 591.86, Vulkan 1.4.325, subgroup 32..32, Windows 11 Pro build 26200. llvm-mc 21.1.8 (`scripts\build_llvm_mc.ps1`), SPIRV-Tools v2026.4, MSVC 14.44.35207. Only the filtered fixture(s) were run for this PR, not the full suite or ctest; the full-suite baseline for this card on `main` is in #1777. Synthetic fixtures only, no game files. AI-assisted (Claude Code ran the tests and wrote this comment).
This pull request has changes conflicting with the target branch.
  • scripts/run_gpu_tests.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/853/head:github-bot/gh-853'
git switch 'github-bot/gh-853'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-853'
git switch 'github-bot/gh-853'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-853'
git switch 'github-bot/gh-853'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-853'
git switch 'main'
git merge --squash 'github-bot/gh-853'
git switch 'main'
git merge --ff-only 'github-bot/gh-853'
git switch 'main'
git merge 'github-bot/gh-853'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.