Recompiler: translate f64 division ops (v_div_scale/fmas/fixup_f64) #823
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!823
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-823"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@mastrr9 on GitHub · 2026-11-24 06:07 UTC · original
mastrr9:feat/recomp-div-f64→main· +145 −0 · 2 files · 1 commits · openv_div_scale_f64,v_div_fmas_f64, andv_div_fixup_f64were previously reported unsupported, leaving shaders that emit LLVM'sfdiv doublesequence untranslated.What is in it
crates/xcl/src/gpu/recomp/emit.rs:v_div_scale_f64passessrc0through unscaled and setsSDST(VCC) tofalse(matchingv_div_scale_f32).v_div_fmas_f64emitsfma(a, b, c)(since scale carry is 0).v_div_fixup_f64emitsdiv_fixup_d(q, d, n)(placed afterldexp_dinPRELUDE): handles IEEE 754 special cases on the bits, usesqdirectly with the quotient sign in the safe normal range (e_n >= 55,3 <= e_d <= 2042,3 <= e_q <= 2045), and falls back todiv_d(n, d)(precisemantissa division + single-rounded denormal scaling) where scaling matters.crates/xcl/src/gpu/recomp/tests.rs:div_f64_translates(HLSL + DXC check) andgpu_div_f64(full LLVM f64 division sequence verified bit-for-bit against CPU IEEE division across 512+ special, denormal, extreme-exponent, and random pairs).Tested
617.42/32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), D3D12 debug layer installed (d3d12SDKLayers.dll),rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC from Windows SDK10.0.26100.0, debug build.93b8b1d118d6db4b6e134166c0ada511a8950354):cargo build --workspace && cargo test --workspace -- --test-threads=4gpu::recomp::tests::div_f64_translates—okgpu::recomp::tests::gpu_div_f64—ok(executed on RTX 5080 wave32, bit-exact on all 512+ pairs, not skipped)gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64).Regression run
Smoke run by @Toons29 in comment below: #823
Contributed by a community tester; the PR author did not run it. Both blocks are pasted as posted.
main:
PR:
Tester's setup and limits: AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.Tester's AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; the tester checked the blocks before posting.Not tested
AI use
v_div_scale_f64/v_div_fmas_f64/v_div_fixup_f64translation,div_d/div_fixup_dhelpers, and tests.div_d/div_fixup_dbelowldexp_dafter catching a DXC compile error on Windows), ran the full Windows RTX 5080 MSVC + D3D12 debug-layer workspace suite, and drafted this PR description.@SlopTart on GitHub · 2026-11-24 06:41 UTC · original
2|
3|AMD/wave64 + release-build datapoint - and the bit-exactness does NOT hold here: your
gpu_div_f64fails on RDNA3, deterministically, and only in the wave64 form.4|
5|Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Wine = Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust 1.100.0 cross
x86_64-pc-windows-gnu, release profile,XCL_NETWORK=0, native wave64. Same rig as my Linux rows in #42 / #718.6|
7|Merged state: head
93b8b1d(fast-forward ontobeaa245), clean.8|
9|Full suite,
cargo test --workspace --release --no-fail-fast -- --test-threads=4: 704 passed, 11 failed, 41 ignored (17 suites). 10 are this rig's known set (7 stable Wine-lane, my #42 row, + the #718 trio). The 11th is yours:10|
11|-
gpu::recomp::tests::gpu_div_f64- FAIL, deterministic: 3 of 3 isolated reruns + the full suite, identical pair set. The wave32 form passes; the wave64 form is off by exactly 1 ulp on 19 of the checked pairs. Every mismatch sits where your fixup falls back todiv_d(extreme exponents / denormal territory), including the clean case1.7976931348623157e308 / 1.7976931348623157e308 = 0.9999999999999999 (0x3fefffffffffffff), want 1e0. Sample of the set:12| -
-3.3895232148356776e228 / 1.7976931348623157e308 = ...2fc9, want ...2fca13| -
1.005e2 / 1.7976931348623157e308 = 0x0059200000000000, want 0x005920000000000114| -
2.225073858507201e-308 / -1.644453431147607e-308 = ...947f, want ...947e15|-
div_f64_translates(HLSL/DXC check) passes.16|- Note this rig's f64 lane already has known failures (
gpu_f64_math_randometc., my #42 row) - but those are different ops and a different pattern; your wave32 form passing while wave64 fails 1-ulp points at the wave64 path or thediv_dfallback under this DXC/radv pipeline, not at general f64 brokenness.17|
18|Not tested: retail titles (none here), Windows, RDNA4, debug build.
19|Counts only, no game data.
20|AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
@dcastell1 on GitHub · 2026-11-24 06:55 UTC · original
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on
main@beaa245:All green: the translated f64 division ops builds and runs, the workspace has no new failure against
mainon this box (737 passed there), and nothing else changes verdict. Restored the tree afterwards; no game data, hardware adapter, no Wine.AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
@mastrr9 on GitHub · 2026-11-24 07:06 UTC · original
Huge catch — thank you for running this on RDNA3 wave64!
Root cause: In
div_d,precise double r = mn / md;assumed the driver's double division is IEEE correctly rounded (as on NVIDIA), whereas RADV wave64 lowersdoubledivision via approximate reciprocal (~1 ULP low, e.g.mn == mdreturning0x3fefffffffffffffinstead of1.0).Fix (squashed into
fb5ca84a252484bda54daf65f39a825f11978be2):r = fma(rem, 1.0 / md, r); rem = fma(-md, r, mn);followed by an exact 1-ULP IEEE round-to-nearest-even adjustment comparingremagainst the exact power-of-two half-ULP boundmd * (0.5 * ulp(r)), updatingrem = fma(-md, r, mn)if adjusted (so the denormal rounding step below also sees the exact remainder).f64::MAX / f64::MAX) with simulated±4 ULPcorrupted hardwaremn / mdand±2 ULPcorrupted1.0 / md— 0 mismatches.Re-tested on native Windows 11 + NVIDIA RTX 5080 (
fb5ca84a252484bda54daf65f39a825f11978be2, driver617.42,rustc 1.100.0):cargo build --workspaceclean,cargo test --workspace -- --test-threads=4: 715 passed, 0 failed, 41 ignored (SKIPPED: only the 2no wave64tests). If you get a chance to re-rungpu_div_f64on your RX 7900 XT, I'd love to know if wave64 is bit-exact now!(Assisted-by: Antigravity / Gemini 4 Neon + Claude Sonnet 5.5)
@SlopTart on GitHub · 2026-11-24 08:10 UTC · original
Re-ran on the RX 7900 XT at
fb5ca84(merged onto main1ec4c98for the run): the fix works for the normal range butgpu_div_f64still fails here - wave64 leg only, and the residue is purely denormal.f64::MAX / f64::MAX->0x3fefffffffffffff). All gone - MAX/MAX and the normal-range pairs are bit-exact now.5e-324 / -6.591622639274444e-308. The wave32 leg passes clean, as before.Sample (full list of 8 is in the test output):
Reading from your fix note: the FMA refinement + RNE adjustment lands
rexactly for normals, but the denormal rounding step still computes through the approximate reciprocal path - same root cause one layer down. Theremyou feed into it is exact now, so the fixup may only need the subnormal scale handled without re-touching1.0 / md.Determinism: same 8 pairs on reruns (isolated, release,
--test-threadsdefault). Happy to re-verify any follow-up.Counts only, no game data.
Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross
x86_64-pc-windows-gnu,XCL_NETWORK=0, release profile. My Linux rows: #42 / #718.AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
@KENAJBBY on GitHub · 2026-11-24 09:32 UTC · original
Native wave64 run on RDNA2 under the Windows AMD driver, at
66d892164d14eb091f175c2763574d02e348fd2e(its basebeaa245; it also merges cleanly withmain077ce40):gpu_div_f64passes, both the wave64 and the wave32 pass, every pair bit-exact. This head has the same code asfb5ca84, which failed on 8 denormal pairs on the RX 7900 XT under RADV in the comment above. The test's pairs are fixed (seeded RNG), so this run checked the same pairs.Tested
gfx1036, native 64-lane waves, mesh shaders), driver 32.0.21030.2001; NVIDIA GeForce RTX 5070 Ti, driver 621.24 (32-lane waves only); Windows 11 Pro 26200; Rust 1.100.0stable-x86_64-pc-windows-msvc, debug; DXC 1.9.2602.17XCL_ADAPTER=radeon XCL_REQUIRE_GPU=wave64,mesh cargo test --workspace --no-fail-fast -- --test-threads=4: 715 passed, 0 failed, 41 ignored, 0SKIPPED.mainbeaa245on the same machine: 713 passed, 0 failed, 41 ignored, 0SKIPPED. The +2 arediv_f64_translatesandgpu_div_f64.gpu_div_f64alone on the Radeon (--exact,XCL_REQUIRE_GPU=wave64,mesh), 3 runs: passed each time.XCL_ADAPTER=nvidia XCL_REQUIRE_GPU=mesh, same command: 712 passed, 3 failed, 41 ignored.SKIPPED(no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.gpu_div_f64passes there too (split wave64 + wave32).placed_title_textures_share_vram_and_preserve_pixels(cubemap extra_pages must be reused at same va) plustransitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memoryon itsPoisonError. They are not from this PR.main077ce40fails the same three on this machine on both adapters, and the first Radeon run of this PR did too. Other test runs were using the same GPUs at the time. Alone (cargo test -p xcl --lib -- --test-threads=4 title_textures::tests vram::tests), they pass on this head: 20 passed, 0 failed on the Radeon and on the RTX.So on this machine the remaining RDNA3 mismatches do not show up, in either wave size. That points at how RADV / vkd3d-proton runs the f64 denormal path rather than at XCL's wave64 form, but I have not checked RADV myself.
Not tested
scripts/smoke.ps1); noXCL_SAMPLE_*setAI use
@iggyvilla on GitHub · 2026-11-24 13:04 UTC · original
Test report for
66d892164d14eb091f175c2763574d02e348fd2e(current head of #823, basebeaa245; not merged withmain): the targeted GPU tests on an AMD RDNA2 card. The command was run, and its output captured, by an agent (omp, DeepSeek V4.1 Flash); the text below was checked against the PR head's source and written by Claude Code (Claude Sonnet 5.5).Tested
cargo test -p xcl --lib --release -- div_f64:No
SKIPPEDline, so the GPU path ran.gpu_div_f64loops overgpu_waves(); on a native wave64 adapter that is wave64 and wave32. In each it runs the same 512 pairs (34 fixed edge cases, the rest random) and compares the result bit for bit withn / d, treating NaN as equal to NaN.What this shows
Not tested
cargo test --workspace; no compare-side e2e.crates/xcl/src/gpu/recomp/emit.rsis runtime code, so the PR still needs thescripts/smoke.ps1pair (main vs head). This report is GPU test evidence only; no retail title was run.main. The raw test output was not kept as a file; the block above is the agent's capture.AI use
Claude Code, Claude Sonnet 5.5: checked the report against the PR head's
tests.rsand wrote this text; it ran nothing. The build and test run were done by omp with DeepSeek V4.1 Flash, which changed no code.@mastrr9 on GitHub · 2026-11-24 14:38 UTC · original
Huge thanks @SlopTart, @KENAJBBY, and @iggyvilla for the thorough cross-GPU data! Confirming bit-exact pass across both wave64 and wave32 on two independent Windows RDNA2 GPUs (
gfx1036and RX 6650 XT) alongside NVIDIA RTX 5080 (with the remaining 8 denormal pairs isolated specifically to RADV's wave64 path) gives a very clear picture.@Toons29 on GitHub · 2026-11-25 03:02 UTC · original
Regression run of
66d89216on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 100 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.@DavidM1911 on GitHub · 2026-11-25 10:38 UTC · original
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!
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.