diff options
| author | Vonsek <45567075+Vonsek@users.noreply.github.com> | 2026-11-22 00:50:03 +0100 |
|---|---|---|
| committer | Vonsek <45567075+Vonsek@users.noreply.github.com> | 2026-11-22 00:50:03 +0100 |
| commit | eaae31f609ca95dfa06abfc72a3c552f7073314b (patch) | |
| tree | 6a35a575e07fe566e3e2ae6a801945bf1b6916a1 /tools/salu_diff.py | |
| parent | fc7a3d9ca74d2fa0e79a2af74e4ae52ff2931d9a (diff) | |
| parent | d937b7f092dbc188b59754e5c73c1a9dac553cf9 (diff) | |
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>
Diffstat (limited to 'tools/salu_diff.py')
| -rw-r--r-- | tools/salu_diff.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/salu_diff.py b/tools/salu_diff.py index 3195be829..df972b47a 100644 --- a/tools/salu_diff.py +++ b/tools/salu_diff.py | |||
| @@ -19,9 +19,10 @@ removing instructions that do not matter), 2 on a harness error. Skips are count | |||
| 19 | 19 | ||
| 20 | By default the opcodes in LANE_MASK_OPS are left out: the translator models those 64-bit values (and | 20 | By default the opcodes in LANE_MASK_OPS are left out: the translator models those 64-bit values (and |
| 21 | s_wqm_b32) as per-lane wave masks, so a 64-bit integer reference disagrees with them by design (--ops | 21 | s_wqm_b32) as per-lane wave masks, so a 64-bit integer reference disagrees with them by design (--ops |
| 22 | names them explicitly). Known divergences: s_min/max_i32 SCC on a tie until SHADER-40 (#332) lands, and | 22 | names them explicitly). s_bfe_* control words stay inside offset + width <= 32 unless --bfe-any: past |
| 23 | s_bfe_i32 with offset + width > 32, where the reference follows the ISA pseudocode literally and the | 23 | that the reference follows the ISA pseudocode literally and the translator sign-extends s_bfe_i32 from |
| 24 | translator sign-extends from bit 31; which one hardware does is an open question in #156. | 24 | bit 31, and which one hardware does is an open question in #156. Known divergence on main: s_ff0/ff1_i32_b32 |
| 25 | with a constant source, until SHADER-46 (#349) lands. | ||
| 25 | """ | 26 | """ |
| 26 | import argparse | 27 | import argparse |
| 27 | import gc | 28 | import gc |
| @@ -48,6 +49,7 @@ STUB_DXBC = b"DXBC" + bytes(24) + struct.pack("<I", 0) + bytes(4) | |||
| 48 | REGS = tuple(range(4, 20)) | 49 | REGS = tuple(range(4, 20)) |
| 49 | PAIRS = tuple(range(4, 20, 2)) | 50 | PAIRS = tuple(range(4, 20, 2)) |
| 50 | OUT_SCC = 30 # s_cselect_b32 s30, 1, 0 observes SCC at the end | 51 | OUT_SCC = 30 # s_cselect_b32 s30, 1, 0 observes SCC at the end |
| 52 | BFE_ANY = False # any s_bfe_* control word (--bfe-any), not only offset + width <= 32 | ||
| 51 | INLINE64 = False # inline constants in 64-bit positions (--inline64); the translator reads those as lane masks | 53 | INLINE64 = False # inline constants in 64-bit positions (--inline64); the translator reads those as lane masks |
| 52 | 54 | ||
| 53 | LANE_MASK_OPS = ("s_and_b64", "s_or_b64", "s_xor_b64", "s_andn2_b64", "s_orn2_b64", "s_not_b64", "s_wqm_b64", | 55 | LANE_MASK_OPS = ("s_and_b64", "s_or_b64", "s_xor_b64", "s_andn2_b64", "s_orn2_b64", "s_not_b64", "s_wqm_b64", |
| @@ -242,7 +244,7 @@ def emit(rng, name): | |||
| 242 | form = OPS[name][0] | 244 | form = OPS[name][0] |
| 243 | d, p = rng.choice(REGS), rng.choice(PAIRS) | 245 | d, p = rng.choice(REGS), rng.choice(PAIRS) |
| 244 | if form == "sop2": | 246 | if form == "sop2": |
| 245 | b = _bfe_ctl(rng) if name.startswith("s_bfe") and rng.random() < 0.7 else _src32(rng) | 247 | b = _src32(rng) if name.startswith("s_bfe") and BFE_ANY and rng.random() < 0.3 else _bfe_ctl(rng) if name.startswith("s_bfe") else _src32(rng) |
| 246 | return f"{name} s{d}, {_src32(rng)}, {b}" | 248 | return f"{name} s{d}, {_src32(rng)}, {b}" |
| 247 | if form == "sop2_64": | 249 | if form == "sop2_64": |
| 248 | return f"{name} {_pair(p)}, {_src64(rng)}, {_src64(rng)}" | 250 | return f"{name} {_pair(p)}, {_src64(rng)}, {_src64(rng)}" |
| @@ -477,11 +479,15 @@ def main(argv=None): | |||
| 477 | ap.add_argument("--list-ops", action="store_true") | 479 | ap.add_argument("--list-ops", action="store_true") |
| 478 | ap.add_argument("--self-test", action="store_true") | 480 | ap.add_argument("--self-test", action="store_true") |
| 479 | ap.add_argument("--all-failures", action="store_true", help="print every failing program, not just the first") | 481 | ap.add_argument("--all-failures", action="store_true", help="print every failing program, not just the first") |
| 482 | ap.add_argument("--bfe-any", action="store_true", | ||
| 483 | help="also give s_bfe_* control words past offset + width = 32 (an open hardware question)") | ||
| 480 | ap.add_argument("--inline64", action="store_true", | 484 | ap.add_argument("--inline64", action="store_true", |
| 481 | help="also use inline constants as 64-bit sources (the translator reads them as lane masks)") | 485 | help="also use inline constants as 64-bit sources (the translator reads them as lane masks)") |
| 482 | a = ap.parse_args(argv) | 486 | a = ap.parse_args(argv) |
| 483 | global INLINE64 | 487 | if a.programs < 1 or a.max_ops < 1: |
| 484 | INLINE64 = a.inline64 | 488 | ap.error("--programs and --max-ops must be at least 1") |
| 489 | global INLINE64, BFE_ANY | ||
| 490 | INLINE64, BFE_ANY = a.inline64, a.bfe_any | ||
| 485 | if a.list_ops: | 491 | if a.list_ops: |
| 486 | for name in sorted(OPS): | 492 | for name in sorted(OPS): |
| 487 | print(f"{name:20} {OPS[name][0]}") | 493 | print(f"{name:20} {OPS[name][0]}") |