Skip to content

Recompiler: saturate packed unsigned dot8 without i64 - #2221

Open
luckyteagirl wants to merge 2 commits into
xcl-dev:mainfrom
luckyteagirl:codex/dot8-clamp-32
Open

luckyteagirl wants to merge 2 commits into
xcl-dev:mainfrom
luckyteagirl:codex/dot8-clamp-32

Conversation

@luckyteagirl

@luckyteagirl luckyteagirl commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1269. This is stacked on #2173: rebased parent commit 5ca41eb retains Normal1919's authorship; this PR's change is 404cde36a101d3502504f679db7e6528b08dc19a. Both commits are rebased onto main 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6 so CI can run. The latest conflicts in crates/xcl/src/gpu/dxil/core_tests.rs and crates/xcl/src/gpu/recomp/tests.rs were test additions; all tests are retained.

On the RX 6800M, the previous clamped v_dot8_u32_u4 direct-DXIL path suspended the device at compute PSO creation, while #2173's unclamped path ran in isolation. The eight unsigned nibble products sum to at most 1,800, so the clamped form can accumulate them in 32 bits and saturate the addition to the accumulator without the old 64-bit sum.

What changed

  • crates/xcl/src/gpu/dxil/lower_wide.rs: use packed dot calls for clamped and unclamped unsigned dot8; for clamped, add the bounded product sum to c and select u32::MAX on unsigned overflow.
  • crates/xcl/src/gpu/recomp/tests.rs: add an isolated clamped GPU regression for zero, exact maximum, and overflow. core_tests.rs expects the clamped form to emit the packed calls.

Tested

  • Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver 30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. cargo build --locked --workspace -j 2 and cargo build --locked --release --workspace -j 2 passed on the clean head. git diff --check passed.
  • With XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=wave64, cargo test --locked -p xcl --lib -j 2 dot8_u32_u4 -- --test-threads=1 --show-output passed 3/0/0, no skips, for XCL_DIRECT_DXIL=1; the same filter passed 3/0/0, no skips, for XCL_DIRECT_DXIL=0. The GPU fixtures cover native wave64 and wave32; the third test checks emitted DXIL.
  • Full workspace suite, cargo test --locked --workspace --no-fail-fast -j 2 -- --test-threads=4 --show-output, with XCL_ADAPTER=6800M, XCL_DIRECT_DXIL=1: current main 1a0bbe3 had 1012 passed, 169 failed, 26 ignored in the library; this head had 1013 passed, 172 failed, 26 ignored. Both also failed the same offline_compute_pipeline_is_reused_by_a_second_process integration test. Isolated Cargo targets were used. Three library failure names were added: the parent's dot4_add_u8_packed_matches_cpu and the two dot8 GPU fixtures. All three failed at CreateComputePipelineState after device suspension 0x887A0005, while the dot8 fixtures passed in the focused runs. This broad run is not green on this driver.
  • Before the original code change, the new clamped-only fixture failed at CreateComputePipelineState on this RX 6800M. With local test-only isolation, the old clamped shader failed and DXIL: lower unclamped v_dot8_u32_u4 using Dot4AddU8Packed #2173's unclamped shader passed both wave sizes. Those diagnostic edits were restored before the PR was published.

Regression run

Same owned title, 12 seconds each, default translation mode, separate data/cache directories. Both completed without the external memory guard firing. The title run did not show a dot8 dispatch, so the focused GPU fixture is the direct opcode check.

Main:

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 12
exit: 0x0
frames shown: 104 (PresentX 104)
presents per 2 s (last 3): 1 43 60
device removals: 0
crashes: 0
peak commit: 8185 MB

This PR:

xcl-smoke v1
commit: 404cde36a101d3502504f679db7e6528b08dc19a
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 12
exit: 0x0
frames shown: 119 (PresentX 119)
presents per 2 s (last 3): 0 58 60
device removals: 0
crashes: 0
peak commit: 8204 MB

Not tested

  • NVIDIA/other-vendor GPU verification on this rebased head is still requested by the reviewer. Parent DXIL: lower unclamped v_dot8_u32_u4 using Dot4AddU8Packed #2173 had RX 9070 XT, RX 6800M, RTX 3060 and RTX 3060 Ti reports on its earlier head, but they do not verify this new head. No runtime performance benefit is claimed.

AI use

OpenAI Codex (GPT-6; exact variant not exposed in this session) investigated the RX 6800M failure, wrote the 32-bit clamp and regression test, rebased both commits while preserving the parent author's attribution, ran the native Windows builds, GPU tests, workspace comparison and guarded smoke run, and drafted this description. No game data was committed.

@luckyteagirl
luckyteagirl marked this pull request as ready for review November 25, 2026 10:19
@raylitebull

Copy link
Copy Markdown
Member

4830018 currently conflicts in tests.rs against recent main merges. Please rebase onto main (and add dual-vendor GPU test runs on the rebased head) before CI runs.

O5-7 and others added 2 commits November 25, 2026 03:52
Add Shader::dot4_add_u8_packed (dx.op.dot4AddPacked, opcode 164) and
lower unclamped v_dot8_u32_u4 by splitting even and odd 4-bit nibbles
into two packed byte quads and chaining two Dot4AddU8Packed calls.
Leave clamped v_dot8_u32_u4 on the 64-bit saturating dot_n path.

Part of xcl-dev#1269

Assisted-by: Antigravity (Gemini 4 Neon)
The unsigned four-bit dot products total at most 1800. The clamped path can accumulate that bounded sum with Dot4AddU8Packed and saturate c + sum using a 32-bit carry check. This avoids the old wide-sum DXIL that suspends the RX 6800M device in the focused GPU fixture. Add an isolated clamped overflow regression alongside the existing combined edge cases.
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.

3 participants