From dc902b2eaefa6bda621db8134162e788a08c7fb4 Mon Sep 17 00:00:00 2001 From: Alex <270190108+CouchRiv@users.noreply.github.com> Date: Thu, 8 Oct 2026 22:46:34 -0400 Subject: [PATCH] fix(hw-oracle): assemble wave64 bodies in wave64 mode clang assembled every body as wave32, so a --wave64 body that used vcc or an SGPR pair as a condition failed with "operands are not valid for this GPU or mode". Pass -mwavefrontsize64 on wave64 runs. Co-Authored-By: Claude Opus 5.5 (1M context) --- tools/hw-oracle/hw_oracle.py | 2 +- tools/hw-oracle/test_hw_oracle.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/hw-oracle/hw_oracle.py b/tools/hw-oracle/hw_oracle.py index 3b4407407..04e93712b 100644 --- a/tools/hw-oracle/hw_oracle.py +++ b/tools/hw-oracle/hw_oracle.py @@ -64,7 +64,7 @@ def assemble(body, work, wave64, *, ieee, denorm32, denorm16, dx10_clamp, round3 ("@FP16_OVERFLOW@", str(int(fp16_overflow))), ("@BODY@", body)): text = text.replace(key, value) (work / "k.s").write_text(text) - subprocess.run([tool("clang"), "-x", "assembler", "-target", "amdgcn-amd-amdhsa", f"-mcpu={target()}", "-c", str(work / "k.s"), "-o", str(work / "k.o")], check=True) + subprocess.run([tool("clang"), "-x", "assembler", "-target", "amdgcn-amd-amdhsa", f"-mcpu={target()}", *(["-mwavefrontsize64"] if wave64 else []), "-c", str(work / "k.s"), "-o", str(work / "k.o")], check=True) subprocess.run([tool("ld.lld"), "-shared", str(work / "k.o"), "-o", str(work / "k.co")], check=True) return work / "k.co" diff --git a/tools/hw-oracle/test_hw_oracle.py b/tools/hw-oracle/test_hw_oracle.py index b0625f61b..2d02965e3 100644 --- a/tools/hw-oracle/test_hw_oracle.py +++ b/tools/hw-oracle/test_hw_oracle.py @@ -62,5 +62,23 @@ class FloatModeTests(unittest.TestCase): self.assertEqual(assemble.call_args.kwargs, MODES) +class AssemblyTests(unittest.TestCase): + def test_condition_operands_match_wave_size(self): + for name in ("clang", "ld.lld"): + try: + hw_oracle.tool(name) + except SystemExit as error: + self.skipTest(str(error)) + for wave64, vcc, sgpr in ((False, "vcc_lo", "s8"), (True, "vcc", "s[8:9]")): + body = (f" v_cmp_lt_f32 {vcc}, v4, v5\n" + f" v_cndmask_b32 v10, v6, v7, {vcc}\n" + f" v_cmp_lt_f32 {sgpr}, v4, v5\n" + f" v_cndmask_b32 v11, v6, v7, {sgpr}\n") + with self.subTest(wave64=wave64), tempfile.TemporaryDirectory() as tmp: + with patch.object(hw_oracle, "target", return_value="gfx1036"): + code = hw_oracle.assemble(body, Path(tmp), wave64, **MODES) + self.assertTrue(code.is_file()) + + if __name__ == "__main__": unittest.main()