Tests: 16-bit integer VALU ops and the byte / half SADs on the GPU #633
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/638"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by acaracargo on 2026-11-24T02:45:56Z.
Adds a GPU test for 20 VOP3 instructions that
emit.rstranslates but no test runs:v_mad_u32_u16andv_mad_i32_i16.v_sad_hi_u8,v_sad_u16andv_sad_u32.v_cvt_pk_i16_i32.Eleven lanes carry edge values: sign and carry boundaries, shift counts past 15, and i16 saturation in both directions. The high half of every 16-bit source holds another value, so a translation that reads the whole register shows up. Each lane is compared with the ISA's pseudo-code. Only D[15:0] of a 16-bit result is compared.
#590 tests the 24-bit and high-half multiplies, so this one leaves them out. #445 has the 16-bit min3 / max3 / med3.
What is in it
crates/xcl/src/gpu/recomp/tests.rs:gpu_valu_16_bit_integer_and_sad.Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug.cargo test --workspace -- --test-threads=4on253f749: 685 passed, 0 failed, 41 ignored (main9ce2070: 684 / 0 / 41).gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).v_ashrrev_i16into a logical shift, or makingv_sad_u16skip the high half, fails the test (checked locally, reverted).Regression run
Not tested
AI use
Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T02:55:02Z.
Test run of
253f74917b147deb949fa9633db1ea88eabd54acon AMD RDNA4; the PR was tested on NVIDIA only. I merged it onto currentmain18c105alocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 690 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 650 passed, 0 failed, 21 ignoredSKIPPED;gpu_valu_16_bit_integer_and_sadpasses.Review: The CPU references match the RDNA2 pseudo-code where I checked:
v_sad_u16sums both half differences plus S2,v_sad_hi_u8shifts the byte SAD by 16 before adding S2,v_mad_u32_u16/v_mad_i32_i16widen before the multiply,v_cvt_pk_i16_i32saturates each word, and the*revshifts take the count from S0[3:0]. Comparing only D[15:0] for the 16-bit results is right, since the high half is not defined by these opcodes withoutop_sel. I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Imported from ivall/xcl. Originally posted by marquezinii on 2026-11-24T04:31:07Z.
Test run of
253f74917b147deb949fa9633db1ea88eabd54acon NVIDIA Blackwell with a newer driver than the one in the description. I merged it onto currentmainf4ce27clocally (clean merge, 75 lines intests.rs) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debug; DXC 1.9.2602.17 (Windows SDK 10.0.26100.0)cargo test --workspace -- --test-threads=4: 702 passed, 0 failed, 41 ignored;--test-threads=1: the samegpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)gpu_valu_16_bit_integer_and_sadpassesv_sad_hi_u8shifting the sum by 8 instead of 16 (a=0x12340001 b=0xabcdffff c=0x55550002: got 0x55582f02, want 0x58840002), andv_ashrrev_i16masking the shift count with 31 instead of 15 (a=0xa5a50011 b=0x0f0f8001: got 0xffff, want 0xc000)Not tested
AI use
Imported from ivall/xcl. Originally posted by 4usphs on 2026-11-24T09:37:43Z.
Measured on RDNA2 hardware, for the two points under Not tested: console-generation hardware, and D[31:16] of 16-bit results.
Method. The Radeon iGPU of a Ryzen 7 9800X3D (
gfx1036, RDNA2), Windows 11 Pro 26200, display driver 32.0.21045.29003, AMD OpenCL3652.0 (PAL,LC). Each instruction runs as inline RDNA2 assembly in an OpenCL C kernel (the #518 / #772 method), in its VOP3 form (_e64), on this test's 11 input triples, one per work-item. VDST is preset to0xCAFEBABE. The test runs 6 times, 3 in wave32 and 3 in wave64, with identical output. The reference is a Python port of this test's 20 closures.Result.
0xCAFE, for every input. These arev_add/sub_nc_u16/i16,v_mul_lo_u16, the three*_b16/_i16shifts,v_min/max_u16/i16andv_mad_u16/i16. That is whatvalu16does ((cur & 0xFFFF0000u) | t,emit.rs:3051onmain077ce40). So the test could preset the destinations and compare all 32 bits.v_cvt_u16_f16/v_cvt_i16_f16keep it too (measured for #639). The assembler refuses a VOP2 (_e32) form of these 16-bit instructions ongfx1036, so I could not compare an encoding without op_sel.For comparison, an RX 9070 XT (
gfx1201, RDNA4, OpenCL3686.0) gives the same results and also keeps D[31:16].Not tested: the console itself (
gfx1036is a desktop RDNA2 APU of the same generation), RDNA1, the op_sel forms (writing D[31:16] instead), this PR's D3D12 test on this GPU.AI use: Claude Code (Claude Opus 5.5) wrote the OpenCL probes and the port of the reference, ran them on my PC and wrote this comment. I have not reviewed the code.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T06:36:53Z.
Empirical test report (
253f7491)Hardware / environment
253f74917b147deb949fa9633db1ea88eabd54ac, checked out detached.XCL_ADAPTER=A770. Windows x64, build10.0.26200.0. CPU identifierAMD64 Family 23 Model 113 Stepping 0, AuthenticAMD.1.100.0(0ef1bc386,x86_64-pc-windows-msvc). DXC1.9.2609.5(01b62ad4), DXIL1.9.2609.5. Unoptimized test profile with debug info and incremental compilation disabled.Commands and results
cargo test -p xcl --lib --no-runran outside the Arc lock and exited 0. It built the library test executable.xcl-00e28da3621caf64.exe --exact --nocapture --test-threads=1 gpu::recomp::tests::gpu_valu_16_bit_integer_and_sadran underInvoke-ArcTest.ps1withXCL_ADAPTER=A770andRUST_TEST_NOCAPTURE=1. The executable and wrapper both exited 0. Libtest reported 1 passed, 0 failed, 0 ignored, 0 measured, and 665 filtered out in 0.37 s. The captured stdout and stderr contained 0 lines beginning withSKIPPED.Observed behavior
Not tested
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr638-focused.log and published.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T12:43:40Z.
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!
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:42:50Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T08:56:45Z.
merge-check claim
head:
253f74917bImported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T09:02:46Z.
merge-check
base:
d52ff48caahead:
253f74917bmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2876 passed, 2 failed, 51 ignored; 29 SKIPPED lines
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
correction: this check first reported the PR as "not yet" because of a test failure that is not the PR's. The base-comparison step failed to run (test names contain a double colon, not a legal Windows filename), so an empty read was mistaken for "passes on base".
gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16fails on based52ff48cby itself (verified separately with the same command: "assertion failed: 2D D16 resinfo clobbered v2/v3"). Verdict corrected. Apologies for the noise.Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T10:10:29Z.
merge-check claim
head:
253f74917bImported from ivall/xcl. Originally posted by BBareth on 2026-11-30T10:22:38Z.
merge-check
base:
9dfbe3ea66head:
253f74917bmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails on the base alone too (base: 2885 passed, 1 failed, 51 ignored, 28 SKIPPED lines). 28 SKIPPED lines, as on the base. The new test
gpu_valu_16_bit_integer_and_sadpassed.review: no blocking finding; test-only, one file, read in full. One GPU test of the 16-bit integer VALU instructions and the byte / half SADs against the ISA's pseudo-code per lane, with edge values per lane and another value in each source's high half; only D[15:0] of a 16-bit result is compared. #738 (min3 / max3 / med3 u16) is the neighbouring test, not a duplicate.
performance: none; tests only.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:50:45Z.
Triage (#1607) – head
253f749No open or merged PR tests the same ops. Main has no GPU test of the 16-bit integer VALU ops, V_MAD_*32_*16 or V_CVT_PK_I16_I32. #1576 also checks V_SAD_U32 / V_SAD_HI_U8 / V_SAD_U16 (3 of the 20 ops here), and #202 checks V_MAD_I32_I16 / V_SAD_HI_U8 with CLAMP. Those are small overlaps, not the same change.
The reference closures match the RDNA2 pseudo-code: 4-bit shift counts, signed 16-bit sources, the high half of each 16-bit source ignored and 16-bit results masked.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.