Tests: check 24-bit multiply/MAD, mul_hi and SAD ops on the GPU #1219

Closed
plentilha wants to merge 1 commit from upstream-pr/1228 into main
plentilha commented 2026-11-24 13:24:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by plentilha on 2026-11-24T13:24:44Z.


Adds GPU execution tests for 14 translated 24-bit multiply/MAD, 32-bit high-multiply, sum-of-absolute-differences and byte-lerp VALU instructions: v_mul_i32_i24, v_mul_hi_i32_i24, v_mul_u32_u24, v_mul_hi_u32_u24, v_mad_i32_i24, v_mad_u32_u24, v_mul_hi_i32, v_mul_hi_u32, v_sad_u32, v_sad_u16, v_sad_u8, v_sad_hi_u8, v_msad_u8 and v_lerp_u8. Test-only change.

What is in it

  • crates/xcl/src/gpu/recomp/tests.rs: gpu_mul24_mul_hi_and_sad_ops verifying high-byte masking/sign-extension on 24-bit inputs, 64-bit high products, zero-byte masking in v_msad_u8 and rounding-bit carries in v_lerp_u8 across gpu_waves().

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 3070 (driver 32.0.16.2124, wave32 only), Intel Core i7-9700K, Windows 11 x64, rustc 1.100.0, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), debug
  • ./scripts/test.ps1: 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64))
  • cargo test -p xcl --lib -- gpu_mul24_mul_hi_and_sad_ops --nocapture: 1 passed, 0 failed (wave32 pass on this adapter)

Regression run

  • Not needed: test-only change.

Not tested

  • Native wave64 pass (AMD/Intel GPUs), retail game runs (XCL_SAMPLE_* unset), Wine, release build.

AI use

  • Antigravity (Gemini 4 Hydrogen): checked emit.rs coverage, wrote the test and PR description, and ran the test suite locally.
<!-- greyfinch-sync:ivall/xcl:issue:5472997388 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1228). Originally posted by [plentilha](https://github.com/plentilha) on 2026-11-24T13:24:44Z. --- Adds GPU execution tests for 14 translated 24-bit multiply/MAD, 32-bit high-multiply, sum-of-absolute-differences and byte-lerp VALU instructions: `v_mul_i32_i24`, `v_mul_hi_i32_i24`, `v_mul_u32_u24`, `v_mul_hi_u32_u24`, `v_mad_i32_i24`, `v_mad_u32_u24`, `v_mul_hi_i32`, `v_mul_hi_u32`, `v_sad_u32`, `v_sad_u16`, `v_sad_u8`, `v_sad_hi_u8`, `v_msad_u8` and `v_lerp_u8`. Test-only change. **What is in it** - `crates/xcl/src/gpu/recomp/tests.rs`: `gpu_mul24_mul_hi_and_sad_ops` verifying high-byte masking/sign-extension on 24-bit inputs, 64-bit high products, zero-byte masking in `v_msad_u8` and rounding-bit carries in `v_lerp_u8` across `gpu_waves()`. **Tested** - hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 3070 (driver 32.0.16.2124, wave32 only), Intel Core i7-9700K, Windows 11 x64, rustc 1.100.0, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), debug - `./scripts/test.ps1`: 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64)) - `cargo test -p xcl --lib -- gpu_mul24_mul_hi_and_sad_ops --nocapture`: 1 passed, 0 failed (wave32 pass on this adapter) **Regression run** - Not needed: test-only change. **Not tested** - Native wave64 pass (AMD/Intel GPUs), retail game runs (`XCL_SAMPLE_*` unset), Wine, release build. **AI use** - Antigravity (Gemini 4 Hydrogen): checked `emit.rs` coverage, wrote the test and PR description, and ran the test suite locally.
dcastell1 commented 2026-11-24 14:06:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T13:28:26Z.


Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@47efa2e (baseline 741 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
742 passed; 0 failed; 41 ignored   (exit 0)

One more than the baseline: the 24-bit multiply/MAD, mul_hi and SAD checks run green here.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

<!-- greyfinch-sync:ivall/xcl:comment:7132880296 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1228#issuecomment-7132880296). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T13:28:26Z. --- Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on `main@47efa2e` (baseline **741 passed, 0 failed, 41 ignored** on this box): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 742 passed; 0 failed; 41 ignored (exit 0) ``` One more than the baseline: the 24-bit multiply/MAD, `mul_hi` and SAD checks run green here. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
DavidM1911 commented 2026-11-24 14:06:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T13:36:05Z.


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

  • cargo test -p xcl --lib recomp: 190 passed, 0 failed, 18 ignored (includes the new 24-bit multiply/MAD/mul_hi/SAD GPU checks).

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7133063694 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1228#issuecomment-7133063694). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T13:36:05Z. --- Verification on RTX 3060 Ti (Windows 11, latest Vulkan driver), branch merged with current `main`: - `cargo test -p xcl --lib recomp`: 190 passed, 0 failed, 18 ignored (includes the new 24-bit multiply/MAD/mul_hi/SAD GPU checks). Thanks!
upipibi commented 2026-11-24 15:05:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T14:09:16Z.


I checked the expected values against the RDNA2 definitions (read from the ISA, not run on AMD hardware). All 14 match:

  • v_mul_hi_{i32_i24,u32_u24}: bits 63..32 of the 48-bit product.
  • v_msad_u8: a byte whose S1 byte is 0 adds nothing.
  • v_sad_hi_u8: the SAD shifted left 16 before S2 is added.
  • v_lerp_u8: the rounding bit of each byte is bit 0 of the matching S2 byte (bits 0, 8, 16, 24).

The cases also cover the ignored top byte of the 24-bit ops, and a zero reference byte for msad. No changes needed from my side.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ivall/xcl:comment:7133923824 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1228#issuecomment-7133923824). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T14:09:16Z. --- I checked the expected values against the RDNA2 definitions (read from the ISA, not run on AMD hardware). All 14 match: - `v_mul_hi_{i32_i24,u32_u24}`: bits 63..32 of the 48-bit product. - `v_msad_u8`: a byte whose S1 byte is 0 adds nothing. - `v_sad_hi_u8`: the SAD shifted left 16 before S2 is added. - `v_lerp_u8`: the rounding bit of each byte is bit 0 of the matching S2 byte (bits 0, 8, 16, 24). The cases also cover the ignored top byte of the 24-bit ops, and a zero reference byte for `msad`. No changes needed from my side. AI-assisted (Claude Code).
DavidM1911 commented 2026-11-26 05:05:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:17:28Z.


Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7182464797 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1228#issuecomment-7182464797). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T04:17:28Z. --- Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
throny commented 2026-11-28 07:48:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T07:48:49Z.


Two contributors checked independently and found that this PR makes the same change as #699: #1607, group D144. They suggest keeping #699. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7236178263 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1228#issuecomment-7236178263). Originally posted by [throny](https://github.com/throny) on 2026-11-28T07:48:49Z. --- <!-- xcl-1607-hint:D144 --> Two contributors checked independently and found that this PR makes the same change as #699: #1607, group D144. They suggest keeping #699. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
raylitebull commented 2026-11-28 21:14:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-28T21:14:02Z.


Closing as a duplicate of #699 (confirmed by 2+ contributors in #1607, group D144). Thanks for the contribution — feel free to comment if this covers something #699 does not.

<!-- greyfinch-sync:ivall/xcl:comment:7245868771 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1228#issuecomment-7245868771). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-28T21:14:02Z. --- Closing as a duplicate of #699 (confirmed by 2+ contributors in #1607, group D144). Thanks for the contribution — feel free to comment if this covers something #699 does not.

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
xcl-dev/xcl!1219
No description provided.