Repository navigation
rdna2spirv: a literal source of v_div_fixup_f64 / v_div_fmas_f64 is bits 63:32 - #3791
ramosbezzu wants to merge 1 commit into
Conversation
kacper-serewis
left a comment
There was a problem hiding this comment.
At a2747ce all 15 focused tests passed on Windows. FIXUP CPU results matched equivalent register-pair operands for literals in all three positions. FMAS emitted the literal as bits 63:32 in all positions, with distinct inline integer behavior; SPIR-V passed Vulkan 1.2 validation. Binary64 FMA was not executed. #2863 and #3642 overlap both the opcode list and the design contract row. AI-assisted.
Kam471
left a comment
There was a problem hiding this comment.
Ran this at a2747ce3 on Windows 11:
python -I tests/semantic/test_alu_div_fixup.py-> 7 tests, OK.python -I tests/semantic/test_alu_div_fmas.py-> 8 tests, OK.compileallandgit diff --checkclean.
The f64_literal marking now covers v_div_fixup_f64 / v_div_fmas_f64, matching the documented rule that a 32-bit literal on a 64-bit float source supplies bits 63:32 with the low half zero. The two new cases drive the translator, so they would fail on the parent; the shared shader_ir line is the only overlap with #2863/#3642, as the description says. No blocking issue.
|
Tested at the head on Windows 11 / Python 3.13.0: the 15 div tests (7 + 8) pass, plus Both decoders emit Approve. AI-assisted review, no game files, no GPU. |
|
Hardware word for this PR, plus the translated result on two GPUs, at Native gfx1036 (Ryzen 9 9950X3D iGPU, AMD driver 32.0.21030.2001, raw
VCC = 0, so
So on hardware the literal is bits 63:32 in all three source positions of both ops, as the PR says. Translated (compute
Side note, not about this PR: one control word differs from hardware at both heads. It's the Windows 11, llvm-mc AMD LLVM 23.0.0git, Vulkan SDK 1.4.363. Synthetic programs only, no game files. The scripts are local. AI-assisted (Claude Code). |
|
Measured on gfx1036 (RDNA2, driver 26.10.1, game MODE) through raw hw_oracle kernels, one lane, |
…its 63:32 A 32-bit literal on a binary64 operand supplies bits 63:32, with bits 31:0 zero (docs/design.md, "f64 literal sources"). shader_ir only marked it for v_add_f64 and v_cvt_f32_f64, and the two division helpers' own source decoders took an immediate as its low dword: `v_div_fmas_f64 v[0:1], v[2:3], 0x40100000, v[4:5]` built a 5e-315 denormal instead of 4.0. parse_line now marks the literal for both ops and their decoders honour it. Inline integers stay sign-extended and inline floats keep their binary64 value. tests/semantic/test_alu_div_fixup.py: the literal in each of the three source positions against the same value in a register pair (through the translator and the interpreter), and printed 0x1 against inline 1. tests/semantic/test_alu_div_fmas.py: the operand words built for a literal in each position, and 0x1 against 1. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
a2747ce to
d017a5b
Compare
|
Rebased on Not from this PR: on plain |
|
Tested d017a5b merged onto main 03b09a0 on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:
AI-assisted (Claude Code). |
Claimed in the coordination issue as: a new SHADER item, finding and claim (no ID assigned yet). Found while reviewing #3642.
AI-assisted: yes (Claude Code).
Depends on: nothing. Overlaps #2863 (@Vonsek, BUILD-828) and #3642 (@kapitche) on one line of
tools/shader_ir.py(the list of ops whose literal is markedf64_literal); the lists just need to be merged, and I will rebase on whichever lands first.What and why
A 32-bit literal on a 64-bit float operand supplies bits 63:32, with bits 31:0 zero (
docs/design.md, "f64 literal sources").tools/shader_ir.pymarked that only forv_add_f64andv_cvt_f32_f64, and the source decoders ofv_div_fixup_f64andv_div_fmas_f64took an immediate as the low dword. Sov_div_fmas_f64 v[0:1], v[2:3], 0x40100000, v[4:5](0x40100000 is the high word of 4.0) emittedOpCompositeConstruct %v2uint_d %c40100000 %c0, a 5e-315 denormal, andv_div_fixup_f64used the literal as its low word the same way.tools/shader_ir.py:parse_linemarks the literal for the two ops.tools/rdna2spirv.py:d64_words(v_div_fixup_f64) andf64(v_div_fmas_f64) build(lo 0, hi literal)for a marked source. Inline integers stay sign-extended and inline floats keep their binary64 value, as for the other ops in the row.docs/design.md: the "f64 literal sources" row names the two ops and the tests.#2863 and #3642 fix the same thing for
v_rcp/rsq/sqrt_f64(and #2863 for the twov_frexp_*_f64); neither touches the division helpers.Tested
CPU only, Linux (WSL2), Python 3.12.3, no game files, no GPU.
New tests, through
rdna2spirv:test_alu_div_fixup.py,test_literal_source_is_the_high_dword: the literal in each of the three source positions gives the same word as that value in a register pair (translator +spirv_mini_interp), and -2.0 as a literal denominator flips the quotient's sign.test_inline_integer_source_is_not_a_literal: inline1against the printed literal0x1.test_alu_div_fmas.py,test_f64_literal_source_is_the_high_dword: for a literal in each source position the module builds(lo 0, hi literal)and never(lo literal, hi 0);0x1against inline1. This one checks the emitted operand words rather than a result, becausespirv_mini_interpdoes not evaluate binary64.Red before: with
mainf847748c'stools/both files fail (4 failures each). Green after.All 332
tests/semantic/test_*.pyfiles pass with the change;tests/test_shader_ir.py,tests/test_f64_conversion.pyandtests/test_docs_design_rows.pypass.Not done:
spirv-valnot run locally (no SPIRV-Tools on this machine); the tests call it when present, so CI covers it. No corpus counts: I have no work folder.tools/hw_oraclewould confirm it.Checklist
docs/design.md, with how it was confirmed.🤖 Generated with Claude Code