Skip to content

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

Open
4usphs wants to merge 1 commit into
xcl-dev:mainfrom
4usphs:tests/16-bit-results-keep-other-half
Open

4usphs wants to merge 1 commit into
xcl-dev:mainfrom
4usphs:tests/16-bit-results-keep-other-half

Conversation

@4usphs

@4usphs 4usphs commented Nov 24, 2026

Copy link
Copy Markdown

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: #638 (comment), 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 Recompiler tests: ds_swizzle_b32 lanes match RDNA2 hardware for every offset #518 / Recompiler: ds_bpermute_b32 in wave64 may stay within each 32-lane half on RDNA2 (needs a hardware run) #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

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], and op_sel[0..2] read the
sources' high halves. valu16 does this (`(cur & 0xFFFF0000u) | t`), but only
v_add_f16 had a check of it: the other 16-bit tests compare D[15:0] alone.

gpu_16_bit_results_keep_the_other_half presets every VDST to 0xCAFE_BABE and
runs the 16-bit integer ops of valu16 that RDNA2 has, the op_sel forms the
RDNA2 assembler takes (v_add/sub_nc_u16/i16, v_mad_u16/i16), and
v_cvt_u16_f16 / v_cvt_i16_f16. The expected values follow what RDNA2
(gfx1036) and RDNA4 (gfx1201) silicon gave for the same instructions as
inline assembly through OpenCL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@4usphs
4usphs marked this pull request as ready for review November 24, 2026 12:06
@fromthemoonx

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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 Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #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

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

off-goal Does not bear on the current goal (world loading); waits until it is reached

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants