Tests: 16-bit VALU results keep the other half of VDST #1106

Open
4usphs wants to merge 1 commit from upstream-pr/1115 into main
4usphs commented 2026-11-24 11:56:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by 4usphs on 2026-11-24T11:56:03Z.


A 16-bit VALU result goes into D[15:0] and leaves D[31:16] as it was, or with VOP3 op_sel[3] into D[31:16] leaving D[15:0]. op_sel[0..2] read the sources' high halves. valu16 does this ((cur & 0xFFFF0000u) | t, emit.rs ~3051), but only v_add_f16 has a check of it in gpu_valu_16_and_64_bit. The other 16-bit tests, including #638 and #639, compare D[15:0] alone. A change that zeroed or overwrote the other half would pass all of them.

The expected behaviour is measured on RDNA2 silicon, the console's generation, not taken from the ISA text: https://github.com/ivall/xcl/pull/638#issuecomment-7127672871, plus the op_sel forms below.

What is in it

  • crates/xcl/src/gpu/recomp/tests.rs: gpu_16_bit_results_keep_the_other_half. Every VDST starts at 0xCAFE_BABE. Each source has different values in its two halves. 24 rows:
    • the 16-bit integer ops of valu16 that RDNA2 has, plain VOP3: v_add/sub_nc_u16/i16, v_mul_lo_u16, v_lshlrev/lshrrev_b16, v_ashrrev_i16, v_min/max_u16/i16, v_mad_u16/i16. v_subrev_nc_u16 is left out: the RDNA2 / RDNA4 assembler refuses it.
    • the op_sel forms the RDNA2 assembler takes (v_add/sub_nc_u16/i16, v_mad_u16/i16): writing D[31:16], reading the high halves, both.
    • v_cvt_u16_f16 / v_cvt_i16_f16 (VOP1), f16 source with 0xBEEF in its high half.

Tested

  • Two GPUs in one PC, picked with XCL_ADAPTER: AMD Radeon iGPU of a Ryzen 7 9800X3D (gfx1036, RDNA2, native wave64, driver 32.0.21045.29003) and AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32029.2010). Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on a8133ad: 742 passed, 0 failed, 41 ignored on each GPU, no SKIPPED (main 47efa2e: 741 / 0 / 41 on each).
  • The new test with XCL_REQUIRE_GPU=wave64: 3 / 3 passed on each GPU.
  • Negative controls on the RDNA2 iGPU, each a one-line local change to valu16, reverted after:
    • D[31:16] not kept (t written alone): 108 failing rows, e.g. V_ADD_NC_I16 … got 0x00000000, want 0xcafe0000.
    • op_sel[3] ignored: 36 failing rows (got 0xcafef777, want 0xf777babe).
    • op_sel source bits ignored: 35 failing rows.
  • Hardware reference: each instruction and op_sel form above ran as inline assembly in OpenCL (the #518 / #772 method) on both GPUs, VDST preset to 0xCAFEBABE, wave32 and wave64. Every form the assembler accepted matches the rule above on both GPUs.

Regression run

  • Test-only change (tests.rs), no runtime regression run.

Not tested

  • NVIDIA / wave32-only GPUs (the split wave64 form), so the test ran only in native wave64 here.
  • op_sel on the VOP2-origin ops (v_mul_lo_u16, the shifts, min / max): the RDNA2 assembler refuses it, so there is no hardware reference for it.
  • SDWA forms, clamp, the console itself (gfx1036 is a desktop RDNA2 APU of the same generation).

AI use

  • Claude Code (Claude Opus 5.5) wrote the test, the OpenCL probes and this description, and ran the tests and the controls on my PC.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5471648856 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1115). Originally posted by [4usphs](https://github.com/4usphs) on 2026-11-24T11:56:03Z. --- A 16-bit VALU result goes into D[15:0] and leaves D[31:16] as it was, or with VOP3 `op_sel[3]` into D[31:16] leaving D[15:0]. `op_sel[0..2]` read the sources' high halves. `valu16` does this (`(cur & 0xFFFF0000u) | t`, `emit.rs` ~3051), but only `v_add_f16` has a check of it in `gpu_valu_16_and_64_bit`. The other 16-bit tests, including #638 and #639, compare D[15:0] alone. A change that zeroed or overwrote the other half would pass all of them. The expected behaviour is measured on RDNA2 silicon, the console's generation, not taken from the ISA text: https://github.com/ivall/xcl/pull/638#issuecomment-7127672871, plus the op_sel forms below. **What is in it** - `crates/xcl/src/gpu/recomp/tests.rs`: `gpu_16_bit_results_keep_the_other_half`. Every VDST starts at `0xCAFE_BABE`. Each source has different values in its two halves. 24 rows: - the 16-bit integer ops of `valu16` that RDNA2 has, plain VOP3: `v_add/sub_nc_u16/i16`, `v_mul_lo_u16`, `v_lshlrev/lshrrev_b16`, `v_ashrrev_i16`, `v_min/max_u16/i16`, `v_mad_u16/i16`. `v_subrev_nc_u16` is left out: the RDNA2 / RDNA4 assembler refuses it. - the op_sel forms the RDNA2 assembler takes (`v_add/sub_nc_u16/i16`, `v_mad_u16/i16`): writing D[31:16], reading the high halves, both. - `v_cvt_u16_f16` / `v_cvt_i16_f16` (VOP1), f16 source with `0xBEEF` in its high half. **Tested** - Two GPUs in one PC, picked with `XCL_ADAPTER`: AMD Radeon iGPU of a Ryzen 7 9800X3D (`gfx1036`, RDNA2, native wave64, driver 32.0.21045.29003) and AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32029.2010). Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug. - `cargo test --workspace --no-fail-fast -- --test-threads=4` on `a8133ad`: **742 passed, 0 failed, 41 ignored** on each GPU, no `SKIPPED` (`main` `47efa2e`: 741 / 0 / 41 on each). - The new test with `XCL_REQUIRE_GPU=wave64`: 3 / 3 passed on each GPU. - Negative controls on the RDNA2 iGPU, each a one-line local change to `valu16`, reverted after: - D[31:16] not kept (`t` written alone): 108 failing rows, e.g. `V_ADD_NC_I16 … got 0x00000000, want 0xcafe0000`. - `op_sel[3]` ignored: 36 failing rows (`got 0xcafef777, want 0xf777babe`). - `op_sel` source bits ignored: 35 failing rows. - Hardware reference: each instruction and op_sel form above ran as inline assembly in OpenCL (the #518 / #772 method) on both GPUs, VDST preset to `0xCAFEBABE`, wave32 and wave64. Every form the assembler accepted matches the rule above on both GPUs. **Regression run** - Test-only change (`tests.rs`), no runtime regression run. **Not tested** - NVIDIA / wave32-only GPUs (the split wave64 form), so the test ran only in native wave64 here. - op_sel on the VOP2-origin ops (`v_mul_lo_u16`, the shifts, min / max): the RDNA2 assembler refuses it, so there is no hardware reference for it. - SDWA forms, `clamp`, the console itself (`gfx1036` is a desktop RDNA2 APU of the same generation). **AI use** - Claude Code (Claude Opus 5.5) wrote the test, the OpenCL probes and this description, and ran the tests and the controls on my PC. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fromthemoonx commented 2026-11-24 13:03:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-24T12:26:02Z.


NVIDIA (32-lane) run, since Not tested lists NVIDIA.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (32-lane waves only), driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300.9974), Graphics Tools installed; rustc 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug
  • Exact head a8133adca5c6ea5cd768b966f66383efd06e861c, which is on current main 47efa2e (so also the merged result): cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4: 742 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • gpu_16_bit_results_keep_the_other_half alone, 10 runs: 10 of 10 passed on this card. All 24 rows give the RDNA2-measured values here, including the op_sel forms and the two VOP1 conversions.
  • It catches a broken merge (local edits to emit.rs, reverted after):
    • valu16's low-half write changed from ({cur} & 0xFFFF0000u) | {t} to {t}: the new test fails with clear rows, e.g. V_ADD_NC_I16 op_sel=0b0000 … got 0x00000004, want 0xcafe0004.
    • the op_sel[3] write changed from ({cur} & 0xFFFFu) | ({t} << 16) to ({t} << 16): the new test fails, e.g. V_ADD_NC_I16 op_sel=0b1010 … got 0xabd20000, want 0xabd2babe.
    • For completeness: in both cases the existing gpu_valu_16_and_64_bit fails too, on its v_add_f16 keeps the high half checks (lines 2707 and 2708), because all these ops share that one merge in valu16. So these two mutations were already caught by v_add_f16. The new test adds per-opcode and per-op_sel coverage, which matters for a change to one op's path, and failure messages that name the op and form.

Not tested

  • Native wave64 (this card has 32-lane waves only), RDNA silicon comparisons, release build.

AI use

  • Claude Code (Claude Opus 5.5) ran the build, tests and the two local mutations on the machine above and wrote this report from the output.
<!-- greyfinch-sync:ivall/xcl:comment:7131432435 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1115#issuecomment-7131432435). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-11-24T12:26:02Z. --- NVIDIA (32-lane) run, since **Not tested** lists NVIDIA. **Tested** - NVIDIA GeForce RTX 3060 12 GB (32-lane waves only), driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300.9974), Graphics Tools installed; rustc 1.100.0 `stable-x86_64-pc-windows-msvc`; DXC 1.9.2602.17; debug - **Exact head `a8133adca5c6ea5cd768b966f66383efd06e861c`**, which is on current `main` `47efa2e` (so also the merged result): `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4`: **742 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - `gpu_16_bit_results_keep_the_other_half` alone, 10 runs: **10 of 10 passed** on this card. All 24 rows give the RDNA2-measured values here, including the op_sel forms and the two VOP1 conversions. - **It catches a broken merge** (local edits to `emit.rs`, reverted after): - `valu16`'s low-half write changed from `({cur} & 0xFFFF0000u) | {t}` to `{t}`: the new test fails with clear rows, e.g. `V_ADD_NC_I16 op_sel=0b0000 … got 0x00000004, want 0xcafe0004`. - the op_sel[3] write changed from `({cur} & 0xFFFFu) | ({t} << 16)` to `({t} << 16)`: the new test fails, e.g. `V_ADD_NC_I16 op_sel=0b1010 … got 0xabd20000, want 0xabd2babe`. - For completeness: in both cases the existing `gpu_valu_16_and_64_bit` fails too, on its `v_add_f16 keeps the high half` checks (lines 2707 and 2708), because all these ops share that one merge in `valu16`. So these two mutations were already caught by `v_add_f16`. The new test adds per-opcode and per-op_sel coverage, which matters for a change to one op's path, and failure messages that name the op and form. **Not tested** - Native wave64 (this card has 32-lane waves only), RDNA silicon comparisons, release build. **AI use** - Claude Code (Claude Opus 5.5) ran the build, tests and the two local mutations on the machine above and wrote this report from the output.
JoaoPauluu commented 2026-11-24 14:06:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-24T13:45:23Z.


A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257 (DXIL → SPIR-V through dxil-spirv), DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. a8133ad as it is (based on 47efa2e), no uncommitted changes. The lib test binary runs under Wine.
  • gpu::recomp::tests::gpu_16_bit_results_keep_the_other_half (--exact, one process): ok, no SKIPPED. DXC compiled it and it ran on the GPU in about 0.8 s.

Not tested

  • the rest of the suite on this head; native Windows; AMD / native wave64.

AI use

  • Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
<!-- greyfinch-sync:ivall/xcl:comment:7133289353 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1115#issuecomment-7133289353). Originally posted by [JoaoPauluu](https://github.com/JoaoPauluu) on 2026-11-24T13:45:23Z. --- A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler. **Tested** - RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257 (DXIL → SPIR-V through dxil-spirv), DXC 1.9.2609.5. Release, cross-built for `x86_64-pc-windows-gnu`. `a8133ad` as it is (based on `47efa2e`), no uncommitted changes. The lib test binary runs under Wine. - `gpu::recomp::tests::gpu_16_bit_results_keep_the_other_half` (`--exact`, one process): **ok**, no SKIPPED. DXC compiled it and it ran on the GPU in about 0.8 s. **Not tested** - the rest of the suite on this head; native Windows; AMD / native wave64. **AI use** - Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
wanchudao commented 2026-11-24 16:07:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by wanchudao on 2026-11-24T15:41:16Z.


Tested — a8133ad on Windows 11 Pro build 26300, RTX 3070 Ti (driver 610.88),
rustc 1.100.0, MSVC 14.44.35207, and DXC 1.9.2602.17.

cargo test -p xcl --lib gpu_16_bit_results_keep_the_other_half -- --nocapture

Result with the default adapter: 1 passed, 0 failed, 0 ignored, 719 filtered out.
The same test provided an additional result for xcl's split-wave64 path on this card:

  • With XCL_ADAPTER=definitely-not-a-gpu, it printed SKIPPED ...: no GPU (0.03 s).
  • The default rerun printed no SKIPPED line (0.39 s). The first default run took 0.47 s.
  • With XCL_REQUIRE_GPU=wave64, a skip in this test would fail it. The test passed (0.47 s).

Not tested — AMD reference hardware, native wave64, or op_sel on the VOP2-origin ops.

AI use — DeepSeek Harness (DeepSeek V4.1 Flash) ran the tests and drafted this report.
OpenAI Codex (GPT-6.2 Sol) checked the archived results and revised it.

<!-- greyfinch-sync:ivall/xcl:comment:7136443568 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1115#issuecomment-7136443568). Originally posted by [wanchudao](https://github.com/wanchudao) on 2026-11-24T15:41:16Z. --- **Tested** — a8133ad on Windows 11 Pro build 26300, RTX 3070 Ti (driver 610.88), rustc 1.100.0, MSVC 14.44.35207, and DXC 1.9.2602.17. `cargo test -p xcl --lib gpu_16_bit_results_keep_the_other_half -- --nocapture` Result with the default adapter: 1 passed, 0 failed, 0 ignored, 719 filtered out. The same test provided an additional result for xcl's split-wave64 path on this card: - With `XCL_ADAPTER=definitely-not-a-gpu`, it printed `SKIPPED ...: no GPU` (0.03 s). - The default rerun printed no `SKIPPED` line (0.39 s). The first default run took 0.47 s. - With `XCL_REQUIRE_GPU=wave64`, a skip in this test would fail it. The test passed (0.47 s). **Not tested** — AMD reference hardware, native wave64, or `op_sel` on the VOP2-origin ops. **AI use** — DeepSeek Harness (DeepSeek V4.1 Flash) ran the tests and drafted this report. OpenAI Codex (GPT-6.2 Sol) checked the archived results and revised it.
DavidM1911 commented 2026-11-25 09:08:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T08:16:02Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7156815249 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1115#issuecomment-7156815249). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T08:16:02Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
github-actions[bot] commented 2026-11-29 07:40:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:40:30Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7252619639 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1115#issuecomment-7252619639). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T07:40:30Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 04:51:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:51:41Z.


Triage (#1607) – head a8133ad

#638 also tests these 16-bit integer ops on the GPU but compares only D[15:0]; this PR checks the kept half and VOP3 op_sel (source halves and op_sel[3]), so they complement each other rather than duplicate. Main's valu16 in emit.rs already implements these semantics, so this is coverage, not a fix.
No problems found in the diff. The branch currently conflicts with main in recomp/tests.rs.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301176980 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1115#issuecomment-7301176980). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:51:41Z. --- **Triage (#1607)** – head a8133ad #638 also tests these 16-bit integer ops on the GPU but compares only D[15:0]; this PR checks the kept half and VOP3 op_sel (source halves and op_sel[3]), so they complement each other rather than duplicate. Main's `valu16` in `emit.rs` already implements these semantics, so this is coverage, not a fix. No problems found in the diff. The branch currently conflicts with main in `recomp/tests.rs`. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1115:upstream-pr/1115'
git switch 'upstream-pr/1115'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1115'
git switch 'upstream-pr/1115'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1115'
git switch 'upstream-pr/1115'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1115'
git switch 'main'
git merge --squash 'upstream-pr/1115'
git switch 'main'
git merge --ff-only 'upstream-pr/1115'
git switch 'main'
git merge 'upstream-pr/1115'
git push origin 'main'
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
xcl-dev/xcl!1106
No description provided.