rdna2spirv, docs: NVIDIA splits a binary64 Fma only when folding an all-constant one; add cs_div_fmas_f64_rt (FMA64-RT) #572
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!572
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/572/head"
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?
@DeSunShine on GitHub · 2026-11-24 08:43 UTC · original
DeSunShine:fma64-rt→main· +33 −7 · 6 files · 2 commits · merged 2026-11-24 15:50 UTCClaim: FMA64-RT (issue #14). Carries on old upstream #8750, which was closed unmerged shortly before the original repository went private.
What changes
The binary64
Fmanote added with the f64 FMA fix said NVIDIA's driver rounds GLSLFmaon doubles twice. That is too broad. Turing, Ampere and Ada split only an all-constantFmathat the driver folds while compiling the pipeline. The same operands read at run time are fused. Blackwell fuses both.tools/rdna2spirv.py,docs/design.md,runtime/test/shaders/cs_div_fmas_f64.asm,scripts/run_gpu_tests.pyandtests/semantic/test_fma_khr_f64.pynow says this.runtime/test/shaders/cs_div_fmas_f64_rt.asm: the samefma(a, a, c)cancellation probe (a = 1 + 2^-30, c = -(1 + 2^-29)) with its operands in s4..s7, seeded throughVKC_SGPRS. The runner handles both fixtures in one branch.Tested
RTX 4090, driver 621.24, Windows 11, default
--fma glsl:The second result is fused (2^-60). The run-time result was also measured fused on an RTX 3070 (621.01) and an RTX 5060 Laptop, and on an RTX 4070 by the author of old #4536.
tests/semantic/test_fma_khr_f64.pypasses 5/5.Synthetic fixtures only. No game files.
🤖 Generated with Claude Code
@qhukz13 on GitHub · 2026-11-24 11:25 UTC · original · reviewed
Reviewed on head
10b0052e5(Linux, no GPU: CPU interpreter and the unit tests only).Checked:
cs_div_fmas_f64_rt.asm: rsrc2 0x8090 gives 8 user SGPRs, so s4..s7 are seeded byVKC_SGPRS(low word first, matchingDIV_FMAS_F64_SGPRS); the runner keepsVKC_SUBGROUP_SIZEfromcs_envwhen it addsVKC_SGPRS.tests/test_shader_checks.py87/87,tests/test_run_gpu_tests.py64/64,test_fma_khr_f64.py5/5 (1 skipped, no spirv-val here),test_alu_div_fmas.py9/9, compileall clean.spirv_mini_interpon the same probe (v_div_fmas_f64, VCC = 0, a = 0x3ff00000_00400000, c = 0xbff00000_00800000) gives 0x3c300000_00000000, the fused 2^-60.cs_imgload_tfe/cs_imgload_d16_tfe, macos failscs_fma_fusedword 7 (f16); macOS skips both div_fmas fixtures (no shaderFloat64).One data point this PR's CI already measured: on llvmpipe (LLVM 20.1.2, linux-gpu-tools job 138322550054) the run-time twin splits too:
So "split only when folding an all-constant Fma" holds for the NVIDIA GPUs measured, not for every driver. The design.md row is already worded per GPU, but the
emit_fma64docstring and thetest_fma_khr_f64.pydocstring read as general; adding llvmpipe as a driver that splits both would keep anyone from reading the run-time result as safe. The runner's message for_rton llvmpipe is already right.Nits:
test_fma_khr_f64.py: "(run-time operands are fused) (RTX 4090, ..." has two parentheticals in a row.Looks good to me otherwise.
@Timon360SB on GitHub · 2026-11-24 12:15 UTC · original
Independent verification — Turing and Blackwell
Tested exact PR head:
10b0052e570cc6786681bbcf36b61d85b20fc5a8This addresses the missing Turing runtime-operand
measurement noted in the review.
Test environment
Results
Exact output words:
RTX 2060 SUPER (both modes):
RTX 5070 (both modes):
All 8 fixture executions passed. Shader translation
and spirv-val passed for both fixtures in every run.
The generated SPIR-V and index.json were also checked:
Conclusion
The RTX 2060 SUPER confirms the previously missing
Turing data point: the constant-operand probe splits,
while the runtime-operand probe produces the fused
result (2^-60).
The RTX 5070 produces the fused result for both probes.
Results are identical between native and emulated
Wave64 on each tested GPU.
These measurements support the PR's description for
the tested NVIDIA GPUs and driver version. They do
not establish identical behavior across all drivers.
Synthetic fixtures only. No game files used.
AI-assisted test automation and result analysis.