Recompiler: translate v_qsad_pk_u16_u8 and v_mqsad_{pk_u16,u32}_u8 in both backends (takes over #909) #2324

Merged
NWProgramming00 merged 2 commits from upstream-pr/2334 into main 2026-11-25 18:37:27 +00:00
NWProgramming00 commented 2026-11-25 14:57:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by NWProgramming00 on 2026-11-25T14:57:59Z.


Both backends refused v_qsad_pk_u16_u8, v_mqsad_pk_u16_u8 and v_mqsad_u32_u8. This takes over #909 by @bigiello, which its author closed along with their other open PRs on 24.11 while it was waiting only for a regression run. Their commit is kept as it was, with its authorship. On top of it, this adds the same translation to the direct DXIL backend, checks both backends against RDNA2 hardware, and adds the regression run.

What is in it

  • 95f6c1a (@bigiello, unchanged from #909): Em::valu_qsad and a pk_sad_u16 prelude helper in crates/xcl/src/gpu/recomp/emit.rs, plus the tests qsad_and_mqsad_operand_forms_and_validation and gpu_qsad_and_mqsad.
  • c0eaeff: Lw::valu_qsad in crates/xcl/src/gpu/dxil/lower_wide.rs, dispatched from lower_valu.rs.
    • It follows valu_qsad: the four 4-byte windows of the 64-bit SRC0 against SRC1, with mqsad skipping SRC1's zero bytes.
    • Each SAD is added to its 16-bit (_pk_u16) or 32-bit (_u32) element of SRC2, saturating per element with CLAMP.
    • It refuses the same operand forms as the HLSL backend.
    • gpu_qsad_and_mqsad now runs both backends in wave32 and wave64.

Tested

  • Windows 11, NVIDIA GeForce RTX 5070 Ti 16 GB (wave64 as two halves) and an AMD Radeon RDNA2 iGPU (gfx1036, native wave64, XCL_ADAPTER=radeon). Rust 1.100 MSVC, release.
  • xcl against the gfx1036. All three instructions, with and without CLAMP, ran on 832 lanes. The inputs were edge bytes, zero bytes in SRC1, accumulators near 0xFFFF / 0xFFFFFFFF, and random words. I compared all 8 result words per lane with the gfx1036's own results, which come from running the instructions there directly through HIP:
    • HLSL backend: no differences on either adapter.
    • direct DXIL: no differences on either adapter.
    • This repeats @4usphs's hardware check on #909 for the HLSL backend, now on both backends.
  • gpu_qsad_and_mqsad passes on both adapters. It fails with each of six deliberate mistakes:
    • the zero-byte mask of mqsad dropped (direct DXIL);
    • CLAMP ignored on the 16-bit elements (direct DXIL);
    • CLAMP ignored on the 32-bit elements (direct DXIL);
    • a wrong window shift (direct DXIL);
    • the high accumulator read from the low word (direct DXIL);
    • pk_sad_u16 without saturation (HLSL).
  • The whole suite: cargo build --release --workspace, then cargo test --release --workspace --no-fail-fast -- --test-threads=4, with and without XCL_DIRECT_DXIL=all, against base 06c9f55 on the same machine:
Adapter Mode base 06c9f55 this PR (c0eaeff)
RTX 5070 Ti default 1261 passed, 4 failed, 46 ignored 1263 passed, 4 failed, 46 ignored
RTX 5070 Ti XCL_DIRECT_DXIL=all 1260 passed, 5 failed, 46 ignored 1262 passed, 5 failed, 46 ignored
Radeon gfx1036 default 1264 passed, 1 failed, 46 ignored 1266 passed, 1 failed, 46 ignored
Radeon gfx1036 XCL_DIRECT_DXIL=all 1263 passed, 2 failed, 46 ignored 1265 passed, 2 failed, 46 ignored

The +2 are #909's two tests. The same tests fail on both sides, and all of them are tracked:

  • fuzz_validate_and_gpu_0..3 on NVIDIA (#1905);
  • fuzz_validate_and_gpu_1 on RDNA2 (#2115);
  • offline_compute_pipeline_is_reused_by_a_second_process with direct DXIL (#1674).

Regression run
Base (main 06c9f55), NVIDIA GeForce RTX 5070 Ti:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 5070 Ti
title: title-a
seconds: 60
exit: 0x0
frames shown: 819 (PresentX 820)
presents per 2 s (last 3): 13 28 28
device removals: 0
crashes: 0
peak commit: 16053 MB

This PR (c0eaeff), same card:

xcl-smoke v1
commit: c0eaeff7046ebb8e5384673c661920d7a9d76cff
gpu: NVIDIA GeForce RTX 5070 Ti
title: title-a
seconds: 60
exit: 0x0
frames shown: 881 (PresentX 881)
presents per 2 s (last 3): 9 60 60
device removals: 0
crashes: 0
peak commit: 15656 MB

Not tested

  • RDNA3 / RDNA4 and Intel here. @SlopTart ran #909's head on RDNA3 under Linux.
  • Whether a retail program uses these instructions.

AI use

  • #909's commit says it was written with Antigravity.
  • Claude Code (Claude Opus 5.5) did the rest: it ported the lowering to direct DXIL, measured the hardware, extended the test, ran the comparisons, the mutation checks and the suites, and wrote this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5493779363 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2334). Originally posted by [NWProgramming00](https://github.com/NWProgramming00) on 2026-11-25T14:57:59Z. --- Both backends refused `v_qsad_pk_u16_u8`, `v_mqsad_pk_u16_u8` and `v_mqsad_u32_u8`. This takes over #909 by @bigiello, which its author closed along with their other open PRs on 24.11 while it was waiting only for a regression run. Their commit is kept as it was, with its authorship. On top of it, this adds the same translation to the direct DXIL backend, checks both backends against RDNA2 hardware, and adds the regression run. **What is in it** - `95f6c1a` (@bigiello, unchanged from #909): `Em::valu_qsad` and a `pk_sad_u16` prelude helper in `crates/xcl/src/gpu/recomp/emit.rs`, plus the tests `qsad_and_mqsad_operand_forms_and_validation` and `gpu_qsad_and_mqsad`. - `c0eaeff`: `Lw::valu_qsad` in `crates/xcl/src/gpu/dxil/lower_wide.rs`, dispatched from `lower_valu.rs`. - It follows `valu_qsad`: the four 4-byte windows of the 64-bit SRC0 against SRC1, with `mqsad` skipping SRC1's zero bytes. - Each SAD is added to its 16-bit (`_pk_u16`) or 32-bit (`_u32`) element of SRC2, saturating per element with CLAMP. - It refuses the same operand forms as the HLSL backend. - `gpu_qsad_and_mqsad` now runs both backends in wave32 and wave64. **Tested** - Windows 11, NVIDIA GeForce RTX 5070 Ti 16 GB (wave64 as two halves) and an AMD Radeon RDNA2 iGPU (gfx1036, native wave64, `XCL_ADAPTER=radeon`). Rust 1.100 MSVC, release. - **xcl against the gfx1036.** All three instructions, with and without CLAMP, ran on 832 lanes. The inputs were edge bytes, zero bytes in SRC1, accumulators near 0xFFFF / 0xFFFFFFFF, and random words. I compared all 8 result words per lane with the gfx1036's own results, which come from running the instructions there directly through HIP: - HLSL backend: no differences on either adapter. - direct DXIL: no differences on either adapter. - This repeats @4usphs's hardware check on #909 for the HLSL backend, now on both backends. - **`gpu_qsad_and_mqsad` passes on both adapters.** It fails with each of six deliberate mistakes: - the zero-byte mask of `mqsad` dropped (direct DXIL); - CLAMP ignored on the 16-bit elements (direct DXIL); - CLAMP ignored on the 32-bit elements (direct DXIL); - a wrong window shift (direct DXIL); - the high accumulator read from the low word (direct DXIL); - `pk_sad_u16` without saturation (HLSL). - **The whole suite:** `cargo build --release --workspace`, then `cargo test --release --workspace --no-fail-fast -- --test-threads=4`, with and without `XCL_DIRECT_DXIL=all`, against base `06c9f55` on the same machine: | Adapter | Mode | base `06c9f55` | this PR (`c0eaeff`) | |---|---|---|---| | RTX 5070 Ti | default | 1261 passed, 4 failed, 46 ignored | 1263 passed, 4 failed, 46 ignored | | RTX 5070 Ti | `XCL_DIRECT_DXIL=all` | 1260 passed, 5 failed, 46 ignored | 1262 passed, 5 failed, 46 ignored | | Radeon gfx1036 | default | 1264 passed, 1 failed, 46 ignored | 1266 passed, 1 failed, 46 ignored | | Radeon gfx1036 | `XCL_DIRECT_DXIL=all` | 1263 passed, 2 failed, 46 ignored | 1265 passed, 2 failed, 46 ignored | The +2 are #909's two tests. The same tests fail on both sides, and all of them are tracked: - `fuzz_validate_and_gpu_0..3` on NVIDIA (#1905); - `fuzz_validate_and_gpu_1` on RDNA2 (#2115); - `offline_compute_pipeline_is_reused_by_a_second_process` with direct DXIL (#1674). **Regression run** Base (`main` `06c9f55`), NVIDIA GeForce RTX 5070 Ti: ``` xcl-smoke v1 commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324 gpu: NVIDIA GeForce RTX 5070 Ti title: title-a seconds: 60 exit: 0x0 frames shown: 819 (PresentX 820) presents per 2 s (last 3): 13 28 28 device removals: 0 crashes: 0 peak commit: 16053 MB ``` This PR (`c0eaeff`), same card: ``` xcl-smoke v1 commit: c0eaeff7046ebb8e5384673c661920d7a9d76cff gpu: NVIDIA GeForce RTX 5070 Ti title: title-a seconds: 60 exit: 0x0 frames shown: 881 (PresentX 881) presents per 2 s (last 3): 9 60 60 device removals: 0 crashes: 0 peak commit: 15656 MB ``` **Not tested** - RDNA3 / RDNA4 and Intel here. @SlopTart ran #909's head on RDNA3 under Linux. - Whether a retail program uses these instructions. **AI use** - #909's commit says it was written with Antigravity. - Claude Code (Claude Opus 5.5) did the rest: it ported the lowering to direct DXIL, measured the hardware, extended the test, ran the comparisons, the mutation checks and the suites, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
nnonno91 commented 2026-11-25 15:08:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-25T15:06:40Z.


Independent exact-head verification of c0eaeff7046ebb8e5384673c661920d7a9d76cff on Radeon integrated graphics and RTX 5090.

Tested

  • Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, unoptimized profile. AMD Radeon(TM) Graphics driver 32.0.21042.62 and RTX 5090 driver 32.0.16.1742. SDK DXC/DXIL 1.8.2502.11.
  • cargo test --locked -p xcl --lib qsad_and_mqsad -- --nocapture --test-threads=1 with XCL_ADAPTER=AMD Radeon and XCL_ADAPTER=NVIDIA GeForce RTX 5090 in separate processes. Both gave 2 passed, 0 failed, 0 ignored and no skips.
  • Both translation paths passed the wave32 and logical wave64 GPU fixtures, including the three instructions, saturation and wrap cases, overlapping operands and the check that inactive lanes retain their original values. Operand-form and translation validation also passed.

Not tested

The separate HIP hardware capture, retail inputs, the parent and the full workspace suite.

AI use

OpenAI Codex (GPT-6.2 Sol) ran the checks and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7166318122 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2334#issuecomment-7166318122). Originally posted by [nnonno91](https://github.com/nnonno91) on 2026-11-25T15:06:40Z. --- Independent exact-head verification of `c0eaeff7046ebb8e5384673c661920d7a9d76cff` on Radeon integrated graphics and RTX 5090. **Tested** - Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, unoptimized profile. AMD Radeon(TM) Graphics driver 32.0.21042.62 and RTX 5090 driver 32.0.16.1742. SDK DXC/DXIL 1.8.2502.11. - `cargo test --locked -p xcl --lib qsad_and_mqsad -- --nocapture --test-threads=1` with `XCL_ADAPTER=AMD Radeon` and `XCL_ADAPTER=NVIDIA GeForce RTX 5090` in separate processes. Both gave 2 passed, 0 failed, 0 ignored and no skips. - Both translation paths passed the wave32 and logical wave64 GPU fixtures, including the three instructions, saturation and wrap cases, overlapping operands and the check that inactive lanes retain their original values. Operand-form and translation validation also passed. **Not tested** The separate HIP hardware capture, retail inputs, the parent and the full workspace suite. **AI use** OpenAI Codex (GPT-6.2 Sol) ran the checks and wrote this report.
luckyteagirl commented 2026-11-25 16:12:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T15:41:31Z.


Independent focused check of exact head c0eaeff7046ebb8e5384673c661920d7a9d76cff on Windows 11 build 26200, discrete AMD Radeon RX 6800M (driver 30.0.13002.13003), Rust 1.99 MSVC, DXC/DXIL 1.9.2609.5.

With XCL_ADAPTER=6800M and XCL_REQUIRE_GPU=wave64, cargo test --locked -p xcl --lib qsad_and_mqsad -- --test-threads=1 --show-output on the clean PR head gave 2 passed, 0 failed, 0 ignored, 0 explicit skips. The GPU fixture runs both HLSL/DXC and direct DXIL in wave32 and wave64, checking all three QSAD/MQSAD instructions, CLAMP and wrap results, overlapping operands, and EXEC-inactive lanes. The operand-form validation test also passed.

A temporary diagnostic print in the fixture confirmed AMD Radeon RX 6800M and native wave64: true; its run also passed 2/2. I restored that print and repeated the clean-head run above; the checkout is clean. The diagnostic only identified the device and wave capability, and is not part of the PR.

This adds a discrete RDNA2 and older driver to the author and other reviewers' checks. I did not perform a separate HIP hardware capture, full workspace suite, or retail-title smoke comparison for this PR.

AI use: OpenAI Codex (GPT-6) ran the checks and prepared this report.

<!-- greyfinch-sync:ivall/xcl:comment:7167232699 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2334#issuecomment-7167232699). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-25T15:41:31Z. --- Independent focused check of exact head `c0eaeff7046ebb8e5384673c661920d7a9d76cff` on Windows 11 build 26200, discrete AMD Radeon RX 6800M (driver `30.0.13002.13003`), Rust 1.99 MSVC, DXC/DXIL 1.9.2609.5. With `XCL_ADAPTER=6800M` and `XCL_REQUIRE_GPU=wave64`, `cargo test --locked -p xcl --lib qsad_and_mqsad -- --test-threads=1 --show-output` on the clean PR head gave **2 passed, 0 failed, 0 ignored, 0 explicit skips**. The GPU fixture runs both HLSL/DXC and direct DXIL in wave32 and wave64, checking all three QSAD/MQSAD instructions, CLAMP and wrap results, overlapping operands, and EXEC-inactive lanes. The operand-form validation test also passed. A temporary diagnostic print in the fixture confirmed `AMD Radeon RX 6800M` and `native wave64: true`; its run also passed 2/2. I restored that print and repeated the clean-head run above; the checkout is clean. The diagnostic only identified the device and wave capability, and is not part of the PR. This adds a discrete RDNA2 and older driver to the author and other reviewers' checks. I did not perform a separate HIP hardware capture, full workspace suite, or retail-title smoke comparison for this PR. **AI use:** OpenAI Codex (GPT-6) ran the checks and prepared this report.
DavidM1911 commented 2026-11-25 18:04:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T18:04:44Z.


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:7170407374 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2334#issuecomment-7170407374). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T18:04:44Z. --- 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!
upstream-sync closed this pull request 2026-11-25 19:08:16 +00:00
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!2324
No description provided.