Commit Graph

7 Commits

Author SHA1 Message Date
111200df40 fix(test): generate encodable SALU literal pairs
The CPU oracle accepts two different literal words even though the instruction has space for one. Replace the conflicting first source with an initialized SGPR so the same generated case can run through the hardware backend.
2026-11-22 20:11:55 +01:00
06f36cec6b tools/salu_diff: add integer SALU ops and gfx1036 RDNA2 follow-up to #1746 (SHADER-137) 2026-11-22 19:29:38 +03:00
2e33dc681a salu_diff: SCC consumers in control flow (--branches, FUZZ-4 follow-up)
With --branches every SCC producer may be followed by a chain of 1..3
consumers (s_cselect_b32, s_addc_u32, s_subb_u32) or by s_cbranch_scc0/scc1
forward over the next 1..3 scalar instructions (one lane, no loops, no
nesting). Half the instructions are drawn from the SCC producers. Program
lines write a branch as "+N" instructions; the listing for the translator
carries the dword offset and ; encoding: placeholders of each instruction's
size (literal = 8 bytes), which place the branch targets. The reference
models the skip, the shrinker keeps skipped ranges consistent, and a
mismatch prints the real offsets. Default runs are unchanged so existing
seeds keep their programs; the hardware oracle refuses --branches.

8000 branch programs (8 seeds, max-ops 6/12/20, one with --bfe-any) match
on main. Also drops the stale "until #349 lands" note (#349 is merged).

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:40:38 +01:00
ed64990837 salu_diff: optional hardware oracle (--oracle hw), reference s_bfe past bit 31
tools/hw_oracle wraps the generated scalar programs in GFX10/GFX11 kernels,
assembles them with AMD clang and runs them through the HIP runtime of the
AMD Windows driver (hw_oracle.c, loaded with LoadLibrary, no SDK). salu_diff
compares the hardware's three SGPRs + SCC with the reference, alone or
together with the translator. A missing tool prints "unavailable" and exits 77.

First finding: s_bfe_i32 with offset + width > 32 stops the field at bit 31
on gfx1150 (width = min(width, 32 - offset)); the reference followed the
pseudocode literally. The translator already did the hardware thing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 08:43:11 +01:00
4a7db23cc0 tests/test_salu_diff.py: test --ops whitespace, duplicates, empty tokens and stderr reporting 2026-11-22 01:33:12 +00:00
eaae31f609 Merge main; leave the s_ff fix to #349; review fixes for salu_diff
SHADER-46 (#349) fixes the same s_ff0_i32_b32 bug and was opened first, so
this branch drops its translator change and ps_salu_ff and keeps the
fuzzer. s_bfe_* control words stay inside offset + width <= 32 unless
--bfe-any; --programs/--max-ops below 1 is an argument error; the tests
no longer exclude s_min/max_i32 (#332 is on main) and check the BFE range.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:50:03 +01:00
fc7a3d9ca7 FUZZ-4: scalar ALU differential fuzzer; s_ff0_i32_b32 on a constant
tools/salu_diff.py runs seeded SOP1/SOP2/SOPC/SOPK programs through its
own reference and through the translator plus spirv_mini_interp, and
compares three SGPRs and SCC. It found that s_ff0_i32_b32 read a 32-bit
constant source as a lane mask; constants are now values, as for
s_bcnt*_b32. GPU-checked with ps_salu_ff.asm.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:21:00 +01:00