[PR #411] GPU fixtures for global_atomic_csub / buffer_atomic_csub (GPU-ATOMIC-CSUB) #461

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

📋 Pull Request Information

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

Base: main ← Head: gpu-test/atomic-csub


📝 Commits (6)

  • b80541e GPU fixture for global_atomic_csub / buffer_atomic_csub, and a "; mcpu:" fixture header
  • 40d7d76 tests/conftest.py: assemble a fixture for its "; mcpu:" target too
  • e811439 GPU fixture cs_w32_csub_ext: csub inactive lanes and buffer bounds (GPU-ATOMIC-CSUB)
  • 7c77cf4 Merge origin/main into gpu-test/atomic-csub
  • fd8a042 Merge main into gpu-test/atomic-csub
  • e95d2c1 Merge main into gpu-test/atomic-csub

📊 Changes

8 files changed (+354 additions, -30 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 runtime/test/shaders/build.py (+14 -3)
📝 runtime/test/shaders/check.py (+8 -3)
➕ runtime/test/shaders/cs_global_csub.asm (+138 -0)
➕ runtime/test/shaders/cs_w32_csub_ext.asm (+140 -0)
📝 scripts/run_gpu_tests.py (+38 -16)
📝 tests/conftest.py (+11 -5)
📝 tests/test_rdna2_decode.py (+4 -2)

📄 Description

GPU-ATOMIC-CSUB (claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7121459552)

What and why

The docs/design.md row "global_atomic_csub, buffer_atomic_csub (GFX10.3)" is CPU-checked only on main (tests/semantic/test_atomic_csub.py) and says that the translation is not GPU-verified.

Draft #59 (carried over, Unclaimed) already has a GPU fixture for it, runtime/test/shaders/cs_global_csub.asm, from old PR 7237 by xelerb-debug. This PR takes that part over on its own:

  • xelerb-debug's two commits, cherry-picked unchanged with their author: the cs_global_csub fixture and the ; mcpu: fixture header (build.py, run_gpu_tests.py, tests/test_rdna2_decode.py, tests/conftest.py). The fixture covers both forms:

    • DATA above, equal to and below M
    • 0xffffffff on 0x80000000
    • glc and no glc
    • 32 lanes on one dword
  • One new commit adds runtime/test/shaders/cs_w32_csub_ext.asm, a wave32 fixture for what that file leaves out:

    • Inactive lanes: for each form, the 16 even lanes work on one dword while the odd lanes are inactive and aimed at a trap word. Both trap words stay unchanged, the inactive lanes keep vdst/vdata, and the active lanes get their old values. Each lane ORs 1 << lane into a word, which gives the exact mask. A lane mask copied into a VGPR would read only that lane's bit in the translator (the "Whole-wave masks" row).
    • Buffer bounds: buffer_atomic_csub goes through a V# with num_records 8. Offset 4 is in range. Offsets 8 (glc) and 12 (no glc) are out of range: memory is untouched, and vdata is 0 with glc and kept without.

    Every expected word is derived in the file header from three docs/design.md rows:

    • the csub row
    • "Atomic natural alignment": a dropped glc lane gets 0, and an inactive lane keeps its register
    • "Buffer bounds checking"

    It is registered in check.py and run_gpu_tests.py the way cs_w32_fcmpswap is. It is also in WAVE32_LANE_DUMPS, because its masks cover 32 lanes.

  • The csub row now names both fixtures, the GPUs, and the faults each fixture catches.

#59 would then reduce to its cs_w32_dot_int commit, on top of this one.

out cs_w32_csub_ext value
0 lanes whose global vdst kept its preset 0xaaaaaaaa
1 global dword after (100 - 16) | trap word << 16 0x77770054
2 sum of global old values (100..85) | sum of buffer old values (50, 48, ..., 20) << 16 0x023005c8
3 lanes whose buffer vdata kept its preset 0xaaaaaaaa
4 buffer dword after (50 - 32) | trap word << 16 0x55550012
5 in range, glc: old 30 | M after (25) << 16 0x0019001e
6 past the range, glc: vdata 0 | M kept (0x99) << 16 0x00990000
7 past the range, no glc: vdata kept (3) | M kept (0xab) << 16 0x00ab0003

Depends on: none.

Tested

CachyOS (Linux 7.3.3) on this branch (main ece4ba5b3 plus 3 commits), with llvm-mc 23.1.4 and the runtime/build test programs, whose sources are the same as this branch's. The device was picked with VK_DRIVER_FILES. Both fixtures were run with run_gpu_tests.py --filter csub and with build.py + check.py:

GPU driver native LEONIDA_W64_EMULATE=1
NVIDIA GeForce RTX 4070 Ti 620.70.06 both PASS both PASS
AMD Radeon 610M (Ryzen 9 7900X iGPU, gfx1036, RDNA2) RADV, Mesa 26.2.6 both PASS both PASS

I planted translator faults one at a time and reverted each. The results are the same on both GPUs:

fault cs_global_csub cs_w32_csub_ext
plain subtract, no clamp FAIL pass
signed compare FAIL pass
no glc return FAIL FAIL
EXEC ignored FAIL FAIL
V# bounds ignored (buffer form) pass FAIL
a dropped glc lane gets its DATA, not 0 pass FAIL

Other checks:

  • python -m unittest discover -s tests/semantic -p test_atomic_csub.py: OK.
  • These pass with python -I: test_run_gpu_tests, test_runner_calls_all_tests, test_design_contract_rows, test_docs_links, test_docs_repo_paths, test_text_write_line_endings and test_shader_checks.
  • tests/test_rdna2_decode.py with LLVM_MC set: both csub fixtures pass the llvm-mc parity check. The test then fails on cs_w32_permlane_fi.asm, as it does on main.
  • Not run: the pytest-based tests, which are what the conftest.py change serves. pytest isn't installed here.
  • scripts/check_no_game_data.py on the changed files: clean.

AI-assisted: yes (Claude Code).

🤖 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/411 **Author:** [@milk4sale](https://github.com/milk4sale) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `gpu-test/atomic-csub` --- ### 📝 Commits (6) - [`b80541e`](https://github.com/ubiquitarianism/leonida/commit/b80541e8127b2aeaf62534fd8cc044d3e1a31a7b) GPU fixture for global_atomic_csub / buffer_atomic_csub, and a "; mcpu:" fixture header - [`40d7d76`](https://github.com/ubiquitarianism/leonida/commit/40d7d766df397cf5b57ab8c41baf753c50cee570) tests/conftest.py: assemble a fixture for its "; mcpu:" target too - [`e811439`](https://github.com/ubiquitarianism/leonida/commit/e81143926ac6cc1e9f7699c87418eb620641ff5d) GPU fixture cs_w32_csub_ext: csub inactive lanes and buffer bounds (GPU-ATOMIC-CSUB) - [`7c77cf4`](https://github.com/ubiquitarianism/leonida/commit/7c77cf4d9b6e468f557baf68f30fee3e3606f120) Merge origin/main into gpu-test/atomic-csub - [`fd8a042`](https://github.com/ubiquitarianism/leonida/commit/fd8a042c93fab512601b478805d14769b19babfb) Merge main into gpu-test/atomic-csub - [`e95d2c1`](https://github.com/ubiquitarianism/leonida/commit/e95d2c16baebb007b8129d5c53d8bc70b60aa6bc) Merge main into gpu-test/atomic-csub ### 📊 Changes **8 files changed** (+354 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `runtime/test/shaders/build.py` (+14 -3) 📝 `runtime/test/shaders/check.py` (+8 -3) ➕ `runtime/test/shaders/cs_global_csub.asm` (+138 -0) ➕ `runtime/test/shaders/cs_w32_csub_ext.asm` (+140 -0) 📝 `scripts/run_gpu_tests.py` (+38 -16) 📝 `tests/conftest.py` (+11 -5) 📝 `tests/test_rdna2_decode.py` (+4 -2) </details> ### 📄 Description **GPU-ATOMIC-CSUB** (claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7121459552) ### What and why The `docs/design.md` row "`global_atomic_csub`, `buffer_atomic_csub` (GFX10.3)" is CPU-checked only on `main` (`tests/semantic/test_atomic_csub.py`) and says that the translation is not GPU-verified. Draft #59 (carried over, Unclaimed) already has a GPU fixture for it, `runtime/test/shaders/cs_global_csub.asm`, from old PR 7237 by `xelerb-debug`. This PR takes that part over on its own: - **`xelerb-debug`'s two commits**, cherry-picked unchanged with their author: the `cs_global_csub` fixture and the `; mcpu:` fixture header (`build.py`, `run_gpu_tests.py`, `tests/test_rdna2_decode.py`, `tests/conftest.py`). The fixture covers both forms: - `DATA` above, equal to and below `M` - `0xffffffff` on `0x80000000` - `glc` and no `glc` - 32 lanes on one dword - **One new commit** adds `runtime/test/shaders/cs_w32_csub_ext.asm`, a wave32 fixture for what that file leaves out: - **Inactive lanes:** for each form, the 16 even lanes work on one dword while the odd lanes are inactive and aimed at a trap word. Both trap words stay unchanged, the inactive lanes keep `vdst`/`vdata`, and the active lanes get their old values. Each lane ORs `1 << lane` into a word, which gives the exact mask. A lane mask copied into a VGPR would read only that lane's bit in the translator (the "Whole-wave masks" row). - **Buffer bounds:** `buffer_atomic_csub` goes through a V# with `num_records` 8. Offset 4 is in range. Offsets 8 (`glc`) and 12 (no `glc`) are out of range: memory is untouched, and `vdata` is 0 with `glc` and kept without. Every expected word is derived in the file header from three `docs/design.md` rows: - the csub row - "Atomic natural alignment": a dropped `glc` lane gets 0, and an inactive lane keeps its register - "Buffer bounds checking" It is registered in `check.py` and `run_gpu_tests.py` the way `cs_w32_fcmpswap` is. It is also in `WAVE32_LANE_DUMPS`, because its masks cover 32 lanes. - The csub row now names both fixtures, the GPUs, and the faults each fixture catches. #59 would then reduce to its `cs_w32_dot_int` commit, on top of this one. | out | `cs_w32_csub_ext` | value | |---|---|---| | 0 | lanes whose global `vdst` kept its preset | `0xaaaaaaaa` | | 1 | global dword after (100 - 16) \| trap word << 16 | `0x77770054` | | 2 | sum of global old values (100..85) \| sum of buffer old values (50, 48, ..., 20) << 16 | `0x023005c8` | | 3 | lanes whose buffer `vdata` kept its preset | `0xaaaaaaaa` | | 4 | buffer dword after (50 - 32) \| trap word << 16 | `0x55550012` | | 5 | in range, `glc`: old 30 \| `M` after (25) << 16 | `0x0019001e` | | 6 | past the range, `glc`: `vdata` 0 \| `M` kept (0x99) << 16 | `0x00990000` | | 7 | past the range, no `glc`: `vdata` kept (3) \| `M` kept (0xab) << 16 | `0x00ab0003` | Depends on: none. ### Tested CachyOS (Linux 7.3.3) on this branch (`main` `ece4ba5b3` plus 3 commits), with llvm-mc 23.1.4 and the `runtime/build` test programs, whose sources are the same as this branch's. The device was picked with `VK_DRIVER_FILES`. Both fixtures were run with `run_gpu_tests.py --filter csub` and with `build.py` + `check.py`: | GPU | driver | native | `LEONIDA_W64_EMULATE=1` | |---|---|---|---| | NVIDIA GeForce RTX 4070 Ti | 620.70.06 | both PASS | both PASS | | AMD Radeon 610M (Ryzen 9 7900X iGPU, gfx1036, RDNA2) | RADV, Mesa 26.2.6 | both PASS | both PASS | I planted translator faults one at a time and reverted each. The results are the same on both GPUs: | fault | `cs_global_csub` | `cs_w32_csub_ext` | |---|---|---| | plain subtract, no clamp | FAIL | pass | | signed compare | FAIL | pass | | no `glc` return | FAIL | FAIL | | EXEC ignored | FAIL | FAIL | | V# bounds ignored (buffer form) | pass | FAIL | | a dropped `glc` lane gets its `DATA`, not 0 | pass | FAIL | Other checks: - `python -m unittest discover -s tests/semantic -p test_atomic_csub.py`: OK. - These pass with `python -I`: `test_run_gpu_tests`, `test_runner_calls_all_tests`, `test_design_contract_rows`, `test_docs_links`, `test_docs_repo_paths`, `test_text_write_line_endings` and `test_shader_checks`. - `tests/test_rdna2_decode.py` with `LLVM_MC` set: both csub fixtures pass the llvm-mc parity check. The test then fails on `cs_w32_permlane_fi.asm`, as it does on `main`. - Not run: the pytest-based tests, which are what the `conftest.py` change serves. pytest isn't installed here. - `scripts/check_no_game_data.py` on the changed files: clean. AI-assisted: yes (Claude Code). 🤖 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#461
No description provided.