Repository navigation
rdna2spirv: v_mul_legacy_f32 zero override on the Radeon driver, and omod keeps a subnormal result's sign - #5399
Conversation
…n driver, and omod keeps a subnormal result's sign Two signed-zero differences from RDNA2, found by running f32_fuzz cases through the translator on a real Vulkan GPU against the hardware words: * The zero override tested the operands with float compares against 0.0 and selected a float 0.0. In a compute shader that starts with s_mov_b32 exec_lo, -1 the AMD Windows driver (26.10.1) returned -0 for -0 * 3.0 and 3.0 * -0. The test is now on the magnitude bits and the override an integer select of the word 0. * The rule that omod turns -0 into +0 was applied after the flush that follows the scaling. A normal product that omod scales into the subnormal range is flushed afterwards and keeps its sign on the hardware (-1.396 * FLT_MIN with div:2 is -0); only a -0 that enters omod (a flushed subnormal product) becomes +0. New GPU test cs_legacy_mul_zero, words measured on gfx1036 in game MODE; it fails on main on both GPUs (the omod word) and on the Radeon (the zero words). AI-assisted.
|
Tested On Linux with a GeForce RTX 5090 (595.99.02), the unmodified wave32 compute fixture I varied only the z multiplier in two temporary copies to check the flush boundary after AI-assisted verification. |
|
Tested Result: pass.
This doesn't exercise the Radeon-driver path the PR is about; it shows the zero override and the omod change leave the other drivers unaffected. Tested and written by Claude (Claude Code), posting from @theswiss24's account. |
|
I tested the clean merge of this PR ( On that combined tree, |
|
Tested
So on AI-assisted: runs were done with Claude Code. |
Kam471
left a comment
There was a problem hiding this comment.
Head 4c410fbcb89715438136a639643e1f9cb3566bcd (base main 3faac557b).
Commands in review-5399:
python tests/semantic/test_legacy_mul_zero.py-> 1 OK;test_valu_mul_legacy_denorm.py-> 4 OK;test_mutations.py-> 3 OK (202 s);regen_fixtures.py --check-> exit 0.LLVM_MC=wsl .../llvm-mc python -m pytest -q tests/test_translate.py -k "legacy or mul"-> 122 passed, 476 deselected.- GPU (RTX 5070 Ti,
build-5339):python -I scripts/run_gpu_tests.py --build ... --filter legacy-> 4/4,cs_legacy_mul_zero=0 0 0x80000000 0 0 0 0x80000000 0. - Negative control on main's
rdna2spirv.py: semantic 2 + 1 failures, GPU 3/4 (cs_legacy_mul_zero= all zeros). tests/test_shader_checks.py-> 79 OK;git diff --checkclean.
Translator change matches the claim (integer magnitude-bits zero test, omod before the post-scaling flush).
One defect: docs/design.md:348 appends | **Signed zeros ... with an unescaped pipe after the row's existing closing |, so the row now has 3 cells against the | Piece | Contract | header. GFM ignores cells past the header's column count, so the whole new note is dropped from the rendered page. tests/test_docs_design_rows.py passes only because it counts pipes, and the missing trailing pipe cancels the extra one.
Verdict: translator work verified and GPU-green; escape the leading | (or drop it) before merge.
|
FAIL to merge as-is: main moved today (round-44, 561b65a) and git merge-tree now conflicts in docs/design.md and tests/semantic/regen_fixtures.py — a rebase is needed. Substance otherwise checks out and was re-run on the merged tree: the new test_legacy_mul_zero passes, test_valu_mul_legacy_denorm 4/4, test_mutations green with the re-anchored mutation, the fixture regenerates byte-identical and passes spirv-as/spirv-val, and all four words of ps_mul_legacy_denorm_mods stay consistent with the reordered flush/omod. One must-fix that survives the rebase: at your head the "Signed zeros (measured on gfx1036 …)" sentence sits AFTER the row's closing pipe (column 1136 vs last pipe at 1132) — the pipe-count guard mis_shaped_rows cannot see it, and by that guard's own docstring GitHub silently drops text outside the cells, so the whole measurement sentence would vanish from the rendered table; fold it into the description cell. Two review points: v_mad_legacy_f32/v_mac_legacy_f32 (rdna2spirv.py:8001-8014) still use the float-compare + float-select zero test your PR identifies as driver-broken — same fix needed there? — and the gfx1036/driver measurements could not be re-run on this CPU-only host. Also expect design.md line collisions with #3188/#4542. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested
AI-assisted (Claude Code). |
docs/design.md tests/semantic/regen_fixtures.py tests/test_shader_checks.py AI-assisted.
tests/semantic/regen_fixtures.py AI-assisted.
|
Tested
AI-assisted (Claude Code). |
Requested by Lucas · project thread
Claimed in the coordination issue as: EGEN-LEGACY-MUL-ZERO, #5032 (comment)
What and why
Two signed-zero differences of
v_mul_legacy_f32from RDNA2, found by runningf32_fuzzcases through the translator on real GPUs against the hardware words (--oracle hw,vk, #5351):0.0. In a compute shader that starts withs_mov_b32 exec_lo, -1the AMD Windows driver (26.10.1) returned-0for-0 * 3.0and3.0 * -0; RDNA2 gives+0. The test is now on the magnitude bits and the override an integer select of the word 0. (A pixel shader and the RTX 5080 were fine, which is why the existing fixtures did not see it.)-1.396 * FLT_MINwithdiv:2is-0; measured fordiv:2,mul:2,mul:4over six mantissas); only a -0 that enters omod (a subnormal product flushed first) becomes+0. The existingtest_product_flush_precedes_modifierscase-FLT_MIN * 1.0, div:2expected+0; the hardware gives-0(the other four cases of that test stand), so its expected word changes.v_mad_legacy_f32/v_mac_legacy_f32use the same zero-override pattern but have no RDNA2 hardware to measure on (GFX10.1 only) and no omod path here, so they are left as they are.Tested
cs_legacy_mul_zero(compute, 32 lanes, derivation in the.asmheader; words measured withtools/hw_oracleon the gfx1036 in game MODE:0 0 0x80000000 0twice), plus the same shader as a semantic fixture (regen_fixtures.py, asserted intests/semantic/test_legacy_mul_zero.py).python -I scripts/run_gpu_tests.py --filter legacy:cs_legacy_mul_zero,ps_legacy_mul,ps_mul_legacy_denorm,ps_mul_legacy_denorm_modsall pass on an AMD Radeon iGPU (gfx1036, driver 26.10.1) and an NVIDIA GeForce RTX 5080 (driver 616.92).cs_legacy_mul_zerogets0x80000000 0x80000000 0 0 ...on the Radeon (both causes) and0 0 0 0 ...on the RTX 5080 (the omod word); in the semantic test the omod word fails the same way. The mutation testv_mul_legacy_f32 drops zero-times-anything guardis re-anchored on the new lines and still catches its mutation.python -I tools/f32_fuzz.py --programs 1500 --seed 5 --ops v_mul_legacy_f32,v_mad_legacy_f32: 1446 match, 0 mismatch.regen_fixtures.py --checkclean,tests/test_shader_checks.pyOK (its fixture count and canned dump gain the new test).python -m unittest discover -s tests/semanticbefore the last two test edits (the mutation anchor and the one expected word): the only failures besides the three above were the existingtest_loop_ballot_barrier*_emulate*ones (tests/semantic: run test_loop_ballot_barrier's emulated cases through the structured form #5024), which fail the same way on unmodified main. The edited tests andtest_mutationswere rerun and pass.v_mul_legacy_f32row gains the signed-zero rule and how it was measured.AI-assisted: yes.
Checklist
docs/design.md, with how it was confirmed.