mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 13:58:43 +00:00
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 (#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 #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).
21 lines
1.3 KiB
NASM
21 lines
1.3 KiB
NASM
; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm
|
|
; Output modifiers on v_add_f64 (VOP3_Profile<VOP_F64_F64_F64> carries clamp and omod). On RDNA2 the omod of this op
|
|
; does nothing while f64 denormals are kept, which is the MODE this port assumes, and clamp does apply: measured with
|
|
; tools/hw_oracle raw kernels on a gfx1036 iGPU in wave32 and wave64, mul:2/mul:4/div:2 apply only with MODE.IEEE off
|
|
; and f64 denormals flushed. So a + b is 1.25 with or without an omod, and clamp gives 1.0.
|
|
; a = 0.75, b = 0.5 as doubles (low word first); each export is the high word of one double result (low words are 0).
|
|
; mul:2 -> 1.25, clamp -> 1.0, clamp div:2 -> 1.0 (the omod did nothing), mul:4 on a - b -> 0.25.
|
|
; With the omod applied the words would have been 0x40040000 (2.5), 0x3fe40000 (0.625) and 0x3ff00000 (1.0).
|
|
; Needs shaderFloat64; vk_harness exits 77 (SKIP) on a device without it.
|
|
; Expected mrt0 bits: 0x3ff40000, 0x3ff00000, 0x3ff00000, 0x3fd00000
|
|
v_mov_b32 v0, 0
|
|
v_mov_b32 v1, 0x3fe80000
|
|
v_mov_b32 v2, 0
|
|
v_mov_b32 v3, 0x3fe00000
|
|
v_add_f64 v[4:5], v[0:1], v[2:3] mul:2
|
|
v_add_f64 v[6:7], v[0:1], v[2:3] clamp
|
|
v_add_f64 v[8:9], v[0:1], v[2:3] clamp div:2
|
|
v_add_f64 v[10:11], v[0:1], -v[2:3] mul:4
|
|
exp mrt0 v5, v7, v9, v11 done vm
|
|
s_endpgm
|