Files
mandy/tests/test_run_gpu_tests.py
tunczzzz 81590d3b6d run_gpu_tests: uniform-branch check requires a bit=0 pixel with s5 = 8
check_uniform_branch (ps_uniform_branch, ps_scc_mask32) only asked for some
s5 = 8 and some s5 = 7, so a translator that decides the branch per lane
passed too. Like check.py, it now also needs a pixel whose own bit is 0 but
got 8 (the wave-wide vote). Reported by @Vonsek in #477: the parent 4abd545
gave 0 such pixels and still passed the runner.

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

139 lines
6.0 KiB
Python

"""scripts/run_gpu_tests.py: how it judges the output of a compute "dump" test (no device needed)."""
from pathlib import Path
import sys
import unittest
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
import run_gpu_tests as rgt
WANT = [55, 48]
DEVICE_32 = "device: X (subgroup 32..32)\n"
DEVICE_64 = "device: X (subgroup 32..64)\n"
CONFIRMED = "compute subgroup size: 64\n"
def dump(words, pad=8):
return "out[0..7] = " + " ".join(str(w) for w in (list(words) + [0] * pad)[:8]) + "\n"
def judge(rc, msg, **kw):
kw = {"wave64": False, "partial": False, "emulated": False, **kw}
return rgt.judge_cs_dump(rc, msg, WANT, **kw)
class DumpWords(unittest.TestCase):
def test_eight_decimal_words(self):
self.assertEqual(rgt.dump_words("noise\n" + dump(WANT) + "tail\n"), WANT + [0] * 6)
def test_anything_else_is_not_a_dump(self):
for line in ("out[0..7] = 55 48\n", "out[0..7] = 55 48 BAD 0 0 0 0 0\n", "out[0..7] = 1 BAD 3\n",
"out[0..7] = 55 48 0 0 0 0 0\n", "out[0..7] = 55 48 0 0 0 0 0 0 0\n",
"out[0..7] = 55 48 0 0 0 0 0 0 x\n", "out[0..7] = \n", "no dump here\n"):
with self.subTest(line=line):
self.assertIsNone(rgt.dump_words(line))
class WholeWaveDump(unittest.TestCase):
"""wave64: run with --require-wave64 (the whole-wave mask tests)."""
def judge(self, rc, msg):
return judge(rc, msg, wave64=True)
def test_passes_with_the_words_and_the_confirmation(self):
self.assertEqual(self.judge(0, DEVICE_64 + CONFIRMED + dump(WANT)), (True, "55 48"))
def test_a_device_without_64_wide_subgroups_skips(self):
ok, detail = self.judge(77, DEVICE_32 + "full 64-wide compute subgroups unavailable\n")
self.assertIs(ok, None)
self.assertTrue(detail.startswith("SKIP"))
def test_right_words_without_the_confirmation_fail(self): # a vk_compute_test that ignores the flag
ok, detail = self.judge(0, DEVICE_64 + dump(WANT))
self.assertIs(ok, False)
self.assertIn("not confirmed", detail)
def test_wrong_word_and_harness_errors_fail(self):
for i in range(len(WANT)):
wrong = list(WANT)
wrong[i] ^= 1
with self.subTest(word=i):
self.assertIs(self.judge(0, CONFIRMED + dump(wrong))[0], False)
self.assertIs(self.judge(1, "Vulkan pipeline failed\n")[0], False) # an error is not a skip
self.assertIs(self.judge(1, CONFIRMED + dump(WANT))[0], False)
def test_malformed_dump_lines_fail_without_raising(self):
for line in ("out[0..7] = 55 48\n", "out[0..7] = 55 48 BAD 0 0 0 0 0\n", "out[0..7] = 1 BAD 3\n",
"out[0..7] = 55 48 0 0 0 0 0 0 0\n"):
with self.subTest(line=line):
ok, detail = self.judge(0, CONFIRMED + line)
self.assertIs(ok, False)
self.assertIn(line.strip(), detail)
class NotWholeWave(unittest.TestCase):
"""Dumps run without --require-wave64: cs_store, emulated wave64 (#152) and partial-group tests."""
def test_plain_dump_needs_no_confirmation_and_a_77_is_a_failure(self):
self.assertEqual(judge(0, dump(WANT)), (True, "55 48"))
self.assertIs(judge(77, "unavailable\n")[0], False)
def test_hex_words(self):
ok, detail = rgt.judge_cs_dump(0, dump([0x400080FF, 7]), [0x400080FF, 7], wave64=False, partial=False,
emulated=False, hexwords=True)
self.assertEqual((ok, detail), (True, "0x400080ff 0x7"))
def test_emulated_wave64_runs_on_any_subgroup_size_without_the_confirmation(self):
self.assertEqual(judge(0, DEVICE_32 + dump(WANT), emulated=True), (True, "55 48"))
self.assertIs(judge(77, DEVICE_32, emulated=True)[0], False) # no skip: it must run here
self.assertIs(judge(0, DEVICE_32 + dump([1, 2]), emulated=True)[0], False)
def test_partial_group_skips_unless_the_device_reports_a_64_subgroup(self):
ok, detail = judge(0, DEVICE_32 + dump(WANT), partial=True)
self.assertIs(ok, None)
self.assertTrue(detail.startswith("SKIP"))
self.assertEqual(judge(0, DEVICE_64 + dump(WANT), partial=True), (True, "55 48")) # no confirmation line
self.assertIs(judge(0, DEVICE_64 + dump([1, 2]), partial=True)[0], False)
def test_partial_group_emulated_runs_everywhere(self):
self.assertEqual(judge(0, DEVICE_32 + dump(WANT), partial=True, emulated=True), (True, "55 48"))
def test_malformed_dump_lines_fail_in_every_mode(self):
for kw in ({}, {"emulated": True}, {"partial": True, "emulated": True}):
with self.subTest(**kw):
self.assertIs(judge(0, DEVICE_64 + "out[0..7] = 55 48 BAD 0 0 0 0 0\n", **kw)[0], False)
class UniformBranchCheck(unittest.TestCase):
"""check_uniform_branch (ps_uniform_branch, ps_scc_mask32) must reject a readback in which no bit=0 pixel got
s5 = 8: that is what a translator deciding the branch per lane draws (#477, measured on RTX 5080 and RX 9070 XT:
1856 (8,1) / 192 (8,0) / 2048 (7,0) with the vote, 1856 / 0 / 2240 without)."""
@staticmethod
def judge(rows):
import os
import struct
import tempfile
fd, path = tempfile.mkstemp(suffix=".raw")
try:
with os.fdopen(fd, "wb") as f:
for s5, bit, bary in rows:
f.write(struct.pack("<2I2f", s5, bit, bary, 0.0))
return rgt.check_uniform_branch(path)
finally:
os.remove(path)
def test_wave_vote_passes(self):
ok, detail = self.judge([(8, 1, 0.5), (8, 0, 0.1), (7, 0, 0.1)])
self.assertTrue(ok, detail)
def test_per_lane_decision_fails(self):
ok, detail = self.judge([(8, 1, 0.5), (7, 0, 0.1), (7, 0, 0.1)])
self.assertFalse(ok)
self.assertIn("no bit=0 pixel got s5=8", detail)
def test_set_bit_without_8_fails(self):
self.assertFalse(self.judge([(7, 1, 0.5), (8, 0, 0.1), (7, 0, 0.1)])[0])
if __name__ == "__main__":
unittest.main()