Skip to content

rdna2spirv: the f64 VALU ops keep only clamp, not their omod - #4371

Open
fiestorra wants to merge 2 commits into
ItsNotRexed:mainfrom
fiestorra:f64-omod-clamp-only
Open

fiestorra wants to merge 2 commits into
ItsNotRexed:mainfrom
fiestorra:f64-omod-clamp-only

Conversation

@fiestorra

@fiestorra fiestorra commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Coordinated as SHADER-721 in #4084.

What changes

docs/design.md said v_add_f64 scales its result by mul:2/mul:4/div:2 before clamping, and the rows for
v_rcp_f64, v_rsq_f64, v_sqrt_f64 and for the four f64 rounding ops repeated the same. On RDNA2 that omod does
nothing while f64 denormals are kept, which is the MODE this port assumes, so the translator was applying a modifier
the hardware drops. Both f64 call sites in tools/rdna2spirv.py now pass clamp_mods_f64 only the clamp they
actually apply; clamp is unchanged, and v_div_fixup_f64, v_div_fmas_f64 and v_frexp_mant_f64 are left as
they are (not measured here, and none of them occurs in the corpus).

How it was confirmed

tools/hw_oracle raw kernels, wave32 and wave64, on the Radeon iGPU (gfx1036) of a Ryzen 7 7800X3D, Windows driver
31.0.24002.92, code object v5, AMD clang 23 from rocm-sdk-core 10.0.0: 23 cases across the four MODE combinations
of IEEE × denorm_mode_16_64, covering v_add_f64, v_rcp_f64, v_rsq_f64, v_sqrt_f64, v_trunc_f64,
v_ceil_f64, v_floor_f64 and v_rndne_f64. Wave32 and wave64 agreed on every case.

  • denorm_mode_16_64 = 3 (denormals kept): no omod changed anything, with MODE.IEEE on or off.
  • denorm_mode_16_64 = 0 with IEEE on: still nothing.
  • denorm_mode_16_64 = 0 with IEEE off: the omod applied.
  • clamp applied in every run: 1.25 → 1.0, sqrt(2.00003) → 1.0, ceil(1.75) → 1.0, ceil(-1.75) → 0.0,
    floor(-0.25) → 0.0.
  • v_add_f64 2^-1074 + 0 mul:2 kept 0x0000000000000001 in the two denormals-kept MODEs. With denormals flushed
    the operand is already 0, so that case separates nothing; the normal sums are what show the second half.

@Vonsek measured the same split on a different gfx1036 in #3896 (1.5 + 1.5 mul:2 → 3.0, and 6.0 only with IEEE off
and denormals flushed) and left this op as a finding asking for exactly this fix. The rounding row here was already
measured by @timelery on gfx1036; this makes the translator agree with it instead of writing that it applies the omod.

Separately recorded and not fixed here: v_sqrt_f64 on this part is not the correctly rounded root —
sqrt(4.0) stored 0x4000000004000000 (2.0000000298), sqrt(9.0) 0x4008000004000000, sqrt(0.25)
0x3fe0000004000000 and sqrt(2.0) 0x3ff6a09e64000000 (1.4142135531 against 1.4142135624), each off by 2^26
ulps of its own result, so only about 26 of the 53 significand bits are right. Four samples only, and the exact
v_rcp_f64/v_rsq_f64 results prove nothing because those inputs are powers of two. No v_sqrt_f64 occurs in the
corpus, so it is written down as a finding rather than fixed.

Counted over the corpus

Counting every mnemonic that contains f64 in all 26 503 listings: 216 v_add_f64 in 5 shaders and 36
v_cvt_f32_f64 in 5, none with an omod and none with clamp, and no other f64 op appears at all. So this
changes no game shader's output; it is a contract fix, not a rendering fix.

Translating all 26 503 listings twice with the same flags (--wave64-emulate, 8 shards, --no-asm) — once with the
translator at main 902358c8, once with this branch rebased onto it — gives 26 503 translated and 26 503 .spv
accepted by spirv-val in both runs, with no rejected listing in either, and the two output trees are identical file
by file, index.json included (SHA-256 7e9aca940d0007a7399d9748861fe3751cf1736654249e1ce342628fa37861d6). So this
changes no game shader's output; it is a contract fix, not a rendering fix.

Tested

  • runtime/test/shaders/ps_f64_mods.asm, cs_f64_add.asm and ps_f64_round.asm: 3/3 pass on the RTX 4090
    (driver 32.0.16.2124) and on the gfx1036 iGPU (driver 31.0.24002.92)
    , with the words this rule predicts
    (ps_f64_mods 0x3ff40000, 0x3ff00000, 0x3ff00000, 0x3fd00000 — 1.25, 1.0, 1.0, 0.25). Their inputs are
    unchanged; only the expected words and their comments moved.
  • tests/semantic/test_valu_add_f64.py, tests/semantic/test_f64_round.py, tests/test_f64_output_modifiers.py,
    tests/test_f64_transcendentals.py: expectations flipped to clamp-only and passing (815 tests OK for the two
    semantic modules; 4 tests and 13 subtests for the two tests/ ones).
  • python -m unittest discover -s tests/semantic on main 902358c8: 6245 tests, failures=3, errors=2,
    skipped=1, expected failures=1
    — all five in test_loop_ballot_barrier. On this branch: the same 6245 tests
    and the same five pre-existing failures and no others. Nothing in an f64 module fails.
  • tests/semantic/regen_fixtures.py --check, scripts/check_no_game_data.py,
    python -m compileall -q make_game.py tools tests: clean.

Related, not dependencies

AI-assisted: an agent ran the measurements and wrote the change; the doc rows and test expectations follow from them.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this at f2d33415 on Windows 11:

  • tests/semantic/test_valu_add_f64.py -> 8 tests, OK.
  • tests/semantic/test_f64_round.py -> 2 tests, OK.
  • tests/test_f64_output_modifiers.py -> 2 tests, OK.
  • tests/test_f64_transcendentals.py -> 2 tests, OK.
  • git diff --check clean.

The change records that the f64 VALU ops keep clamp but not their omod, and updates the CPU/GPU fixtures accordingly; all affected tests pass. I cannot reproduce the hardware measurement here. No blocking issue.

@MKmajster

MKmajster commented Nov 23, 2026 •

Copy link
Copy Markdown

Tested f2d3341 on NVIDIA GeForce RTX 3070 (Ampere, shaderFloat64), driver 617.42, Windows 11 24H2: pass, and the updated fixtures do separate the two behaviours on this driver.

run_gpu_tests.py --filter f64:

cs_f64_add ps_f64_mods ps_f64_round
this branch (its fixtures and translator) PASS 0x0 0x3ff40000 PASS 4096/4096 PASS 4096/4096
main aa2988c (its own fixtures) PASS 0x0 0x40040000 PASS PASS
this branch's fixtures + main's rdna2spirv.py FAIL 0x40040000 FAIL 4096/4096, e.g. got 0x40040000 0x3ff00000 0x3fe40000 0x3ff00000, want 0x3ff40000 0x3ff00000 0x3ff00000 0x3fd00000 PASS

So the omod-dropping result (1.25 instead of 2.5 for the mul:2 add, and so on) comes out of the translated SPIR-V on NVIDIA too. The old translation fails the new fixtures there, rather than both readings happening to agree. ps_f64_round passes either way, as expected: it uses no mul:/div: omod, so it can't tell the two apart.

No game files. AI-assisted (Claude).

@2-CD

2-CD commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Windows + GPU check: NVIDIA GeForce RTX 5080 (driver 621.01) + AMD Radeon 610M iGPU (driver 32.0.13018.6, RDNA2-class), Windows 11, MSVC (VS BuildTools 18) + Ninja, RelWithDebInfo, llvm-mc 21.1.8 (gfx1013), spirv-as/spirv-val. Tested head f2d33415 (base 03b09a08). This head also carries #4362's large-module-gate / preflight removals.

Build: clean, 20 targets.

GPU shader fixtures (scripts/run_gpu_tests.py --filter f64, assemble with llvm-mc 21.1.8 -> translate -> spirv-val -> GPU):

  • NVIDIA RTX 5080: 3/3 PASS - cs_f64_add (0x0 0x3ff40000), ps_f64_mods (4096/4096 pixels exact), ps_f64_round (4096/4096 exact).
  • AMD Radeon 610M iGPU (LEONIDA_VK_DEVICE=Radeon): 3/3 PASS, identical readbacks. The iGPU is RDNA2-class, so this exercises the f64 VALU omod/clamp change on the same ISA family the translator targets.

Python:

  • tests/test_f64_output_modifiers.py, tests/test_f64_transcendentals.py: 5 tests OK.
  • tests/semantic/test_f64_round.py (6 OK, 1 skip) and tests/semantic/test_valu_add_f64.py (8 OK).

Full suite (ctest -C RelWithDebInfo -j 6, excluding the 4 window-showing tests dxgi_swapchain|d3d12_present|vk_presenter_sync|xbox_present):

  • NVIDIA RTX 5080: 149/149 passed, 0 failed.
  • AMD Radeon 610M iGPU: 149/149 passed, 0 failed.

The PR's unstable CI state did not reproduce locally.

Synthetic fixtures only, no game files. AI-assisted (opencode); runs on my machine.

@Flyander Flyander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The translator now preserves only the measured clamp behavior for the covered f64 VALU and rounding operations, while leaving unmeasured f64 ops untouched. The updated semantic and GPU fixtures exercise the changed output, and the reported hardware runs agree across wave sizes and vendor backends.

@theswiss24

Copy link
Copy Markdown

Tested f2d33415 merged onto main 03b09a08 (clean) on two NVIDIA GPUs, test programs built from main 03b09a08: pass on both.

GPU driver, OS llvm-mc run_gpu_tests.py
RTX 4070 (Ada) 621.24, Windows 11 21.1.8 195/210 passed, 15 skipped, 0 failed
RTX 2060 SUPER (Turing) 580.178.04, Ubuntu 24.04 20.1.2 195/210 passed, 15 skipped, 0 failed

Every test has the same result as on main on both cards, including the two changed fixtures:

PASS  cs_f64_add            0x0 0x3ff40000
PASS  cs_f64_add            0x0 0x40040000
PASS  ps_f64_mods           4096/4096 pixels exact

LEONIDA_W64_EMULATE=1 on both. I did not run the PR's tests/semantic changes separately. No game files.

Tested and written by Claude (Claude Code), posting from @theswiss24's account.

@sperm

sperm commented Nov 23, 2026

Copy link
Copy Markdown

Tested f2d3341 on AMD Radeon RX 9070 XT (RADV GFX1201) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.

No game files. AI-assisted.

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested accd13ba39b95f4834294ce44dc474177fc6dfb5 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

At accd13ba on Linux RTX 5090, the stock ps_f64_mods draw matched all 4,096 pixels, and cs_f64_add returned binary64 1.25 (low/high words 0x00000000 0x3ff40000).

I changed the pixel fixture’s first operand from +0.75 to −0.75, keeping the second at +0.5. All 4,096 pixels returned the expected high words bfd00000 00000000 00000000 bff40000: the unclamped sum and difference stayed unscaled, and both clamped sums gave a zero high word. All three module translations passed SPIR-V validation. This checks the translated add paths on NVIDIA.

AI-assisted verification.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested accd13b on Intel UHD 630 (Coffee Lake GT2), Mesa 25.2.8 ANV, Ubuntu 24.04: run_gpu_tests.py --filter f64 with LEONIDA_VK_DEVICE=Intel passes 3/3 (cs_f64_add reads 0x0 0x3ff40000, ps_f64_mods and ps_f64_round 4096/4096 pixels exact), with no f64 fixture skipped. At the PR base 902358c the same filter also passes 3/3 but cs_f64_add reads 0x40040000, so the Intel word moves from 0x40040000 to 0x3ff40000 with this change; the base and head differ in the fixture .asm files as well as the translator, so this is not an isolated translator-only control. test_f64_output_modifiers (2 tests), test_f64_transcendentals (2), test_valu_add_f64 and test_f64_round (14 together) pass, and a nonexistent device name fails with "no Vulkan physical device matches". The PR's claim about omod on AMD gfx1036 was not tested here.

AI-assisted.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Rebased onto main 902358c8 (f64-omod-clamp-only is now accd13ba). The only conflict was in the docs/design.md rows: I kept main's updated rows as they are and put my four f64 rows back as single table lines — they were wrapped over 13 physical lines before, which breaks that table.

Re-measured on the new base, all on this machine (Ryzen 7 7800X3D, gfx1036 iGPU + RTX 4090):

  • python -m unittest discover -s tests/semantic: main 902358c8 → 6245 tests, failures=3, errors=2 (all five in test_loop_ballot_barrier). This branch → the same 6245 tests and the same five failures, and nothing else. The four f64 test files pass on their own (815 tests OK in tests/semantic; 4 tests and 13 subtests under pytest for the two tests/ ones).
  • Corpus A/B with the same flags (--wave64-emulate, 8 shards): 26 503 listings translated and validated on both sides, byte-identical output trees including index.json (SHA-256 7e9aca940d0007a7399d9748861fe3751cf1736654249e1ce342628fa37861d6) — no game shader changes, as the row says.
  • cs_f64_add, ps_f64_mods, ps_f64_round: 3/3 pass on the gfx1036 iGPU (driver 31.0.24002.92) and on the RTX 4090 (driver 32.0.16.2124), with the words this rule predicts.

The body's measured numbers now point at the new base; nothing else in this pull request changed.

@fiestorra

fiestorra commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Re-review request: the branch is mergeable again.

fiestorra:f64-omod-clamp-only is rebased onto 902358c8 as accd13ba, and the docs/design.md conflict is resolved by keeping main's newer "Floating-point class compare" row and re-applying this PR's v_add_clamp_f64 / v_rsq_f64 / v_rcp_f64 / rounding rows as single table lines. Same 10 files and the same behaviour as the head you reviewed.

Re-measured on the rebased tree:

  • tests/semantic full suite: 6245 tests, failures = 3, errors = 2 — identical to main 902358c8 on this machine, all five in test_loop_ballot_barrier.
  • f64 semantic modules: 815 tests, 1 expected failure, 1 skipped; tests/test_f64_output_modifiers.py and tests/test_f64_transcendentals.py: 4 passed, 13 subtests.
  • Whole game corpus: 26,503 listings translated and validated, byte-for-byte identical to the main baseline, index.json sha256 7E9ACA940D0007A7399D9748861FE3751CF1736654249E1CE342628FA37861D6 on both sides, no rejects.
  • GPU --filter f64: 3/3 exact on the gfx1036 iGPU (Ryzen 7 7800X3D integrated iGPU 0x1002:0x164e, driver 31.0.24002.92) and on an RTX 4090 (driver 32.0.16.2124) — cs_f64_add 0x0 0x3ff40000, ps_f64_mods and ps_f64_round 4096/4096 pixels.

@Flyander your approval and @Kam471's run were against f2d33415, so they are marked out-of-date by the rebase. Could either of you re-review at accd13ba? Nothing in the change itself moved.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested accd13b on Intel UHD Graphics 630 (CFL GT2, subgroup 8..32): run_gpu_tests.py --filter f64 with LEONIDA_VK_DEVICE=Intel passes 3/3, "PASS cs_f64_add 0x0 0x3ff40000", "PASS ps_f64_mods 4096/4096 pixels exact" and "PASS ps_f64_round 4096/4096 pixels exact", and a nonexistent device name fails all three with "no Vulkan physical device matches". tests/semantic test_valu_add_f64 and test_f64_round pass (14 tests), and test_f64_output_modifiers.py and test_f64_transcendentals.py pass (2 tests each). The full suite gives 154/217 passed, 61 skipped, with FAIL cs_fmt_int_narrow and cs_signed_zero_nan. The Radeon measurements and the corpus translation check from the description were not reproduced.

AI-assisted.

RDNA2 ignores the VOP3 output modifier of the f64 VALU arithmetic and rounding
ops while f64 denormals are kept, which is the MODE this translator models. I
measured it with tools/hw_oracle raw kernels on a gfx1036 iGPU (the Radeon
iGPU of a Ryzen 7 7800X3D, Windows driver 31.0.24002.92, code object v5),
wave32 and wave64 identical, over the four combinations of MODE.IEEE and
denorm_mode_16_64. mul:2 / mul:4 / div:2 changed nothing for v_add_f64,
v_rcp_f64, v_rsq_f64, v_sqrt_f64, v_trunc_f64, v_ceil_f64, v_floor_f64 and
v_rndne_f64 while f64 denormals were kept, applied only with MODE.IEEE off and
the denormals flushed, and clamp applied in every one of those runs. The two
f64 call sites that still forwarded a full modifier list now hand
clamp_mods_f64 only the clamp they act on, and the rows that described the
scaling for those ops are corrected to what the hardware does.

This is SHADER-721, the binary64 counterpart of the f16 omod row (ItsNotRexed#4542,
"an f16 destination ignores omod"). The row for v_add_f64 records the sweep and
how it was confirmed and keeps the LLVM VOP3 citation main already had; the
rcp/rsq/sqrt and rounding rows keep the measurements others contributed (the
v_sqrt_f64 ulp errors, @timelery's sweep of the four rounding ops) and only
change the sentence about the omod. One contradiction is removed on the way:
main's rounding row said the translator applies the modifiers "as those rows
do" while the code applied them to ops whose own row says they are ignored.

Ops with their own rows are left exactly as they are - v_cvt_f64_i32/u32,
v_cvt_f32_f64, v_frexp_mant_f64, v_div_fixup_f64 and v_ldexp_f64 keep what
their rows measure. The same rule probably reaches the first three as well, and
tests/semantic/test_alu_ldexp_f64.py already knows it for ldexp; I raised that
in ItsNotRexed#5256 as a finding instead of folding unmeasured ops into this change.

Counted over the whole corpus, not a sample: 216 v_add_f64 in 5 of the 26,503
listings, none carrying an omod or a clamp, and no f64 mnemonic in the corpus
carries one, so no game shader changes behaviour here. The two translated
fixtures that do carry a modifier move to the unmodified result, which is what
the sweep predicts: cs_f64_add now reads 0x0 0x3ff40000.

Expectations follow the rule in tests/semantic/test_valu_add_f64.py,
tests/semantic/test_f64_round.py, tests/test_f64_output_modifiers.py,
tests/test_f64_transcendentals.py and the two fixtures with their runners.
tools/f64_diff.py keeps its f64-omod case as a known divergence and
tests/test_f64_diff.py now expects it to mismatch the ISA reference rather than
match it: the reference applies the omod the ISA text describes, the translator
no longer emits it, and that case is the one MODE in which the hardware does
apply it. ps_f64_mods, cs_f64_add and ps_f64_round pass on an NVIDIA RTX 4090
(driver 32.0.16.2124) and on the gfx1036 iGPU above, 3/3 on both; cs_f64_add
reads the same words on Intel UHD 630 / Mesa ANV at this head (@gertify).
@fiestorra

Copy link
Copy Markdown
Contributor Author

Rebased onto 561b65a8; the branch head is now 9b0d35f0b. @gertify your Intel numbers are the evidence this change needed, so let me put them next to mine.

Three vendors agree on the unmodified result. At this head cs_f64_add reads 0x0 0x3ff40000 on my gfx1036 iGPU (Radeon iGPU of a Ryzen 7 7800X3D, Windows driver 31.0.24002.92) and on an NVIDIA RTX 4090 (driver 32.0.16.2124) - the same words you read on Intel UHD 630 / Mesa ANV. On main (902358c8) your run read 0x40040000, the scaled word, which is the other half of the same measurement: the only thing that moved is the mul: the fixture asks for. The rule in the rows is what the three drivers do, not what the ISA text says.

What is in the rebased commit. Only the ops I measured. The sweep is tools/hw_oracle raw kernels on the gfx1036 part above, wave32 and wave64 identical, over the four combinations of MODE.IEEE and denorm_mode_16_64: mul:2 / mul:4 / div:2 do nothing for v_add_f64, v_rcp_f64, v_rsq_f64, v_sqrt_f64, v_trunc_f64, v_ceil_f64, v_floor_f64 and v_rndne_f64 while f64 denormals are kept, apply only with MODE.IEEE off and the denormals flushed, and clamp applies in every run. The rows keep main's LLVM citations and the measurements others added (the v_sqrt_f64 ulp errors, @timelery's sweep of the four rounding ops) and change only the sentence about the omod. v_cvt_f64_i32/u32, v_cvt_f32_f64, v_frexp_mant_f64, v_div_fixup_f64 and v_ldexp_f64 are untouched.

One contradiction goes away with it: main's v_trunc/ceil/rndne_f64 row said the translator applies the modifiers "as those rows do", while the row for v_add_f64 and the code said the omod is a real thing for them. The rows now describe one behaviour, and the code matches them.

Verification at 9b0d35f0b. run_gpu_tests.py --filter f64 -> 3/3 passed on both GPUs above: cs_f64_add 0x0 0x3ff40000, ps_f64_mods 4096/4096 exact, ps_f64_round 4096/4096 exact. Semantic: unittest discover -s tests/semantic -p "test_*f64*.py" -> 766 tests OK; test_alu_div_*.py -> 18 tests OK; test_f64_diff.py -> 29 passed, 578 subtests; the docs row checks (test_docs_design_rows, test_docs_table_rows, test_docs_table_ids, test_docs_repo_paths, test_docs_links, test_docs_repeated_lines, test_docs_list_items) -> all pass; compileall clean. tools/f64_diff.py already listed f64-omod as a known divergence, so tests/test_f64_diff.py now expects that known case to mismatch the ISA reference instead of matching it, with a comment saying why: the reference applies the modifier the ISA text describes, the translator no longer emits it, and that case is the one MODE in which the hardware does apply it. Counted over the whole corpus: 216 v_add_f64 in 5 of the 26,503 listings, none with an omod or a clamp, and no f64 mnemonic in the corpus carries one - no game shader changes.

Open question I did not fold in. Main's "32-bit integers to binary64" row states that output scaling precedes clamping for v_cvt_f64_i32 / v_cvt_f64_u32, and tests/semantic/test_alu_frexp_f64.py asserts an OpFMul %double for v_frexp_mant_f64, while tests/semantic/test_alu_ldexp_f64.py already records that ldexp's omod is ignored when denorm16_64 is 3. Those rows read as inherited from the code path rather than measured. I left them alone and raised it in #5256 as a finding, since they need their own sweep and that is not this PR.

@bunbeans2-arch

Copy link
Copy Markdown

An RDNA4 hardware data point for the omod rule, so the rows can say which hardware they describe. Setup: AMD Radeon RX 9070 XT (gfx1201), AMD Windows driver 26.10.1, native tools/hw_oracle kernels (IEEE is fixed on gfx12, so only denorm_mode_16_64 varies). Same 8 ops (v_add_f64, v_rcp/rsq/sqrt/trunc/ceil/floor/rndne_f64), 8 operands, mul:2 / mul:4 / div:2 / clamp:

  • omod is applied. Unlike gfx1036, gfx1201 applies the omod with f64 denormals kept (denorm_mode_16_64 = 3) as well as flushed. Example: v_add_f64 1.5 + 1.5 mul:2 = 6.0 (0x4018000000000000). Every word whose two readings differ was scaled, for all 8 ops. The only exceptions are NaN results, and 2^-1074 + 2^-1074 under an omod, which comes out +0 (plain: 0x0000000000000002).
  • clamp applies everywhere; NaN results clamp to +0.
  • v_sqrt_f64 gives the same low-precision words you saw: sqrt(4.0) = 0x4000000004000000, sqrt(0.25) = 0x3fe0000004000000.

So the clamp-only rule matches RDNA2 (the console's family) and gfx1036, but not gfx1201. The rows' wording should not imply all AMD hardware drops omod, and a gfx12 hardware oracle would disagree with them. The same holds for the omod note in #2952's v_fract_f64 row. RDNA3 is not tested here.

Not run: wave64, more than one driver. Synthetic operands only. AI-assisted (Claude Code). No game files.

kapitche added a commit to kapitche/Leonida that referenced this pull request Nov 23, 2026
The row already translated the scaling for this op because its destination is f32, and that is
what hardware does. Measured with tools/hw_oracle raw kernels on a gfx1036 iGPU (driver
31.0.24002.92), 8 inputs x 5 MODEs x 5 modifier forms, wave32 and wave64 identical: the scaling
applies under IEEE=0 whenever denorm32=0, including denorm_mode_16_64=3, and is ignored only
with denorm32=3 or IEEE=1, while clamp applies in every mode. No translator or test change;
docs/design.md only. docs checks 33 OK, test_f64_conversion OK, 766 semantic f64 tests OK.
@fiestorra

Copy link
Copy Markdown
Contributor Author

One docs-only follow-up on this branch, no behaviour change: 5d7eba497.

While measuring the binary64 output modifiers for a separate change (now #6314) I found that this branch already treats v_cvt_f32_f64 correctly: its destination is f32, so tools/rdna2spirv.py keeps the full modifier handling for it (clamp_mods(r, mods)) and tests/test_f64_conversion.py expects OpFMul %float for mul:2/mul:4/div:2, and the code comment at the v_add_f64 branch names only v_add_f64, v_rcp_f64, v_rsq_f64 and v_sqrt_f64 as the ops whose scaling is dropped. Nothing needed correcting there.

What was missing was the evidence for that row. The sweep on my gfx1036 iGPU (AMD Radeon(TM) Graphics, driver 31.0.24002.92, raw ISA through tools/hw_oracle, 8 inputs x 5 MODEs x 5 modifier forms, wave32 and wave64 identical word for word) confirms the row as written and says why it differs from the binary64 rows: the gate follows the destination precision. v_cvt_f32_f64 scales under IEEE = 0 whenever denorm32 = 0 — including denorm_mode_16_64 = 3, where the binary64 results do not scale — and stops only with denorm32 = 3 or IEEE = 1; clamp applies in every mode. The row now states that instead of resting on the LLVM assembler encoding alone.

Checked here after the change: docs row/table/id/path/link checks 33 OK, tests/test_f64_conversion.py OK, test_*f64* semantic 766 OK, test_f64_* 37 OK. #6314 carries the measurement tool (tools/f64_omod_probe.py) and the matching wording for v_cvt_f64_i32, v_cvt_f64_u32, v_frexp_mant_f64, v_div_fixup_f16 and v_div_fixup_f64; it does not touch the v_rcp_f64/v_rsq_f64/v_sqrt_f64 branches owned by #5268.

@fiestorra

Copy link
Copy Markdown
Contributor Author

@bunbeans2-arch your gfx1201 run is the first measurement in this thread from a different architecture, and it changes what the rows are allowed to say, so thank you for posting the words rather than a conclusion.

Reading your numbers against mine: on my gfx1036 the scaling appears only with IEEE = 0 and denorm_mode_16_64 = 0 (flushed), and never with IEEE = 1 or with denormals kept. On your gfx1201 it applies with denorm_mode_16_64 = 3 (kept) as well, and you note that IEEE is fixed on there — so the mode gate is not a property of "RDNA" in general, it is RDNA2 behaviour. That is consistent with everything else in the thread: nobody has measured RDNA1 or RDNA3 for these ops.

For this PR that does not change the translation. The point of #4371 is to reproduce what the console's hardware did with the game's ISA — the package's shaders are Xbox (RDNA2) machine code — and the fixture values are what the three RDNA2/other-vendor runs agree on when no modifier is asked for. So the branch keeps dropping the scaling.

What your data does require is that the gate stop being stated as a general rule. The row that states it ("Output modifiers are gated by RDNA2 MODEs") is main's row, not one of mine, and my three rows in #6314 are about individual ops. I am going to add the scope to that gate row in #6314, where the tool that produced the RDNA2 measurement lives: it will name the architecture the gate is confirmed on (RDNA2, my gfx1036 run and the f32_fuzz evidence main already cites), and name your run as the counter-case (RDNA4 gfx1201, RX 9070 XT, driver 26.10.1, IEEE fixed on, omod applied with denormals kept), which is also the honest reason the translator has to pick one architecture's behaviour instead of a hardware-agnostic rule. Two questions before I write it:

  • Do you want to submit those numbers yourself as a note on that row, so the attribution and the wording of your setup are yours? I would rather cite your run than paraphrase it; if you would rather I did it, say so and I will use exactly what you posted here.
  • Is "IEEE is fixed on gfx12" a statement about the MODE encoding being fixed there, or about what the drivers you ran set? I want to record which one it is, because it decides whether the gate can be tested at all on RDNA4.

fiestorra added a commit to fiestorra/Leonida that referenced this pull request Nov 23, 2026
…unter-case

The gate row stated the MODE condition without saying which hardware it describes. It is RDNA2
behaviour: the probe added by this PR measures the same gate per destination precision for the five
binary64/f16 forms and for v_cvt_f32_f64 (f32 destination) on a gfx1036 iGPU, and @bunbeans2-arch
reported on ItsNotRexed#4371 that gfx1201 (RX 9070 XT, driver 26.10.1, IEEE fixed on) applies the scaling with
denorm16_64=3 kept. Quoted from that thread, not reproduced here. docs checks 33 OK.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants