Repository navigation
rdna2spirv: --fma khr covers the f64 FMAs (v_div_fmas_f64) with OpFmaKHR on doubles - #6635
Conversation
…KHR on doubles GLSL.std.450 Fma on doubles rounds twice on NVIDIA (RTX 4090, 621.24, Windows): the new cs_div_fmas_f64 GPU test, fma(a, a, c) with a = 1 + 2^-30 and c = -(1 + 2^-29), gives the split 0 instead of 2^-60 under the default --fma glsl, and the fused 2^-60 with --fma khr, which now emits OpFmaKHR on doubles for v_div_fmas_f64's three multiply-adds. The index lists shaderFmaFloat64 for them (and shaderFmaFloat32 only for an f32 FMA); vk_pipeline_check checks both. Default output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
Gap: the index now lists |
|
Confirmed the f64 cancellation result on Ampere with the native Linux Vulkan driver. On
I also searched all 26,503 disassembled Xbox 1.0.2.1 shader listings for the affected |
|
Independent AI-assisted CPU check at A synthetic listing with The checker's index-based width decisions matched the mocked feature matrix, but the FMA checks currently run after All 88 synthetic outputs validated, and 11/11 default-mode modules and index entries matched base, including mixed-width instruction orders. The focused suite passed 79 at head and 74 at base. Windows, uv CPython 3.12.13, SDK 1.4.363.0; no GPU for this check. |
|
@whattheflop right, thanks. Using |
…shaderFmaFloat64) Review of ProjectLeonida#6635: the harnesses' gate knew only shaderFmaFloat32, so an f64 OpFmaKHR module would reach pipeline creation on a device with Float32 but not Float64 FMA instead of exiting 77. accepts() now reads each OpFmaKHR's result type (OpTypeFloat / OpTypeVector width), so a module that declares Float64 for other doubles but has only f32 OpFmaKHRs still needs only shaderFmaFloat32. ShaderFma records shaderFmaFloat64 and supported() is either width. vk_pipeline_check checks both FMA features before vkCreateShaderModule. New ctest vk_shader_fma (no GPU). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @Mortify7612, @whattheflop, @Kev-Ball. Pushed
RTX 4090 (621.24), runtime rebuilt at |
|
Retested at
AI-assisted (Claude Code). |
|
RADV data point at head
No game files - synthetic compute fixtures, bare hardware. Posted by Hermes (agent) on my machine (RX 7900 XT, Arch; also the boxb/GTX 1070 reporter). |
|
Tested
|
|
GTX 1070 row (second machine: boxb, Pascal GP104, driver 550.163.01, Debian 13, head
No game files — synthetic fixtures from the PR, bare hardware. Posted by Hermes (agent) from the second machine (boxb, GTX 1070; the RX 7900 XT row is above). |
|
Tested 6b0e03e on AMD Radeon RX 7600 (RDNA3, Navi 33), AMD proprietary 26.11.2 (LLPC), Windows driver 32.0.32029.2010, Vulkan 1.4.359, subgroup 32..64, Windows 11 Pro 26300: pass. Test programs built from the PR head with MSVC 19.44 (VS Build Tools 17.14), llvm-mc 23.1.6 (conda-forge), Vulkan SDK 1.4.363 / SPIRV-Tools v2026.4.
AMD's Windows driver exposes the FP64 FMA here, so nothing skips under AI-assisted: run and written up with Claude (Claude Opus 5.5, Anthropic). Synthetic fixtures only, no game files. |
shayderrr
left a comment
There was a problem hiding this comment.
Summary
- Extends OpFmaKHR support to float64:
vk_shader_fma.hgainsspirv_fma_widths()deriving f32/f64 width from the instruction's result type;vk_pipeline_check.cppgates onshaderFmaFloat64, checks the device feature before module creation, and a newvk_shader_fma_testCTest verifies the width gate without a GPU. - Adds a
cs_div_fmas_f64.asmsingle-rounding fixture and updatesdocs/design.mdFMA notes.
Why merge
The translator can now emit OpFmaKHR on doubles, and the harness correctly detects and skips devices lacking the matching feature, avoiding spurious failures. New CPU-side coverage checks the width logic.
Verdict: Approve
Summary
Why mergeThe translator can now emit Verdict: Approve |
…ar, accept either zero sign Review follow-ups on ItsNotRexed#4536 (KubickNubick, DeSunShine, whattheflop, tedin7). - KubickNubick's RTX 4080 mismatch (`v_div_fmas_f64 v[8:9], s[4:5], 3.25, s[4:5]`, VCC clear, last bit) and DeSunShine's `fma(a, a, c)` giving 0 on an RTX 4090 are the same driver behaviour, reproduced on an RTX 4070: an all-constant GLSL Fma comes back split (product rounded to binary64, then the sum) while the same Fma on runtime operands is fused and equals C's fma and the Fraction reference (the reference is right). A GPU result equal to the split value (scaled the same way with VCC set) is now a counted skip with a vendor-neutral reason; `--fma khr` makes it a mismatch, for a translator that emits OpFmaKHR (ItsNotRexed#6635). `--oracle hw` always judges. - Two directed cancellation programs (fma(a, a, c), a = 1 + 2^-30, c = -(1 + 2^-29), with VCC clear and set) run with every v_div_fmas_f64 sweep, and the generator emits VCC clear about half of the time (parity of an operand word, so the random stream of other programs is unchanged), so the split is seen on every run. - whattheflop: `1 * (-0) + (-0)` is -0 in IEEE and +0 here, and the RDNA2 notes do not specify the sign; a zero of the other sign is a counted skip in the translator and gpu oracles, judged by hw. - tedin7: the fixup/fmas rules are the measured gfx1036 ones and equal those of the closed ItsNotRexed#6947 (0 mismatches on an RX 6700 XT); a test pins the values. tests/test_f64_diff.py: 45 tests, seven mutations of the new logic each fail one. AI-assisted (OpenBot team). Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
Conflicts, each resolved keeping both sides: - runtime/shims/d3d12_vulkan_device.cpp, create_graphics(): main's mesh-shader PSOs (ItsNotRexed#2359: `create_graphics(desc, ms, as)` and the mesh-limit check) plus the per-stage code-base slots. An MS stage sits in stages[0] and reads dwords 34-35 like a VS, a PS reads 38-39, and push_bytes is the max over all stages, MS included. - tools/rdna2spirv.py, the index entry: main's FMA features (ItsNotRexed#6635) plus `push_constant_bytes = 4 * USER_SGPRS + 4 * tail_dwords(g)`, so a code-base PS still declares 160 bytes. - docs/design.md and docs/d3d12_vulkan.md: merged word by word. The one main edit not kept is ItsNotRexed#5288's `**ASSUMPTION.**` marker. It sat inside the old "two code bases in one block" paragraph, which this PR replaces with the implemented text, so the assumption is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed in the coordination issue as: new SHADER item, #6414 (comment)
Depends on: none. Touches the same
v_div_fmas_f64lines as #4840 and #3791 (one-lineemit→emit_fma64swaps), whichever lands first.What and why
GLSL.std.450 Fmaon doubles rounds twice on NVIDIA. On an RTX 4090 (driver 621.24), the newcs_div_fmas_f64test gives the split0instead of2^-60. The test isv_div_fmas_f64with VCC = 0, i.e. a plain f64 FMA, computingfma(a, a, c)with a = 1 + 2^-30 and c = -(1 + 2^-29). The f32cs_fma_fusedfuses 8/8 on the same card.--fma khronly covered f32, sov_div_fmas_f64was off in the last bits there with no option to fix it. The pre-scaled FMA and the exact product errorFma(x, y, -p)that its scaled path relies on were also double-rounded.Gen.emit_fma64:OpFmaKHR %doubleunder--fma khr,GLSL Fmaotherwise (--fma exacthas no f64 form and keepsFma).v_div_fmas_f64's three multiply-adds use it.shaderFmaFloat64for an f64OpFmaKHR, andshaderFmaFloat32now only for an f32 one. Before,FMAKHRalways mapped to Float32.vk_pipeline_checkenables and checks both. The test harnesses already enable whateverVK_KHR_shader_fmareports.runtime/test/shaders/cs_div_fmas_f64.asm(+run_gpu_tests.py). It is strict where the index listsshaderFmaFloat64and accepts the split result under the default, ascs_fma_fuseddoes.docs/design.md: the floating-point row no longer says "no f64 fused multiply-add in the translator yet", and records the measurement.--fma glsloutput is unchanged.Tested
NVIDIA GeForce RTX 4090 (driver 621.24, Windows 11 Pro 26200, VS Build Tools 18 + Ninja, Vulkan SDK 1.4.363, llvm-mc 23.1.6), runtime built from this branch:
run_gpu_tests.py --filter cs_div_fmas_f64: default → PASS with the split0x0 0x0(the driver splits);LEONIDA_FMA=khr→ PASS0x0 0x3c300000(fused).cs_fma_fusedunderkhris still 8/8.tests/semantic/test_fma_khr_f64.py(new: emission, index features for f64-only / f32-only / both,spirv-val), plustest_fma_khr.py,test_alu_div_fmas.py,test_run_gpu_tests.py,test_docs_repo_paths.py,test_design_contract_rows.py: 79 passed.regen_fixtures.py --checkis clean.--fma khroutput changes, and only for shaders withv_div_fmas_f64.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed.