From ddd1923cb2db9bcf5c30ca89add8f4703a708909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=B8rm?= <52797150+AC-Storm-YT@users.noreply.github.com> Date: Mon, 23 Nov 2026 16:42:25 -0500 Subject: [PATCH] wint_diff: GFX12 has no always-true/false VALU compare; skip those programs by name GFX12 dropped v_cmp_{t,f}_{i32,u32,i64,u64} and their v_cmpx_ forms: AMD LLVM 23 (rocm-sdk-core 10.0.0) assembles all sixteen for gfx1036, gfx1100 and gfx1150 and rejects every one for gfx1201. wint_diff emits v_cmp_t_u32 and v_cmp_f_i32 (and the v_cmpx_ forms), so on an RX 9070 XT those programs were counted as "assembler rejected", and the whole batch carried the first error's text: on main all 69 skips of seed 1 read "... v_cmp_t_u32", including the programs that only use v_cmp_f_i32. - tools/hw_oracle/asm.py: GFX12_VALU_REMOVED lists the sixteen. valu_skip_reason() names them on gfx12xx (and ignores an _e32/_e64 suffix); program_skip_reason() returns the first such reason of a program's lines. The GFX10.1-only mads are unchanged. - tools/wint_diff.py: hw_results() sends only the programs the GPU can run; the others get their reason and are never assembled. The run and the shrinker both use it. - Tests: the sixteen, the suffixes, gfx1013/1036/1100/1150 unchanged, and hw_results with a fake oracle (gfx1201 assembles only the program it can run; gfx1036/1150 run all four). RX 9070 XT, `wint_diff.py --oracle hw --programs 500 --wave both`: seeds 1 and 2 give the same 431 / 426 passes and 69 / 74 skips as main, 0 mismatch; the skips now read v_cmp_f_i32 29, v_cmp_t_u32 25, v_cmpx_f_i32 8, v_cmpx_t_u32 7 (seed 1) and 25 / 25 / 12 / 12 (seed 2). gfx1036: 500/500 on both seeds, as on main. AI-assisted (Claude Code). (cherry picked from commit 32a9427ba442e2160be96e110ffc8362bb14e4e3) --- tests/test_hw_oracle.py | 20 ++++++++++++++++++++ tests/test_wint_diff.py | 22 ++++++++++++++++++++++ tools/hw_oracle/asm.py | 21 ++++++++++++++++++++- tools/wint_diff.py | 35 ++++++++++++++++++++++++++++++----- 4 files changed, 92 insertions(+), 6 deletions(-) diff --git a/tests/test_hw_oracle.py b/tests/test_hw_oracle.py index 036877048..2941d6c45 100644 --- a/tests/test_hw_oracle.py +++ b/tests/test_hw_oracle.py @@ -385,6 +385,26 @@ class Filters(unittest.TestCase): self.assertIn("s_ff0", asm.skip_reason(PROG + ["s_ff0_i32_b64 s[4:5], s[6:7]"], "gfx1201")) self.assertEqual(len([op for op in asm.GFX12_REMOVED if op.startswith("s_cmpk_")]), 12) + def test_gfx12_has_no_always_true_or_false_valu_compare(self): + # gfx1036, gfx1100 and gfx1150 assemble these; gfx1201 rejects all sixteen (AMD LLVM 23). + self.assertEqual(len(asm.GFX12_VALU_REMOVED), 16) + for op in ("v_cmp_t_u32", "v_cmp_f_i32", "v_cmpx_t_u64", "v_cmpx_f_i64"): + for spelled in (op, op + "_e32", op + "_e64"): + self.assertIn("removed in GFX12", asm.valu_skip_reason(spelled, "gfx1201"), spelled) + self.assertIn("removed in GFX12", asm.valu_skip_reason(spelled, "gfx1200"), spelled) + for arch in ("gfx1013", "gfx1036", "gfx1100", "gfx1150"): + self.assertIsNone(asm.valu_skip_reason(spelled, arch), (spelled, arch)) + for op in ("v_cmp_eq_u32", "v_cmp_lt_u32_e64", "v_cmpx_ne_u32_e32", "v_add_nc_u32"): + self.assertIsNone(asm.valu_skip_reason(op, "gfx1201"), op) + # the GFX10.1-only mads are unchanged + self.assertIn("GFX10.1", asm.valu_skip_reason("v_mad_f32", "gfx1201")) + self.assertIsNone(asm.valu_skip_reason("v_mad_f32", "gfx1013")) + prog = ["v_mov_b32_e32 v1, 5", "", "v_cmp_t_u32_e64 s[4:5], v1, v2", "v_cmp_f_i32_e32 vcc, v1, v2"] + self.assertEqual(asm.program_skip_reason(prog, "gfx1201"), + "v_cmp_t_u32: removed in GFX12 (no always-true/always-false VALU compare there)") + self.assertIsNone(asm.program_skip_reason(prog, "gfx1150")) + self.assertIsNone(asm.program_skip_reason(["v_mov_b32_e32 v1, 5"], "gfx1201")) + class VcvarsScript(unittest.TestCase): """The .cmd that calls vcvars64.bat and cl holds the checkout, %TEMP% and Visual Studio paths. A character diff --git a/tests/test_wint_diff.py b/tests/test_wint_diff.py index 0152482b5..a9eb5bcda 100644 --- a/tests/test_wint_diff.py +++ b/tests/test_wint_diff.py @@ -315,6 +315,28 @@ class Cli(unittest.TestCase): self.assertEqual(d.hw_words(words, 64)[1], (4, 5, 6, 7)) self.assertEqual(d.hw_words("assembler rejected: x", 64), "assembler rejected: x") + def test_gfx12_skips_its_removed_compares_by_name_and_never_assembles_them(self): + class Fake: + def __init__(self, arch): + self.arch, self.sent = arch, [] + + def run(self, kernels): + self.sent += kernels + return [[7] * k.words for k in kernels] + removed = [program(["v_cmp_t_u32_e64 s[20:21], v1, v2"]), program(["v_cmpx_f_i32_e64 v1, v2"]), + program(["v_mov_b32_e32 v1, 5", "v_cmp_f_i32_e32 vcc, v1, v2"])] + kept = program(["v_cmp_eq_u32_e64 s[20:21], v1, v2"]) + gfx12 = Fake("gfx1201") + got = d.hw_results(gfx12, removed + [kept]) + for i, op in enumerate(("v_cmp_t_u32", "v_cmpx_f_i32", "v_cmp_f_i32")): + self.assertEqual(got[i], f"{op}: removed in GFX12 (no always-true/always-false VALU compare there)") + self.assertEqual(got[3][0], (7, 7, 7, 7)) + self.assertEqual(len(gfx12.sent), 1) # only the program GFX12 can run is assembled + for arch in ("gfx1036", "gfx1150"): # GFX10/11 still have them: everything runs + other = Fake(arch) + self.assertTrue(all(not isinstance(r, str) for r in d.hw_results(other, removed + [kept])), arch) + self.assertEqual(len(other.sent), 4, arch) + class OracleGuards(unittest.TestCase): def setUp(self): diff --git a/tools/hw_oracle/asm.py b/tools/hw_oracle/asm.py index db8483517..c9688cfa9 100644 --- a/tools/hw_oracle/asm.py +++ b/tools/hw_oracle/asm.py @@ -305,6 +305,13 @@ VALU_REMOVED = { "v_madmk_f32": _MAD_GONE.format("v_fmamk_f32"), "v_mad_legacy_f32": _MAD_GONE.format("v_fma_dx9_zero_f32"), } +# GFX12 dropped the always-true and always-false VALU compares. AMD LLVM 23 (rocm-sdk-core 10.0.0) assembles +# v_cmp_{t,f}_{i32,u32,i64,u64} and the v_cmpx_ forms for gfx1036, gfx1100 and gfx1150 and rejects every one for +# gfx1201 ("instruction not supported on this GPU"). There is no renamed form to substitute: a program that uses one +# cannot run there, so it is skipped with this reason rather than counted as an assembler rejection. +_CMP_TF_GONE = "removed in GFX12 (no always-true/always-false VALU compare there)" +GFX12_VALU_REMOVED = {f"v_{kind}_{tf}_{ty}": _CMP_TF_GONE + for kind in ("cmp", "cmpx") for tf in ("t", "f") for ty in ("i32", "u32", "i64", "u64")} # Same instruction, new mnemonic: the assembler takes the GFX10 spelling for GFX11 and encodes the GFX11 name. GFX11_VALU_RENAMED = { "v_mul_legacy_f32": "v_mul_dx9_zero_f32", # DX9 rule: 0 * anything = 0 (the oracle itself checks it) @@ -383,9 +390,21 @@ def sync_lines(line, arch): def valu_skip_reason(op, arch): - """Why an f32 VALU opcode cannot be run on this architecture, or None.""" + """Why a VALU opcode cannot be run on this architecture, or None. An _e32/_e64 suffix is ignored.""" + op = re.sub(r"_e(32|64)$", "", op) if op in VALU_REMOVED and arch not in ("gfx1010", "gfx1011", "gfx1012", "gfx1013"): return f"{op}: {VALU_REMOVED[op]}" + if op in GFX12_VALU_REMOVED and family(arch) == "gfx12": + return f"{op}: {GFX12_VALU_REMOVED[op]}" + return None + + +def program_skip_reason(lines, arch): + """The first valu_skip_reason of a program's instruction lines (their first word), or None.""" + for line in lines: + why = valu_skip_reason(line.split(None, 1)[0], arch) if line.strip() else None + if why: + return why return None diff --git a/tools/wint_diff.py b/tools/wint_diff.py index 43c9d315f..4a5cf3b24 100644 --- a/tools/wint_diff.py +++ b/tools/wint_diff.py @@ -668,6 +668,32 @@ def hw_words(words, wave): return [tuple(words[4 * lane:4 * lane + 4]) for lane in range(wave)] +def hw_skip(oracle, prog): + """Why the oracle's GPU cannot run this program (asm.program_skip_reason: v_cmp_t_u32 / v_cmp_f_i32 and their + v_cmpx_ forms on GFX12), or None. An oracle without a GPU architecture name skips nothing.""" + arch = getattr(oracle, "arch", None) + if not isinstance(arch, str): + return None + from hw_oracle import asm + return asm.program_skip_reason(prog.lines(), arch) + + +def hw_results(oracle, progs): + """Per program the hardware's per-lane words, or a str reason. A program hw_skip names is never assembled; it + gets that reason, so it is a named skip and not one of the assembler's rejections. The others go to the oracle, + which must return one result per program.""" + out = [hw_skip(oracle, p) for p in progs] + todo = [i for i, why in enumerate(out) if not why] + if todo: + raw = oracle.run([hw_kernel(progs[i]) for i in todo]) + if raw is None or len(raw) != len(todo): + count = 0 if raw is None else len(raw) + raise RuntimeError(f"the hardware runner returned {count} results for {len(todo)} programs") + for i, words in zip(todo, raw): + out[i] = hw_words(words, progs[i].wave) + return out + + # ---- comparison, shrinking, the run -------------------------------------------------------------------------- def _diff(prog, want, got, label): @@ -793,11 +819,7 @@ def run_suite(programs, seed, max_ops, ops, waves=(32,), backends=("translator", rng = random.Random(seed) progs = [generate(rng, rng.randrange(1, max_ops + 1), ops, waves[i % len(waves)]) for i in range(programs)] if "hw" in backends: - raw = oracle.run([hw_kernel(p) for p in progs]) - if raw is None or len(raw) != len(progs): - count = 0 if raw is None else len(raw) - raise RuntimeError(f"the hardware runner returned {count} results for {len(progs)} programs") - hw = [hw_words(w, p.wave) for w, p in zip(raw, progs)] + hw = hw_results(oracle, progs) else: hw = [None] * programs if "vk" in backends: @@ -924,6 +946,9 @@ def main(argv=None): def check_fn(prog): def run_hw_one(p): + why = hw_skip(oracle, p) + if why: + return why res = oracle.run([hw_kernel(p)]) if not res: raise RuntimeError("the hardware runner returned no result for shrunk program")