Skip to content

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 into
mainfrom
old-pr/9864
Closed

Andretuta wants to merge 1 commit into
mainfrom
old-pr/9864

Conversation

@Andretuta

Copy link
Copy Markdown
Collaborator

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.

…_pk_add_u16/v_pk_mad_i16

docs/design.md marks the v_add_nc_i16/v_sub_nc_i16, 16-bit
min3/max3/med3 and packed 16-bit integer rows not GPU-verified: the
instructions were measured on hardware and the translations
CPU-checked, but the translated SPIR-V never ran on a GPU.
cs_valu16_ext.asm runs one lane with every destination preset to
0xA5A5A5A5, so the unwritten half shows: i16 clamp at both ends of the
range (one written to the high half through op_sel), the wrap without
clamp, v_med3_i16 reading S0's high half, v_max3_u16/v_min3_u16 and
v_min3_f16/v_max3_f16 (with a quiet NaN) each writing one half,
v_pk_add_u16 clamp saturating one half, and v_pk_mad_i16 with a
negative half. The eight expected words are derived in its header from
the rows. Registered in check.py and run_gpu_tests.py next to
cs_lds_b64_cmpst; the three rows note the GPU check.
@KoLolX3

KoLolX3 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 24, 2026
@aslan2142

Copy link
Copy Markdown
Collaborator

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).

@aslan2142 aslan2142 closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants