Skip to content

Recompiler: translate v_mullit_f32 and v_cvt_off_f32_i4 as RDNA2 runs them - #2241

Open
NWProgramming00 wants to merge 1 commit into
xcl-dev:mainfrom
NWProgramming00:recomp/mullit-cvt-off
Open

NWProgramming00 wants to merge 1 commit into
xcl-dev:mainfrom
NWProgramming00:recomp/mullit-cvt-off

Conversation

@NWProgramming00

@NWProgramming00 NWProgramming00 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Both backends refused v_mullit_f32 (VOP3) and v_cvt_off_f32_i4 (VOP1). This translates both as RDNA2 hardware runs them. I measured the hardware first, because the ISA text for v_mullit_f32 does not spell out its special cases.

Measured on an RDNA2 gfx1036 (2,656 input rows: 18 special S0 / S1 values × 8 S2 values, plus 64 cvt_off inputs with high bits set):

  • v_cvt_off_f32_i4: bits 3:0 are a signed 4-bit number in sixteenths (1 → 0.0625, 8 → -0.5, 15 → -0.0625). Bits 31:4 are ignored.
  • v_mullit_f32:
    • The result is -MAX_FLOAT (0xff7fffff) when S2 is not above +0 (that is, +0, -0, negative or NaN), or when S1 is -MAX_FLOAT, -inf or NaN.
    • Otherwise it is S0 × S1 with 0 × anything = +0, as v_mul_legacy_f32. For example, 0 × +inf = +0 and 0 × -1 = +0.
    • A NaN in S0 comes out as that NaN, quieted.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: both instructions, plus a mullit() helper in the HLSL prelude. It decides on the operand bits, so no float compare can be folded away.
  • crates/xcl/src/gpu/dxil/lower_valu.rs: the same rule in the direct DXIL translator.
  • crates/xcl/src/gpu/recomp/tests.rs: gpu_mullit_and_cvt_off_match_rdna2 runs both backends (HLSL + DXC, and direct DXIL) and checks them against hardware values:
    • 41 v_mullit_f32 rows: every special S1 with a positive S2, every S2, every non-NaN S0, and the zero products;
    • 64 v_cvt_off_f32_i4 inputs.
    • Rows with a NaN S0 are left out, because NaN payload bits differ between hosts. Rows with a denormal operand or result are left out too, because the kernel's default float mode flushes them.

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.
  • All 2,656 measured rows through xcl's kernel path on each adapter, in both backends, compared with the gfx1036's results:
    • v_cvt_off_f32_i4: 2656/2656 equal everywhere.
    • v_mullit_f32: 2458 equal on the RTX 5070 Ti and 2488 on the Radeon, in each backend. Every other row is either a NaN result that differs only in payload bits (60 / 30) or a row with a denormal (138). No other difference.
  • The new test passes on both adapters. It fails with each of six deliberate mistakes:
    • the -inf check dropped (HLSL, and separately direct DXIL);
    • the -MAX_FLOAT check dropped (HLSL);
    • the NaN check dropped (direct DXIL);
    • the S2 rule changed to S2 < 0 only (HLSL);
    • the cvt_off scale changed (direct DXIL).
  • 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 568e7db on the same machine:
Adapter Mode base 568e7db this PR (d7df3f9)
RTX 5070 Ti default 1150 passed, 4 failed, 46 ignored 1151 passed, 4 failed, 46 ignored
RTX 5070 Ti XCL_DIRECT_DXIL=all 1148 passed, 6 failed 1149 passed, 6 failed
Radeon gfx1036 default 1153 passed, 1 failed 1154 passed, 1 failed
Radeon gfx1036 XCL_DIRECT_DXIL=all 1151 passed, 3 failed 1152 passed, 3 failed

The +1 is the new test. The failing tests are the same on base and PR, and all are tracked: fuzz_validate_and_gpu_0..3 on NVIDIA (#1905), fuzz_validate_and_gpu_1 seed 540 on RDNA2 (#2115, #2170), gpu_image_get_resinfo_1d_array with direct DXIL (#2046) and 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 (d7df3f9), same card:

xcl-smoke v1
commit: d7df3f9faed0ef34c495d45ae0261b91e9c6f7f8
gpu: NVIDIA GeForce RTX 5070 Ti
title: title-a
seconds: 60
exit: 0x0
frames shown: 856 (PresentX 857)
presents per 2 s (last 3): 1 23 29
device removals: 0
crashes: 0
peak commit: 15691 MB

Earlier runs here ended at about 44 s on main and on this PR alike. The cause was #695: this PC had no active playback device. With one active, both runs reach their end.

Not tested

  • A denormal S0 / S1 / S2 under a program's float mode that keeps denormals (the test keeps the default mode).
  • v_mullit_f32 in a program that sets a non-default f32 rounding mode. The rounding-mode path (valu_f32_rm) does not cover it, so it rounds to nearest.
  • RDNA3 / RDNA4, Intel, and whether a retail program uses either instruction.

AI use

  • Claude Code (Claude Opus 5.5) did the work: it measured the hardware, wrote both lowerings and the test, ran the comparisons, the mutation checks and the suites, and wrote this description.

🤖 Generated with Claude Code

… them

Both instructions were refused by both backends. Their behaviour was
measured on an RDNA2 gfx1036 (2,656 rows):

- v_cvt_off_f32_i4: bits 3:0 as a signed 4-bit number in sixteenths
  (-0.5 .. 0.4375); bits 31:4 are ignored.
- v_mullit_f32: -MAX_FLOAT when S2 is not above +0 (-0, negative or NaN)
  or S1 is -MAX_FLOAT, -inf or NaN; otherwise S0 * S1 with 0 * anything
  = +0 (as v_mul_legacy_f32).

The HLSL path gets a `mullit` prelude helper, the direct DXIL path the
same rule on the operand bits. gpu_mullit_and_cvt_off_match_rdna2 checks
both backends against hardware values (rows with a NaN S0 or a denormal
left out).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GustavoEllwanger

Copy link
Copy Markdown
Contributor

Independent dual-GPU Windows verification on exact PR head d7df3f9faed0ef34c495d45ae0261b91e9c6f7f8 (parent 568e7db), testing both HLSL (XCL_DIRECT_DXIL=0) and direct DXIL (XCL_DIRECT_DXIL=1) on AMD RDNA2 and NVIDIA Blackwell.

Tested

  • Host / toolchain: AMD Ryzen 7 7700, Windows 11, Rust 1.95.0 (59807616e 2026-04-14), DXC 1.8.2502.11, debug build.
  • AMD Radeon(TM) Graphics (RDNA2 iGPU, driver 32.0.21042.62, native wave64):
    • XCL_ADAPTER=Radeon XCL_DIRECT_DXIL=0 cargo test -p xcl --lib gpu::recomp::tests::gpu_mullit_and_cvt_off_match_rdna2 -- --nocapture: 1 passed, 0 failed, 0 ignored (0 skipped).
    • XCL_ADAPTER=Radeon XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu::recomp::tests::gpu_mullit_and_cvt_off_match_rdna2 -- --nocapture: 1 passed, 0 failed, 0 ignored (0 skipped).
  • NVIDIA GeForce RTX 5060 (Blackwell, driver 32.0.16.1088, wave32 / split-wave64):
    • XCL_ADAPTER=5060 XCL_DIRECT_DXIL=0 cargo test -p xcl --lib gpu::recomp::tests::gpu_mullit_and_cvt_off_match_rdna2 -- --nocapture: 1 passed, 0 failed, 0 ignored (0 skipped).
    • XCL_ADAPTER=5060 XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu::recomp::tests::gpu_mullit_and_cvt_off_match_rdna2 -- --nocapture: 1 passed, 0 failed, 0 ignored (0 skipped).
    • XCL_ADAPTER=5060 cargo test -p xcl --lib gpu::recomp::tests:: -- --test-threads=4: 148 passed, 0 failed, 17 ignored (2 runtime SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware — no wave64).
    • XCL_ADAPTER=5060 cargo test -p xcl --lib gpu::dxil:: -- --test-threads=4: 122 passed, 0 failed, 3 ignored (0 skipped).

Not tested

  • Retail title run (scripts/smoke.ps1), full workspace run, Intel GPUs, non-Windows hosts.

AI use

  • Antigravity (Google Gemini): checked out PR head d7df3f9, ran gpu_mullit_and_cvt_off_match_rdna2 across HLSL and direct DXIL on both GPUs plus gpu::recomp::tests:: and gpu::dxil:: on RTX 5060, and drafted this comment from the raw logs.

@NWProgramming00
NWProgramming00 marked this pull request as ready for review November 25, 2026 14:19
@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head d7df3f9faed0ef34c495d45ae0261b91e9c6f7f8 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1153 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • The PR's GPU test passed (no skips): gpu::recomp::tests::gpu_mullit_and_cvt_off_match_rdna2.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: d7df3f9faed0ef34c495d45ae0261b91e9c6f7f8
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1494 (PresentX 1494)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15073 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • Wave32-only GPUs (NVIDIA/Intel); D3D12 debug layer.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…ort upstream xcl-dev#2241)

LATER shared semantics: the measured gfx1036 hardware tables
(MULLIT_RDNA2 41 rows, CVT_OFF_RDNA2 64 rows) land verbatim in
recomp/tests.rs for the future SPIR-V lowering to rebuild the
select-tree from. The HLSL/DXIL emit halves + the GPU test stay out
until a backend consumes them.
@NWProgramming00

Copy link
Copy Markdown
Contributor Author

The failed "Build and test" run (2026-11-25 18:31) is not from this PR. It ran on the merge ref while main was mid-churn, and its two failures are tests this PR does not touch:

  • gpu::recomp::pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator
  • hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa

Checked today on Windows 11 with an RTX 5070 Ti, release. I merged d7df3f9 into current main 8b957be; the merge was clean.

Could a maintainer re-run the job? I left the head as it is, so the independent reports on d7df3f9 still apply.

AI use: Claude Code (Claude Opus 5.5) ran the merge and the tests and wrote this.

@JJAutoCompare

Copy link
Copy Markdown

Tested: Clean d7df3f9faed0ef34c495d45ae0261b91e9c6f7f8, Windows 11 build 26200, Ryzen 7 3800X, Rust 1.100.0 MSVC, debug, Intel Arc A770 driver 32.0.101.9175, DXC 1.9.2602.17. cargo test --locked -j 2 -p xcl --lib --no-run, then the built test with gpu::recomp::tests::gpu_mullit_and_cvt_off_match_rdna2 --exact --nocapture --test-threads=1. With XCL_ADAPTER=A770, 1 passed, 0 failed, 0 ignored, 0 skips. HLSL/DXC and direct DXIL both matched all 64 v_mullit_f32 and 64 v_cvt_off_f32_i4 results bit for bit against the checked-in gfx1036 expectations. Both ran split wave64.

Not tested: Native wave64 arithmetic, full workspace suite, and retail smoke.

AI use: T3 Code / Codex (gpt-6.2-sol) ran and independently reran the checks and drafted this report.

@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA verification of PR #2241 at head d7df3f9faed0ef34c495d45ae0261b91e9c6f7f8 (1 commit; exact parent & merge-base: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, Wave32-only Ada), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (d7df3f9f)

Command Result
cargo test --release -p xcl --lib gpu_mullit_and_cvt_off_match_rdna2 -- --nocapture (3 consecutive runs) 1 passed; 0 failed; 0 ignored; 1124 filtered out × 3 (0.24s, 0.21s, 0.21s, 0 skipped; live RTX 4060 execution checking both HLSL and direct-DXIL backends)
cargo test --release -p xcl --lib gpu::dxil:: -- --test-threads=4 (3 consecutive runs) 122 passed; 0 failed; 3 ignored; 1000 filtered out × 3 (3.07s, 3.06s, 3.08s, 0 skipped)
cargo build --release -p xcl Clean build (1m 02s, exit 0, 0 new warnings)

Paired quiet 60 s retail smoke (title: 29640639)

Exact parent & merge-base (568e7db7729c8fa6c8f0f4b32d798faaf11462bb, same machine):

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1587 (PresentX 1587)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14527 MB

PR #2241 (d7df3f9faed0ef34c495d45ae0261b91e9c6f7f8):

xcl-smoke v1
commit: d7df3f9faed0ef34c495d45ae0261b91e9c6f7f8
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1569 (PresentX 1569)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14537 MB

Limits of coverage

  • Both HLSL and direct-DXIL lowerings of v_mullit_f32 and v_cvt_off_f32_i4 were directly verified on desktop RTX 4060 via gpu_mullit_and_cvt_off_match_rdna2 (3/3, 0 skipped) and gpu::dxil:: (122/122 × 3); as noted by the author, rows with a NaN S0 or denormals are omitted from that fixture.
  • The 60 s retail smoke confirms zero runtime regression on title: 29640639 (single-run frame/commit delta vs. parent reflects normal startup variance, not this PR).

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

@SzczepanGrela

Copy link
Copy Markdown

RX 9070 / RADV / Wine verification of exact head d7df3f9faed0ef34c495d45ae0261b91e9c6f7f8, current main c2ee10e4e905eb736e56953c52b749e18bcc7ede and the PR automatically applied to that main. This adds special-value and NaN-class coverage through both backends on this stack.

Tested

  • RX 9070 16 GB, RADV GFX1201 / Mesa 26.3.1-arch3.5, Ryzen 7 7700, CachyOS 7.3.0-5-cachyos. Windows GNU release executables, Rust 1.97.1, GE-Proton11-12 / Wine 11.0 Staging, native DXGI/D3D12 through vkd3d-proton 8293130ebe370b1+ (local asserts-disabled build), DXC/DXIL 1.9.2602.17.
  • Separate source copies; conflict-free integration of the three-file delta from actual parent 568e7db7729c8fa6c8f0f4b32d798faaf11462bb. Test-only translation/container/readback captures and owned fixtures. Production code, original tables and assertions preserved; main gets the identical original test and tables.
  • Build each: cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run --message-format=json-render-diagnostics.
  • Original filter through Wine: <unit.exe> gpu_mullit_and_cvt_off_match_rdna2 --nocapture --test-threads=1, then --test-threads=4.
Source Threads 1 Threads 4
Main + identical test 0 passed, 1 failed 0 passed, 1 failed
Exact head 1 passed, 0 failed 1 passed, 0 failed
Current-main integration 1 passed, 0 failed 1 passed, 0 failed

Main fails the HLSL translation assertion before GPU execution, recording both instructions as unsupported. Head/integration execute both original backends in native wave64; all 64 lane results for each instruction match the checked-in goldens and an independent recomputation.

Additional owned filter <unit.exe> workflow_special_value_matrix --nocapture --test-threads=1, three fresh processes per source. Head/integration: 1 passed, 0 failed in all six runs. Each runs HLSL/DXC and direct DXIL separately in native wave32, native wave64 and split wave64:

  • V_MULLIT_F32: 24 × 24 × 13 = 7,488 triples per configuration. S0/S1 include signed zeros, signed finite values from 2^-16 through 2^16, signed max-finite, infinities, and positive/negative signaling and quiet NaNs. S2 includes zeros, positive/negative finite values, infinities and both NaN classes.
  • V_CVT_OFF_F32_I4: 16 independent inputs per lane row, 119,808 conversions per configuration. These include all 65,536 low-word patterns with mixed upper-word tags. Results match the signed low nibble divided by 16, bit-for-bit.

Across the six GPU matrix runs: 269,568 mullit outputs and 4,313,088 conversion outputs agree with the reference. This includes 11,520 quiet-NaN class checks. NaN payload bits are archived but are not an assertion: finite/infinite results and signed-zero behavior are checked exactly, while NaN results require the IEEE NaN class and quiet bit.

The finite multiplication oracle independently multiplies the binary32 integer significands and performs exact round-to-nearest-even. No denormal inputs or products are included. The full input cross-product checks the S1/S2 sentinel rules, including their priority over legacy zero multiplication. Raw captures repeat identically within each source; head and current-main integration agree after normalizing only NaN payloads for comparison.

Main's additional filter passes explicit CPU translation-refusal controls in all three modes for both backends: 0 matrix GPU dispatches. It does not claim GPU support for those instructions.

Across original and owned groups: 5,636 captured GPU dispatches, including 12 physical-width probes and 1,418 physical native-wave64 dispatches. Independently verified 19,152,368 words, including result/input registers, inactive physical lanes, 16 SGPR and 16 VGPR guards, unchanged SCC and complete memory readbacks. Programs were independently re-encoded from the public ISA tables; shader metadata and physical widths agree. 0 ignored, 0 skipped, no device-removal markers.

Inherited XCL_* cleared; XCL_NETWORK=0, RX 9070 selected, XCL_REQUIRE_GPU=wave64, XCL_DXC_THREADS=1; private enabled caches per process. Both original and owned tests explicitly select their translation paths.

Not tested

Denormal operands/results, non-default f32 rounding modes, packed/source modifiers, raw RDNA4 ISA measurements, graphics-stage or guest Compute ABI execution, full suite, native Windows, other GPUs, retail workload, scripts/smoke.ps1, timing or FPS. The special-value reference follows the stated RDNA2 contract.

AI use

OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, wrote the owned test-only matrix and captures, ran comparisons, independently verified IEEE multiplication/rounding, NaN classes, nibble conversion, guards, wave widths and source/executable provenance, and drafted this report. Publication authorized by the account owner.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants