Tests: GPU coverage for v_add/sub_nc_i16, 16-bit min3/max3/med3 and v_pk_add_u16/v_pk_mad_i16 #134

Closed
Andretuta wants to merge 1 commit from upstream-pr/134 into main
Andretuta commented 2026-11-24 02:25:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:25:24Z.


Carried over from old PR 9864 by KoLolX3 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9864, 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.
KoLolX3: 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):

docs/design.md marks three 16-bit VALU rows Not GPU-verified: the instructions were measured on hardware and the translations CPU-checked, but the SPIR-V the translator emits had never run on a GPU. No open PR adds a fixture for them.

This adds runtime/test/shaders/cs_valu16_ext.asm (one lane, laid out like cs_lds_b64_cmpst.asm). Every destination is preset to 0xA5A5A5A5, so the half an op does not write shows up as 0xA5A5:

word op case expected
0 v_add_nc_i16 clamp 0x7FFF + 1 saturates 0xA5A57FFF
1 v_sub_nc_i16 op_sel:[0,0,1] clamp 0x8000 - 1 saturates, into the high half 0x8000A5A5
2 v_add_nc_i16 0x7FFF + 1 wraps without clamp 0xA5A58000
3 v_med3_i16 op_sel:[1,0,0,0] S0's high half (-5), 7, 3 0xA5A50003
4 v_max3_u16 / v_min3_u16 op_sel:[0,0,0,1] (0xFFFB, 7, 3), one result per half 0x0003FFFB
5 v_min3_f16 / v_max3_f16 op_sel:[0,0,0,1] (1.0, qNaN, -2.0): the NaN yields the other operands 0x3C00C000
6 v_pk_add_u16 clamp high half 0xFFF0 + 0x20 saturates, low 5 + 3 0xFFFF0008
7 v_pk_mad_i16 low -1 * 4 + 16, high 2 * 3 + 1 0x0007000C

The words are derived in the .asm header from the rows. The fixture is registered in check.py and scripts/run_gpu_tests.py next to cs_lds_b64_cmpst. The three rows keep their marker and add a "GPU-checked by" note, as the ds_cmpst_b32 row does. The Integer clamp row (u16 clamp) is not touched: this fixture doesn't cover v_add_nc_u16 clamp.

Tested on an AMD Radeon RX 7900 XT (RADV NAVI31, Mesa 26.3.1, subgroup 32..64), Artix Linux, llvm-mc 23.1.5, programs built from this branch's base:

  • cs_valu16_ext passes with all eight words exact, native and with LEONIDA_W64_EMULATE=1.
  • Negative control: expecting word 0 to wrap (0xA5A58000, clamp ignored) makes it FAIL.
  • Full scripts/run_gpu_tests.py suite, native and emulated: no failure except the known ms_wave_info_s3 flake (#6172, fixes in #5855/#5741), which fails intermittently on main on this card.
  • The 50 test files that read check.py, run_gpu_tests.py, design.md or the shader fixtures: the same failure set as a clean worktree of the merge base on this machine (26, environment-only). The branch adds 2 passing tests and 12 subtests.

Resubmitted from #9579 (closed with the other outside PRs on 2026-11-23), rebased onto main 2d53a8055. Related: #9494, #9761 (merged), #9813. Synthetic fixture only, no game files. AI-assisted (Claude Code).

On the rebased branch, the full suite on this card also shows cs_imgload_tfe, cs_imgload_d16_tfe, cs_w32_exec_computed and cs_w64_exec_computed failing; they fail the same way on a clean worktree of main, so they are not this change.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464906717 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/134). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:25:24Z. --- > Carried over from **old PR 9864** by `KoLolX3` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9864`, 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. > `KoLolX3`: 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): `docs/design.md` marks three 16-bit VALU rows **Not GPU-verified**: the instructions were measured on hardware and the translations CPU-checked, but the SPIR-V the translator emits had never run on a GPU. No open PR adds a fixture for them. This adds `runtime/test/shaders/cs_valu16_ext.asm` (one lane, laid out like `cs_lds_b64_cmpst.asm`). Every destination is preset to `0xA5A5A5A5`, so the half an op does not write shows up as `0xA5A5`: | word | op | case | expected | |---|---|---|---| | 0 | `v_add_nc_i16 clamp` | 0x7FFF + 1 saturates | `0xA5A57FFF` | | 1 | `v_sub_nc_i16 op_sel:[0,0,1] clamp` | 0x8000 - 1 saturates, into the high half | `0x8000A5A5` | | 2 | `v_add_nc_i16` | 0x7FFF + 1 wraps without clamp | `0xA5A58000` | | 3 | `v_med3_i16 op_sel:[1,0,0,0]` | S0's high half (-5), 7, 3 | `0xA5A50003` | | 4 | `v_max3_u16` / `v_min3_u16 op_sel:[0,0,0,1]` | (0xFFFB, 7, 3), one result per half | `0x0003FFFB` | | 5 | `v_min3_f16` / `v_max3_f16 op_sel:[0,0,0,1]` | (1.0, qNaN, -2.0): the NaN yields the other operands | `0x3C00C000` | | 6 | `v_pk_add_u16 clamp` | high half 0xFFF0 + 0x20 saturates, low 5 + 3 | `0xFFFF0008` | | 7 | `v_pk_mad_i16` | low -1 * 4 + 16, high 2 * 3 + 1 | `0x0007000C` | The words are derived in the `.asm` header from the rows. The fixture is registered in `check.py` and `scripts/run_gpu_tests.py` next to `cs_lds_b64_cmpst`. The three rows keep their marker and add a "GPU-checked by" note, as the `ds_cmpst_b32` row does. The Integer clamp row (u16 clamp) is not touched: this fixture doesn't cover `v_add_nc_u16 clamp`. Tested on an AMD Radeon RX 7900 XT (RADV NAVI31, Mesa 26.3.1, subgroup 32..64), Artix Linux, llvm-mc 23.1.5, programs built from this branch's base: - `cs_valu16_ext` passes with all eight words exact, native and with `LEONIDA_W64_EMULATE=1`. - Negative control: expecting word 0 to wrap (`0xA5A58000`, clamp ignored) makes it FAIL. - Full `scripts/run_gpu_tests.py` suite, native and emulated: no failure except the known `ms_wave_info_s3` flake (`#6172`, fixes in `#5855`/#5741), which fails intermittently on `main` on this card. - The 50 test files that read `check.py`, `run_gpu_tests.py`, `design.md` or the shader fixtures: the same failure set as a clean worktree of the merge base on this machine (26, environment-only). The branch adds 2 passing tests and 12 subtests. Resubmitted from `#9579` (closed with the other outside PRs on 2026-11-23), rebased onto `main` `2d53a8055`. Related: `#9494`, `#9761` (merged), `#9813`. Synthetic fixture only, no game files. AI-assisted (Claude Code). On the rebased branch, the full suite on this card also shows `cs_imgload_tfe`, `cs_imgload_d16_tfe`, `cs_w32_exec_computed` and `cs_w64_exec_computed` failing; they fail the same way on a clean worktree of `main`, so they are not this change.
KoLolX3 commented 2026-11-24 04:01:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KoLolX3 on 2026-11-24T04:01:47Z.


Author here: taken over in #366, rebased on main ece4ba5b3 and re-tested (RX 7900 XT, RADV). This draft can be closed in its favour.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7121640432 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/134#issuecomment-7121640432). Originally posted by [KoLolX3](https://github.com/KoLolX3) on 2026-11-24T04:01:47Z. --- Author here: taken over in #366, rebased on `main` `ece4ba5b3` and re-tested (RX 7900 XT, RADV). This draft can be closed in its favour.
aslan2142 commented 2026-11-24 19:17:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T19:17:58Z.


This carry-over of old upstream PR 9864 has been taken over in #366, so I'm closing this draft as #17 describes. The branch old-pr/9864 stays.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7141892849 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/134#issuecomment-7141892849). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T19:17:58Z. --- This carry-over of old upstream PR 9864 has been taken over in #366, so I'm closing this draft as #17 describes. The branch `old-pr/9864` stays. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!134
No description provided.