[PR #59] GPU fixture for the packed integer dot products (cs_w32_dot_int) #112

Open
opened 2026-11-26 20:16:50 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/59
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9781


📝 Commits (3)

  • 2395050 GPU fixture for global_atomic_csub / buffer_atomic_csub, and a "; mcpu:" fixture header
  • 55f5f11 tests/conftest.py: assemble a fixture for its "; mcpu:" target too
  • d24ef75 GPU fixture for the packed integer dot products (cs_w32_dot_int)

📊 Changes

8 files changed (+274 additions, -28 deletions)

View changed files

📝 docs/design.md (+2 -2)
📝 runtime/test/shaders/build.py (+14 -3)
📝 runtime/test/shaders/check.py (+7 -2)
➕ runtime/test/shaders/cs_global_csub.asm (+138 -0)
➕ runtime/test/shaders/cs_w32_dot_int.asm (+62 -0)
📝 scripts/run_gpu_tests.py (+36 -14)
📝 tests/conftest.py (+11 -5)
📝 tests/test_rdna2_decode.py (+4 -2)

📄 Description

Carried over from old PR 9781 by Joaco9020 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9781, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
Joaco9020: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claim: https://github.com/ItsNotRexed/Leonida/issues/9522#issuecomment-7114878745 (new TEST item)

Re-submission of #9672, which was closed in the PR cleanup. It builds on #7237 by @xelerb-debug (also closed in the cleanup): that PR's two commits, the ; mcpu: fixture header and its cs_global_csub fixture, are included here unchanged and keep @xelerb-debug as their author; this PR's own change is the last commit. If #7237 is re-opened and merged first, this reduces to that last commit.

What and why

docs/design.md's "Packed integer dot products" row is CPU-checked (tests/semantic) and measured with tools/hw_oracle, but no checked-in fixture runs the translation of v_dot2_i32_i16, v_dot2_u32_u16, v_dot4_u32_u8, v_dot8_i32_i4 or v_dot8_u32_u4 on a GPU.

runtime/test/shaders/cs_w32_dot_int.asm is a wave32 dump like cs_w32_new_ops / cs_w32_dot2_f16: lane 0 stores eight words, each derived in the file header from the row's rule (element products + S2, sign- or zero-extended elements, 32-bit wrap; clamp saturates the exact sum):

out instruction operands value
0 v_dot2_i32_i16 0x0003fffe, 0x0005fff9, 100 (-2)(-7) + 3·5 + 100 = 129
1 v_dot2_u32_u16 0xffff8001, 0xffff0003, 0xffffff00 wraps once: 0xffff7f04
2 v_dot4_u32_u8 0x80ff0102, 0x7f02ff03, 5 17032
3 v_dot8_i32_i4 0x8f01f7a3, 0x12345678, -3 -38
4 v_dot8_u32_u4 same, 7 260
5 v_dot2_u32_u16 … clamp all 0xffffffff saturates: 0xffffffff
6 v_dot2_i32_i16 … clamp 0x80008000 twice, -2 2^31 - 2 = 0x7ffffffe: the products overflow, the sum does not, so no saturation
7 v_dot2_i32_i16 … clamp 0x80008000 twice, 0 saturates: 0x7fffffff

Out 1 and 3/4 use the same bits signed and unsigned, so a signedness mix-up changes a word; out 6 vs 7 checks that clamp saturates the exact sum, not a wrapped one.

Registered in check.py (WAVE32_DUMPS + expected words) and run_gpu_tests.py (the three wave32 lists). The design row gets one sentence. The VOP2 v_dot*c_* forms don't assemble with llvm-mc for gfx1013 or gfx1030, so they stay CPU-checked; the sentence says so.

Tested

Windows 11, NVIDIA GeForce RTX 3070 (Ampere), driver 621.01, MSVC 19.44 (VS 2022 Build Tools), Vulkan SDK 1.4.363.1, llvm-mc 23.1.6 (conda-forge, AMDGPU), Python 3.12.10, on this branch (rebased onto main 2d53a8055):

  • run_gpu_tests.py --filter cs_w32_dot: translated + spirv-val, PASS: 129 4294934276 17032 4294967258 260 4294967295 2147483646 2147483647, all eight as derived.
  • build.py + check.py: cs_w32_dot_int ok, cs_global_csub ok (#7237's fixture, still passing after the rebase).
  • tests/test_rdna2_decode.py with LLVM_MC set: the llvm-mc parity check passes on both new fixtures; it later fails on cs_w32_permlane_fi.asm and ps_w64_a_discard.asm, exactly as on main (#8044 covers the permlane one).
  • tests/test_run_gpu_tests.py, tests/test_runner_calls_all_tests.py, tests/test_rdna2_decode.py, tests/test_design_contract_rows.py, tests/test_docs_links.py, tests/test_docs_repo_paths.py: OK. tests/test_shader_checks.py has the same 15 failures with and without this change (the ones main already has, #7122).
  • scripts/check_no_game_data.py on the new fixture and docs/design.md: clean.

AMD: @ThomasSAMP ran it on an RX 9070 XT (RDNA4, Windows): the same eight words, plus a negative control (a zero-extended v_dot8_i32_i4 changes only out[3]); see the comments. An RDNA2 run is still open.

AI-assisted: yes (Claude).

🤖 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/59 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9781` --- ### 📝 Commits (3) - [`2395050`](https://github.com/ubiquitarianism/leonida/commit/2395050c14411e933d015f7dc1d075fb63f36aa3) GPU fixture for global_atomic_csub / buffer_atomic_csub, and a "; mcpu:" fixture header - [`55f5f11`](https://github.com/ubiquitarianism/leonida/commit/55f5f1171e73951b3e12541a34d0c1a100b01a72) tests/conftest.py: assemble a fixture for its "; mcpu:" target too - [`d24ef75`](https://github.com/ubiquitarianism/leonida/commit/d24ef75598fcc3e7b72ca65f0feb22fa3d2a828e) GPU fixture for the packed integer dot products (cs_w32_dot_int) ### 📊 Changes **8 files changed** (+274 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+2 -2) 📝 `runtime/test/shaders/build.py` (+14 -3) 📝 `runtime/test/shaders/check.py` (+7 -2) ➕ `runtime/test/shaders/cs_global_csub.asm` (+138 -0) ➕ `runtime/test/shaders/cs_w32_dot_int.asm` (+62 -0) 📝 `scripts/run_gpu_tests.py` (+36 -14) 📝 `tests/conftest.py` (+11 -5) 📝 `tests/test_rdna2_decode.py` (+4 -2) </details> ### 📄 Description > Carried over from **old PR 9781** by `Joaco9020` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9781`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `Joaco9020`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claim: https://github.com/ItsNotRexed/Leonida/issues/9522#issuecomment-7114878745 (new TEST item) Re-submission of `#9672`, which was closed in the PR cleanup. It builds on `#7237` by `@xelerb-debug` (also closed in the cleanup): that PR's two commits, the `; mcpu:` fixture header and its `cs_global_csub` fixture, are included here unchanged and keep `@xelerb-debug` as their author; this PR's own change is the last commit. If `#7237` is re-opened and merged first, this reduces to that last commit. ### What and why `docs/design.md`'s "Packed integer dot products" row is CPU-checked (`tests/semantic`) and measured with `tools/hw_oracle`, but no checked-in fixture runs the translation of `v_dot2_i32_i16`, `v_dot2_u32_u16`, `v_dot4_u32_u8`, `v_dot8_i32_i4` or `v_dot8_u32_u4` on a GPU. `runtime/test/shaders/cs_w32_dot_int.asm` is a wave32 dump like `cs_w32_new_ops` / `cs_w32_dot2_f16`: lane 0 stores eight words, each derived in the file header from the row's rule (element products + S2, sign- or zero-extended elements, 32-bit wrap; `clamp` saturates the exact sum): | out | instruction | operands | value | |---|---|---|---| | 0 | `v_dot2_i32_i16` | `0x0003fffe, 0x0005fff9, 100` | (-2)(-7) + 3·5 + 100 = 129 | | 1 | `v_dot2_u32_u16` | `0xffff8001, 0xffff0003, 0xffffff00` | wraps once: `0xffff7f04` | | 2 | `v_dot4_u32_u8` | `0x80ff0102, 0x7f02ff03, 5` | 17032 | | 3 | `v_dot8_i32_i4` | `0x8f01f7a3, 0x12345678, -3` | -38 | | 4 | `v_dot8_u32_u4` | same, `7` | 260 | | 5 | `v_dot2_u32_u16 … clamp` | all `0xffffffff` | saturates: `0xffffffff` | | 6 | `v_dot2_i32_i16 … clamp` | `0x80008000` twice, `-2` | 2^31 - 2 = `0x7ffffffe`: the products overflow, the sum does not, so no saturation | | 7 | `v_dot2_i32_i16 … clamp` | `0x80008000` twice, `0` | saturates: `0x7fffffff` | Out 1 and 3/4 use the same bits signed and unsigned, so a signedness mix-up changes a word; out 6 vs 7 checks that clamp saturates the exact sum, not a wrapped one. Registered in `check.py` (`WAVE32_DUMPS` + expected words) and `run_gpu_tests.py` (the three wave32 lists). The design row gets one sentence. The VOP2 `v_dot*c_*` forms don't assemble with llvm-mc for gfx1013 or gfx1030, so they stay CPU-checked; the sentence says so. ### Tested Windows 11, **NVIDIA GeForce RTX 3070** (Ampere), driver 621.01, MSVC 19.44 (VS 2022 Build Tools), Vulkan SDK 1.4.363.1, llvm-mc 23.1.6 (conda-forge, AMDGPU), Python 3.12.10, on this branch (rebased onto `main` `2d53a8055`): - `run_gpu_tests.py --filter cs_w32_dot`: translated + `spirv-val`, **PASS**: `129 4294934276 17032 4294967258 260 4294967295 2147483646 2147483647`, all eight as derived. - `build.py` + `check.py`: `cs_w32_dot_int ok`, `cs_global_csub ok` (`#7237`'s fixture, still passing after the rebase). - `tests/test_rdna2_decode.py` with `LLVM_MC` set: the llvm-mc parity check passes on both new fixtures; it later fails on `cs_w32_permlane_fi.asm` and `ps_w64_a_discard.asm`, exactly as on `main` (`#8044` covers the permlane one). - `tests/test_run_gpu_tests.py`, `tests/test_runner_calls_all_tests.py`, `tests/test_rdna2_decode.py`, `tests/test_design_contract_rows.py`, `tests/test_docs_links.py`, `tests/test_docs_repo_paths.py`: OK. `tests/test_shader_checks.py` has the same 15 failures with and without this change (the ones `main` already has, `#7122`). - `scripts/check_no_game_data.py` on the new fixture and `docs/design.md`: clean. AMD: `@ThomasSAMP` ran it on an RX 9070 XT (RDNA4, Windows): the same eight words, plus a negative control (a zero-extended `v_dot8_i32_i4` changes only out[3]); see the comments. An RDNA2 run is still open. AI-assisted: yes (Claude). 🤖 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>
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#112
No description provided.