Repository navigation
Recompiler: translate v_trig_preop_f64 in both backends - #2315
NWProgramming00 wants to merge 1 commit into
Conversation
|
RDNA3 confirmation: the new f64 trig translation is bit-exact on gfx1100 too. The fix is calibrated against gfx1036 hardware measurements; here it is on RDNA3 (RX 7900 XT, NAVI31) under RADV, which the PR does not list as tested. Tested:
Not tested: Windows on this card; gfx103x native Linux (native target, not Wine). AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Diff review, CI, and both AMD and NVIDIA checks passed on |
…cl-dev#2315) LATER shared semantics: the measured 2/pi fraction table (TRIG_PREOP_2_OVER_PI, b1200..b17) lands verbatim in recomp/emit.rs + the 64-row gfx1036 TRIG_PREOP_RDNA2 vector set in recomp/tests.rs, for the future SPIR-V port (exact integer construction from the table + shift formula). HLSL/DXIL lowering + GPU/omod tests stay out.
Both backends refused v_trig_preop_f64. This follows the RDNA2 ISA pseudocode with the table measured on an RDNA2 gfx1036: the 53 bits of 2/pi that start S1[4:0] * 53 bits (plus exp(S0) - 1077 past 1077) below b1200, times 2^(-53 - shift), plus 2^128 when exp(S0) >= 1968. The hardware's table ends at b17. The product is then always exact, so the double is built from integers. The HLSL backend reads a 37-word table that it declares only when the instruction is used. Direct DXIL selects the words. An output modifier is refused; it was not measured. gpu_trig_preop_f64_matches_rdna2 checks both backends against 64 rows measured on the gfx1036. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44455fe to
a2d9c47
Compare
|
@raylitebull rebased as asked. The new head is
The description has the numbers. |
|
Independent desktop NVIDIA verification of PR #2315 at rebased head Environment
Targeted release tests & build (
|
| Command | Result |
|---|---|
cargo test --release -p xcl --lib trig_preop_f64_with_omod_is_refused -- --nocapture |
1 passed; 0 failed; 0 ignored; 1343 filtered out (0.00s) |
cargo test --release -p xcl --lib gpu_trig_preop_f64_matches_rdna2 -- --nocapture (3 consecutive runs, on-GPU RTX 4060 across both HLSL and direct DXIL backends) |
1 passed; 0 failed; 0 ignored; 1343 filtered out × 3 (0.26s, 0.22s, 0.22s) |
cargo test --release -p xcl --lib gpu::dxil:: |
184 passed; 0 failed; 3 ignored; 1157 filtered out (3.79s; dispatch_chain_native_wave64_builds_whole self-skipped on Wave32-only RTX 4060) |
cargo test --release -p xcl --lib gpu::recomp:: |
403 passed; 0 failed; 20 ignored; 921 filtered out (5.27s; Wave64-only and #1426-refused subcases self-skipped as expected) |
cargo build --release -p xcl --bin xcl |
Clean build (1m 14s, exit 0) |
Paired quiet 60 s retail smoke (title: 29640639)
Exact parent & merge-base (e120925e3abc9956a8b9bae631969d32e8ccd43c, cached baseline on the same machine):
xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1602 (PresentX 1602)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13979 MB
PR #2315 (a2d9c470554cf43ad412af89a5b7c53812ebe4dc):
xcl-smoke v1
commit: a2d9c470554cf43ad412af89a5b7c53812ebe4dc
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1579 (PresentX 1579)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14021 MB
Runtime log observations (xcl.log)
9222log lines,0[ERROR]/ device-removal / panic lines.- Final draw/memory telemetry in log:
19474 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14020 MB committed by the process; video memory 6114 MB local, 4683 MB non-local.
Limits of coverage
gpu_trig_preop_f64_matches_rdna2executed directly on the RTX 4060 GPU across both the HLSL and direct DXIL backends (3/3 passes against all 64 RDNA2 gfx1036 reference rows), andtrig_preop_f64_with_omod_is_refusedverified refusal of output modifiers.- Wave64-only GPU subcases in
gpu::dxil::andgpu::recomp::self-skipped on the Wave32-only RTX 4060, and the existing#[ignore]dump/fuzz/benchmark tests remained ignored. - The 60 s retail smoke on
title: 29640639serves as an end-to-end non-regression check and was not confirmed to execute a retail shader containingv_trig_preop_f64.
AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Both backends refused
v_trig_preop_f64. This translates it as RDNA2 hardware runs it. I measured the hardware first, then checked xcl against it bit for bit.What the hardware does (gfx1036, 2,072 measured rows, MODE with f64 denormals kept)
shiftbits below b1200, times 2^(−53 − shift).shift = S1[4:0] × 53, plusexp(S0) − 1077when the S0 exponent is above 1077.What is in it
crates/xcl/src/gpu/recomp/emit.rs:trig_preop()helper and the 37-word table (TRIG_PREOP_2_OVER_PI);crates/xcl/src/gpu/dxil/lower_wide.rs: the same computation in the direct DXIL translator. It reads the table with a chain of selects, because that translator has no constant arrays.crates/xcl/src/gpu/dxil/lower.rsandemit.rs:v_trig_preop_f64leaves the list of f64 ops that follow the f64 round mode (it does not round).OMOD/CLAMP) is refused, because I did not measure it.crates/xcl/src/gpu/recomp/tests.rs:gpu_trig_preop_f64_matches_rdna2checks both backends against 64 rows measured on the gfx1036.trig_preop_f64_with_omod_is_refusedchecks the OMOD refusal in both backends.Tested
XCL_ADAPTER=radeon). Rust 1.100 MSVC, release.cargo build --release --workspace, thencargo test --release --workspace --no-fail-fast -- --test-threads=4, with and withoutXCL_DIRECT_DXIL=all, on this change rebased ontomain8b957be(9a608a4), against that base on the same machine:8b957be9a608a4)XCL_DIRECT_DXIL=allXCL_DIRECT_DXIL=allThe +2 are the new tests, which pass in all four rows. The failing tests are the same on base and PR, and both are tracked:
fuzz_validate_and_gpu_0..3on NVIDIA (#1905) andfuzz_validate_and_gpu_1on RDNA2 (#2115, #2170).Regression run
Base (
maine120925), NVIDIA GeForce RTX 5070 Ti:This PR (
a2d9c47), same card:e120925: this head sits one120925, themaincommit just before xcl run: prepare shaders in the game window before title execution #2555.main8b957be, this head gives the same tree as the commit the suite above ran on (9a608a4, tree5f5b6a7).main805 frames, this PR 593, both exit 0x0, 0 crashes.mainalone (805, then 649).v_trig_preop_f64, and both have the same 41 refusals. The title does not reach this instruction in these 60 s, so the 60 s runs check only that nothing else changed.Not tested
OMOD/CLAMPon this instruction (refused).AI use
🤖 Generated with Claude Code