Recompiler: v_div_fmas_f32 scales by VCC and v_div_fixup_f32 handles NaN/zero/sign #1144
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!1144
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1144"
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?
@b3IKK on GitHub · 2026-11-24 12:32 UTC · original
b3IKK:recomp/div-fmas-and-fixup→main· +92 −2 · 2 files · 1 commits · openv_div_fmas_f32emittedmad(s0, s1, s2)and ignored its implicitVCCoperand, so lanes withVCC == 1never got the2^32scale (ldexp_f(..., 32)).div_fixup(v_div_fixup_f32) returnedqunchanged whenqwasNaN(overflow in the division sequence), whenn == ±0.0with finited, whenexp(n) - exp(d) < -150(underflow), and without setting the result sign tosign(d) ^ sign(n). This replacesdiv_fixupwith an IEEE-754 bit-level implementation covering NaN (numerator before denominator),0/0,Inf/Inf,x/0,Inf/x,x/Inf,0/x,exp(n) - exp(d) < -150underflow,q = NaNoverflow, andcopysign(q, sign(d) ^ sign(n)).What is in it
crates/xcl/src/gpu/recomp/emit.rs: scalev_div_fmas_f32by2^32vialdexp_ffor lanes withVCC == 1; updatediv_fixupfor NaN priority (numerator before denominator), zero/inf,exp(n) - exp(d) < -150underflow,q = NaNoverflow, and sign.crates/xcl/src/gpu/recomp/tests.rs: add GPU testsgpu_div_fmas_f32_scales_by_vccandgpu_div_fixup_f32_special_cases_and_sign(17 cases including numerator-over-denominator NaN priority and the-151/-150exponent difference boundary) across wave32 and split wave64 (verified failing before the fix).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 753 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib gpu_div_fmas_f32_scales_by_vccandgpu_div_fixup_f32_special_cases_and_sign: both pass across wave32 and split wave64 (both failed on the GPU before the fix)Regression run
main:
PR:
Not tested
AI use
emit.rs, wrote the fix and GPU tests, addressed the PortBridge hardware-probe feedback (nNaN priority andexp(n) - exp(d) < -150), ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.@DavidM1911 on GitHub · 2026-11-24 12:53 UTC · original
Independent verification on current
main384f7f7(branch already contains it — clean).Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug; DXC 1.8.2502.11.
cargo test -p xcl --lib div_fmas: 1 passed, 0 failed —gpu_div_fmas_f32_scales_by_vcccovers VCC scaling and the NaN/zero/sign fixup cases on real hardware.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@TobiasFornell on GitHub · 2026-11-24 12:57 UTC · original
AMD / Linux data point – the PR was tested on NVIDIA only, where native wave64 is not available.
Tested: RX 9070 XT (RDNA4, native wave64), Mesa RADV 26.3.1, CachyOS (kernel 7.3), Proton Experimental
11.0-20261112Wine with vkd3d-proton v3.1 (scripts/linuxbuild), DXC 1.9.2609,x86_64-pc-windows-msvccross-build, release. Head2aa8211merged ontomain47efa2e(clean), together with #1158.gpu_div_fmas_f32_scales_by_vccandgpu_div_fixup_f32_special_cases_and_sign: pass, including the native wave64 path.emit.rschange reverted (tests kept): both fail, e.g.wave64 lane 1 (vcc=true) v_div_fmas_f32–left: 1088421888, right: 1356857344. So the fix is confirmed on AMD hardware too.Testing and write-up assisted by Claude Code (Claude Opus 5.5); runs on my own hardware, checked by me.
@b3IKK on GitHub · 2026-11-24 13:54 UTC · original
Thanks @akimfomin! Updated \
eac652c\ to check numerator NaN before denominator NaN and apply \exp(n) - exp(d) < -150\ underflow before quotient NaN, added GPU test cases for both (including the -151\ vs -150\ boundary), re-ran the full test suite (753 passed, 0 failed, 41 ignored) and refreshed the 60 s smoke block.@akimfomin on GitHub · 2026-11-24 13:47 UTC · original · edited 2026-11-24 13:59 UTC
PortBridge linked this to Lyrnc’s gfx1036 probe in VIctory #200 and Continued #762’s translator tests. I compiled the exact
div_fixuphelper from2aa8211in an isolated dispatch and read its output on WARP (DXC 1.9.2602.17).(q,d,n)=(0x40000000,0x5d800000,0x12000000)the exponent difference is −151. The helper returned0x40000000; the AMD probe and Continued returned0x00000000.nwith0x12800000gives −150. All three preserved0x40000000.Across 14 vectors, including 10 from the hardware probe, the Continued translator plus CPU interpreter matched 14/14. The exact XCL helper matched 9/14. A local HLSL control that prioritizes numerator NaN and applies
exp(n)-exp(d)<-150before handling quotient NaN matched all 14 on WARP. This was a helper-level check. PortBridge case. Synthetic inputs, AI-assisted with Codex.I independently reran the same WARP probe on the published fix at
eac652c. It matched 14/14 on the original vectors, up from 9/14 on2aa8211. I also replayed the 17 rows in the updatedgpu_div_fixup_f32_special_cases_and_signfixture through the isolated helper. The updated helper matched 17/17, including the NaN payload checks and both signed zero cases, up from 13/17 on the earlier helper. Thanks for adding the regression cases.@JoaoPauluu on GitHub · 2026-11-24 14:05 UTC · original
A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler.
Tested
x86_64-pc-windows-gnu.eac652cas it is (based on930e8b4), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact).gpu::recomp::tests::gpu_div_fmas_f32_scales_by_vcc: ok, no SKIPPED.gpu::recomp::tests::gpu_div_fixup_f32_special_cases_and_sign: ok, no SKIPPED.Not tested
AI use
@TobiasFornell on GitHub · 2026-11-24 14:11 UTC · original
Re-tested the updated head
eac652c(merged ontomain47efa2e, clean) on the same AMD setup: RX 9070 XT (RDNA4, native wave64), RADV 26.3.1, Proton Experimental11.0-20261112Wine, vkd3d-proton v3.1 (scripts/linuxbuild), release.gpu_div_fixup_f32_special_cases_and_sign(incl. the new −151/−150 underflow and NaN-order cases),gpu_div_fmas_f32_scales_by_vcc,gpu_divergence_through_exec: 3 passed, 0 failed, native wave64 path included.Testing and write-up assisted by Claude Code (Claude Opus 5.5); runs on my own hardware, checked by me.
@regiumlepidi on GitHub · 2026-11-24 23:42 UTC · original
RTX 5070 Ti:
eac652cmerged intomain20cf130passes its two tests on the default path; both still fail withXCL_DIRECT_DXIL=1Tested
XCL_SAMPLE_*cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture, one run per cell; PR headeac652c3d11927169ea46739249ebcc188ad800emerged locally into20cf13022f764208384c610c2ae6a3f4eed201a2, no conflicts (passed / failed / ignored):XCL_DIRECT_DXIL=1main20cf130gpu_div_fmas_f32_scales_by_vccandgpu_div_fixup_f32_special_cases_and_signpass. The 4 failures arefuzz_validate_and_gpu_0to_3, which fail the same way onmainwith this driver (#1905)XCL_DIRECT_DXIL=1: those 4,offline_compute_pipeline_is_reused_by_a_second_process(fails onmaintoo), and both new tests:gpu_div_fmas_f32_scales_by_vcc:wave32 lane 1 (vcc=true), left1088421888, right1356857344gpu_div_fixup_f32_special_cases_and_sign:wave32 lane 0 v_div_fixup_f32(q=0x7fc00000, d=0x1e3ce508, n=0x7e967699) = 0x7fc00000, want 0x7f800000tests.rschanges applied tomain20cf130: both new tests fail on both paths with the values aboveXCL_DIRECT_DXIL=1the merged tree returns the same values for these two cases asmaindoes (the PR's diff touchesrecomp/emit.rsandrecomp/tests.rs)SKIPPEDlines in the default run, 18 of them no wave64; none names the new testsNot tested
gpu_waves()runs wave32 only on this adapter), release build, any retail title, other GPUs or driversAI use
@regiumlepidi on GitHub · 2026-11-25 00:00 UTC · original
@b3IKK as in my report above, this PR's two tests still fail with
XCL_DIRECT_DXIL=1: the direct translator has the same two bugs indxil/lower_valu.rsanddxil/prelude.rs. I wrote the matching change for it (below):v_div_fmas_f32scales by 2^32 where VCC is set (also in programs that direct f32 rounding), anddiv_fixupworks on the bits in the same order as your HLSL helper.Measured on an RTX 5070 Ti, driver 617.42, debug, with this PR's commit and the patch on
main62265d3: both new tests pass with and withoutXCL_DIRECT_DXIL=1;cargo test --workspace --locked --no-fail-fast -- --test-threads=4gives 984 / 4 / 45 (default) and 983 / 5 / 45 (direct), the failures being the fourfuzz_validate_and_gpu_*of #1905 and, on direct,offline_compute_pipeline_is_reused_by_a_second_process, which fail onmainhere too. Not tested: wave64, av_div_fmas_f32in a directed-rounding program, any retail title.Take it into this PR if you like, or say if you would rather it go in a separate PR stacked on this one.
Patch for the direct translator (applies with
git applyon this PR merged intomain8e87fc7)Claude Code with Claude Opus 5.5 wrote the patch, ran the tests and wrote this comment.
@luckyteagirl on GitHub · 2026-11-25 03:32 UTC · original
Tested
eac652c3d11927169ea46739249ebcc188ad800eon Windows 11 build 26200, AMD Radeon RX 6800M (driver30.0.13002.13003), Ryzen 9 5980HX, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5.XCL_ADAPTER=6800MandXCL_REQUIRE_GPU=1were set.cargo test --locked -p xcl --lib -j 2 gpu_div_fmas_f32_scales_by_vcc -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, no explicit skip.gpu_div_fixup_f32_special_cases_and_sign: 1 passed, 0 failed, 0 ignored, no explicit skip. This test includes 17 NaN, zero, infinity, sign, and exponent-boundary cases.Coverage note
Both tests call
gpu_waves()andrun_wave(). The latter translates to HLSL withOptions { wave64, ..Default::default() }; neither test setssplit_wave64: true. Thus these runs establish HLSL GPU coverage on AMD, but the current tests do not explicitly exercise split wave64, despite the PR description's claim. They run wave32 and, if the adapter reports native wave64, native wave64. I did not instrument which native mode the adapter chose.Not tested
AI use
OpenAI Codex (GPT-6, exact variant not exposed in this session) reviewed the exact diff and test helpers, ran both focused GPU tests, checked the logs, and drafted this report.
@JJAutoCompare on GitHub · 2026-11-25 03:54 UTC · original
PR #1144 on Intel Arc A770
Tested
x86_64-pc-windows-msvc), unoptimized test profile with debuginfo disabled. Both test stderr logs confirmed loaded DXC and DXIL 1.9.2609.5.eac652c3d11927169ea46739249ebcc188ad800ebefore and after the run. UpstreamAGENTS.mdandCONTRIBUTING.mdwere read frommainatcbc296ab65a2661a61e3e2da109134bcd5319f60. I found no equivalent Arc result in the PR discussion or issue #42.cargo test --locked -p xcl --lib --no-runsucceeded outside the Arc mutex.CARGO_TARGET_DIR=L:/XclTooling/pr1512-tiling-edges-fddfa267/target,CARGO_BUILD_JOBS=2,CARGO_INCREMENTAL=0,CARGO_PROFILE_DEV_DEBUG=0,CARGO_PROFILE_TEST_DEBUG=0.TEMPandTMPpointed atL:/XclTooling/pr1144/run-20261125T034636736Z/temp.powershell.exe -NoProfile -ExecutionPolicy RemoteSignedprocess under& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { ... }, withXCL_ADAPTER=A770andXCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64. The build, each test executable invocation, and each mutex wrapper have separate stdout and stderr files next to this report.gpu_div_fmas_f32_scales_by_vccgpu_div_fixup_f32_special_cases_and_signThe first invocation of each fixture also reported a pass, and both mutex releases were logged. PowerShell's
Start-Processlost access to the exit status of the fast child processes. I reran the same two fixtures with exit status captured throughSystem.Diagnostics.Process. The table uses the reruns and their.verified.*logs. Both reruns acquired and released the Arc mutex.Both fixtures assemble synthetic RDNA2 instructions and run HLSL compiled by DXC for
cs_6_6.gpu_waves()selects wave32 and adds a native wave64 run only when the adapter exposes 64 lanes. The A770 with this driver reports an 8–32 lane range in the existing D3D12 probe, so coverage here was wave32.kernel_wave()leavessplit_wave64at its defaultfalsefor both fixtures. Arc A770 capability probe2 × 3 + 1, the 16 even lanes with VCC clear returned7.0and the 16 odd lanes with VCC set returned7.0 × 2^32. A second instruction checked positive zero in all 32 lanes under the same VCC pattern.(q, d, n)vectors. They cover signed infinity for a NaN quotient on overflow, signed zeros and infinities for zero or infinite operands, finite sign correction, NaN classification for0/0andInf/Inf, exact quiet-NaN payloads with numerator priority, and the exponent-difference boundary at −151 and −150. The −151 rows include both signs of zero and precedence over a NaN quotient. At −150 the supplied finite quotient is preserved.Not tested
AI use
gpt-6.2-sol) checked the PR and stock fixtures, ran the tests, and wrote this report.@DavidM1911 on GitHub · 2026-11-26 03:40 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
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.