Repository navigation
Conversation
|
First GPU run of Result at
Why.
So With
These drivers already flush fp32 subnormals on this path. So on my hosts even the fixed test does not tell this PR from Rest of the suite. On the Radeon, nothing else fails beyond Built on Linux with llvm-mingw for |
catminou4
left a comment
There was a problem hiding this comment.
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96. Execution/valu tests are #[cfg(all(test, windows))] and were not run here.
RDNA MAD/MAC flush binary32 subnormals: flush_f32 keeps only the sign bit when the exponent is zero, applied to inputs, the product, the accumulator and the result for v_mac_f32/v_mac_legacy_f32 (and after OMOD via write_f_with_ftz), while v_fmac_f32 keeps fused semantics. The valu test pins four hardware-observed cases around OMOD (subnormal product/input flushed before mul:2, subnormal after OMOD:div:2 cleared). Windows-only execution; 96 passed on macOS.
|
Following up on the analysis above with the new head: With only that one value changed to |
|
Tested commit
Note that AI-assisted; synthetic tests only, no game files. |
Edited: the failure is a typo in the new test's vector, not a lowering bugCorrection. An earlier version of this comment said that What I measured stays valid:
AI-assisted (Claude Code). |
The first case computed src0 * src1 + src2 as 1.5 * FLT_MIN * FLT_MIN - FLT_MIN, which underflows to a normal -FLT_MIN, so mul:2 correctly returned 0x81000000 and the expected zero could never hold. Use 1.0 as the multiplier so the sum is the intended positive subnormal and the case actually exercises the pre-OMOD flush. Reported in review of Marvisak#1554. Validation: - cargo test -p victory-shader --locked -- --test-threads=1 --skip emit::valu_tests --skip emit::waterfall_tests - cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings - cargo xtask policy - rustfmt --edition 2024 --check crates/victory-shader/src/emit/valu_tests.rs
Summary
On RDNA 2 the
v_mad_legacy_f32/v_mac_legacy_f32encodings are the fused instructions:V_FMA_LEGACY_F32(VOP3 0x140) andV_FMAC_LEGACY_F32(VOP2 0x06), per LLVM's AMDGPU GFX10.3 opcode tables. They fuse the product and the add, flush f32 subnormal sources, and keep the legacy rule that a zero factor makes the product +0 rather than turning an infinite or NaN factor into a NaN. The opcodes are now named that way and the lowering's arms follow.v_mad_f32,v_mac_f32andv_fmac_f32are unchanged.Tests
legacy_mad_fuses_its_product_and_flushes_its_sources: (1 + 2^-23)(1 - 2^-23) - 1 is -2^-46 with one rounding and 0 when the product is rounded first; a subnormal source is a zero; a zero factor gives +0 even with an infinite factor.legacy_mad_lowers_to_one_fused_op_with_flushed_sources: onetertiary.f32and three flushes in the DXIL.fuses_fmadnow probes with the same case as the test. KainanP's Xe-LP passes the old probe ((1 - 2^-24)(1 + 2^-23) - 1) but returns 0 for the legacy case, so the old probe was too weak; the legacy test now skips case 0 on a device whose probe says it does not fuse (and on WARP) instead of failing.Verification
cargo test -p victory-shader --libskips the GPU cases on this machine (no SM 6.6 device without the Agility opt-in); CI runs them. Clippy-D warningsclean. Thanks to KainanP for the Xe-LP run that exposed the weak probe.