Skip to content

Recompiler: emit wrapping packed 8-bit dot products in DXIL - #2108

Open
wasonidas wants to merge 1 commit into
xcl-dev:mainfrom
wasonidas:xcl/direct-packed-dot8-cbc296a
Open

wasonidas wants to merge 1 commit into
xcl-dev:mainfrom
wasonidas:xcl/direct-packed-dot8-cbc296a

Conversation

@wasonidas

@wasonidas wasonidas commented Nov 25, 2026 •

Copy link
Copy Markdown

Part of #1269. Emit DXIL dot4AddPacked for the three RDNA2 8-bit dot forms with wrapping accumulation. The saturating forms retain the wide sum clamped to the destination range.

What is in it

  • crates/xcl/src/gpu/dxil/lower_wide.rs and ops.rs emit the packed intrinsic. Tests check its call counts in normal and compact DXIL, along with wrapping, saturation and the tied accumulator on GPU.

Tested

  • Windows 11 build 26300, AMD Ryzen 7 9800X3D, RTX 5080 (32.0.16.2124), integrated Radeon (32.0.21042.62), Rust 1.100.0 MSVC and SDK DXC 1.9.2602.17. Debug builds and tests. Release translation measurements.
  • cargo build --workspace succeeded on main and the candidate. The exact patch tested was committed as 42ba73188bdb60afd222270c51187abe8fbef598 and rebuilt from that clean head.
  • cargo test -p xcl --lib packed_dot8_ -- --nocapture --test-threads=1 passed both new tests on each GPU with 0 failed, ignored or internally skipped. The emission test fails on main with the new tests applied. The existing gpu_packed_math_dots_movrel test also passed on each GPU with direct DXIL enabled.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture on RTX gave 1152 passed, 4 failed, 46 ignored and 27 internal skips. Integrated Radeon gave 1155 passed, 1 failed, 46 ignored and 10 internal skips. Main gave 1150/4/46 on RTX and 1153/1/46 on Radeon, with the same skips and identical fuzz failures (RTX seeds 70, 545, 1019 and 1507, Radeon seed 540). Internal skips are included in Cargo's passed totals and excluded from coverage.
  • A temporary Cargo diagnostic (cargo test -p xcl --lib --release packed_dot8_translation_diagnostic -- --nocapture --test-threads=1) passed in all eight runs. Across three synthetic 96-dot cases, emitted DXIL was 34.86–39.12% smaller and median translation time fell 37.47–40.07% (48 samples per case and tree).

Regression run

Official scripts/smoke.ps1, 60 s on RTX 5080 with direct DXIL enabled.

Main

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 5080
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1171 (PresentX 1171)
presents per 2 s (last 3): 41 41 42
device removals: 0
crashes: 0
peak commit: 14829 MB

PR head

xcl-smoke v1
commit: 42ba73188bdb60afd222270c51187abe8fbef598
gpu: NVIDIA GeForce RTX 5080
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1362 (PresentX 1362)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14507 MB

Not tested

  • Retail shader compilation and GPU execution performance, or whether the smoke title exercised these opcodes.

AI use

  • T3 Code / OpenAI Codex (gpt-6.2-sol) wrote the implementation and tests, ran validation and prepared this draft. T3 Code / OpenAI Codex (gpt-6.1-sol) independently reran the base and candidate GPU suites.

Use the native DXIL dot4AddPacked operation for wrapping signed and unsigned products, including the tied accumulator. Keep the existing wide sum for saturating forms. Synthetic mixed kernels emitted 34.86-39.12% less DXIL.

Part of xcl-dev#1269.

Assisted-by: T3 Code / OpenAI Codex (gpt-6.2-sol)
@Parakeet-Wheat

Copy link
Copy Markdown

NVIDIA RTX 3070 on native Windows, head 42ba731 on its base cbc296a: the emission test fails without the change and passes with it, the GPU test passes on both, the whole suite passes, and the smoke pair is within the limits.

Tested

  • NVIDIA GeForce RTX 3070 8 GB (driver 610.88, 32-lane waves), Ryzen 5 5600X, 32 GB, Windows 11 26300, Rust 1.95.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11, retail 1.0.2.1. Head 42ba731 (one commit on main cbc296a), checked out clean. Tests in the debug profile, smoke in release.
  • cargo test -p xcl --lib packed_dot_tests -- --nocapture --test-threads=1:
    • on cbc296a with the PR's lower_wide.rs but its two lower_wide.rs hunks above the test module (the v_dot4* arms) reverted: 1 failed, 1 passed. packed_dot8_emits_intrinsics_for_wrapping_forms fails with left: 0, right: 2 (no dot4AddPacked call with opcode 163). packed_dot8_matches_wrapping_and_saturating_cpu_results_on_gpu passes there too, not skipped: the old lowering gives the same results on this card, so only the emission test tells the two apart;
    • on 42ba731: 2 passed, 0 failed, none skipped.
  • .\scripts\test.ps1 (cargo build --workspace, then cargo test --workspace -- --test-threads=4) on 42ba731: 1156 passed, 0 failed, 46 ignored, exit 0. SKIPPED, 25: 20 × no wave64, 3 × per-lane form refused (V_CVT_F16_F32, V_PK_MUL_F16, V_MUL_F16: "its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's"), 1 × no heap windows, 1 × cannot disable the driver cache (Windows Developer Mode required). The four fuzz_validate_and_gpu_* failures that the PR text lists on its RTX 5080 do not occur on this card.

Regression run (scripts/smoke.ps1 -Game <folder> -Seconds 60, the same title, back to back, menus, no input; unedited). main cbc296a:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 3070
title: 3d7db37d
seconds: 60
exit: 0x0
frames shown: 1485 (PresentX 1485)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18017 MB

PR head 42ba731:

xcl-smoke v1
commit: 42ba73188bdb60afd222270c51187abe8fbef598
gpu: NVIDIA GeForce RTX 3070
title: 3d7db37d
seconds: 60
exit: 0x0
frames shown: 1521 (PresentX 1521)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17959 MB

That is 102 % of main's frames and 100 % of its peak commit.

Not tested

  • The release translation measurements in the PR text, AMD, native wave64 (the 20 no wave64 skips above), a world run (the smoke stays in the menus, so it does not show whether the title reaches a v_dot4 instruction), the tests on game data (XCL_SAMPLE_* not set).
  • The PR's "PR description" check is red; I did not look into it.

AI use

  • Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report. The account owner has not reviewed it.

@JJAutoCompare

Copy link
Copy Markdown

Tested

PR #2108 was open at 42ba73188bdb60afd222270c51187abe8fbef598. The reused worktree was clean and detached at that SHA before and after the run. The PR discussion contained no prior same-head Arc report.

STOR-WINLAB ran Windows 11 Enterprise Evaluation 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust and Cargo 1.100.0 MSVC x64, and DXC/DXIL 1.9.2609.5. The unoptimized build used two Cargo jobs with incremental compilation and debug info disabled.

cargo test --locked -p xcl --lib --no-run
$exe = 'L:/XclTooling/pr2008-dc0d25fe/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe'
& $exe gpu::dxil::lower_wide::packed_dot_tests::packed_dot8_emits_intrinsics_for_wrapping_forms --exact --nocapture --test-threads=1
$env:XCL_ADAPTER = 'A770'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & $exe gpu::dxil::lower_wide::packed_dot_tests::packed_dot8_matches_wrapping_and_saturating_cpu_results_on_gpu --exact --nocapture --test-threads=1
}
  • CPU/DXC, 0.03 s. Normal and compact DXIL each contained two signed and one unsigned dot4AddPacked calls. The fixture used no GPU. It and the prebuild ran outside the mutex.
  • Arc A770, 0.67 s. Direct DXIL matched all 320 CPU-reference assertions across 64 logical lanes. Each lane checked signed and unsigned wrapping, the tied accumulator, and signed and unsigned saturation.

Build and both fixtures exited 0. Each exact filter excluded 1,125 tests. Combined 2 passed, 0 failed, 0 ignored, 0 skipped. The GPU log confirms mutex release.

Not tested

Other fixtures and adapters, the workspace suite, retail smoke, negative controls, and release timing.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixtures and wrote this report.

@JoaoPauluu

Copy link
Copy Markdown

A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, not the native-Windows path: this PR's 2 new tests pass, none skipped.

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, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. 42ba731 as it is (merge base with main cbc296a), no uncommitted changes. The lib test binary runs under Wine, one test per process.
    • packed_dot8_emits_intrinsics_for_wrapping_forms: ok
    • packed_dot8_matches_wrapping_and_saturating_cpu_results_on_gpu: ok

Not tested

  • the whole suite on this head, a retail title, native Windows, AMD.

AI use

  • Claude Code (Claude Opus 5.5) built the commit, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@luckyteagirl

Copy link
Copy Markdown

RX 6800M check on exact PR head 42ba73188bdb60afd222270c51187abe8fbef598 (clean detached worktree).

Tested: Windows 11 build 26200, Ryzen 9 5980HX, AMD Radeon RX 6800M (RDNA2), driver 30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. Debug profile, XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=1, XCL_DIRECT_DXIL=1, single test thread.

  • cargo test --locked -p xcl --lib -j 2 packed_dot8_ -- --test-threads=1 --show-output: emission test passed; the new GPU result test failed at runner::run / CreateComputePipelineState with device suspension 0x887A0005 (1 passed, 1 failed, 0 ignored, no skips). An isolated rerun of the GPU result test failed at the same call.
  • The existing gpu_packed_math_dots_movrel test passed on this same head and adapter (1 passed, 0 failed).
  • Control: In a separate uncommitted copy of this exact head, I restored only the three v_dot4* lowering arms in lower_wide.rs to base 6987e496 while retaining both new tests and ops.rs. The emission test then failed as expected with 0 dot4AddPacked calls versus 2 expected. The new GPU result test still failed with the same 0x887A0005 pipeline/device error. This shows the new intrinsic is not required to reproduce this fixture failure on this driver; it does not establish the underlying cause.

I did not measure output values because the pipeline was never created. I did not test another driver or adapter, a full workspace suite on this head, or a retail title. The temporary control was not pushed or proposed as a fix.

AI use: OpenAI Codex (GPT-6, exact variant not exposed in this session) ran the tests, prepared the isolated old-lowering control, reviewed the diff, and drafted this report.

@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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants