upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-21 22:10:37 +0100
committerAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-21 22:52:35 +0100
commit047d4d9b606d30dc26fdd067bebc6bcce319e583 (patch)
treebf2346e5c4055a4f7d8dfeaae1b91e0a2a88b8d6 /scripts
parentcdaef79a7d9cdc5179fb21c38ff518c1ab0b31a4 (diff)
Wave64 emulation: guard the chained voted branch, more tests, bench reference
Raise Unsupported when a voted branch's segment was not started by the vote's own round. New tests cs_w64x_mask_reuse2 (EXEC reuse, read after a store, half of a mask pair rewritten, chained successor starting with a conflicting load) and cs_w64x_chain_barrier (chained successor starting with s_barrier), plus a translation test counting mask exchanges. bench_wave64.py reports a missing bench line readably and compares against the native AMD output. design.md: how the rules were confirmed, current GPU counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/bench_wave64.py22
-rw-r--r--scripts/run_gpu_tests.py4
2 files changed, 18 insertions, 8 deletions
diff --git a/scripts/bench_wave64.py b/scripts/bench_wave64.py
index ddb1799a3..c20e32b41 100644
--- a/scripts/bench_wave64.py
+++ b/scripts/bench_wave64.py
@@ -7,7 +7,7 @@ Three configurations: AMD with its native 64-wide subgroup (no flag), AMD with -
7vk_compute_test with VKC_BENCH=`reps` timed dispatches of `groups` workgroups; the table gives the median over all 7vk_compute_test with VKC_BENCH=`reps` timed dispatches of `groups` workgroups; the table gives the median over all
8dispatches, the spread of the per-process medians (other programs share the GPU, so look at it), the number of 8dispatches, the spread of the per-process medians (other programs share the GPU, so look at it), the number of
9translated segments (static: blocks + continuation segments; every continuation segment is one more workgroup barrier 9translated segments (static: blocks + continuation segments; every continuation segment is one more workgroup barrier
10on the path through it) and whether the output bytes are the same in every configuration (they must be). 10on the path through it) and whether the output bytes of the emulated runs equal the native AMD run, which is the reference (they must).
11""" 11"""
12import argparse 12import argparse
13import json 13import json
@@ -57,8 +57,9 @@ def run(tools, spv, groups, reps, driver, emulate):
57 m = re.search(r"bench ms: median=([\d.]+) min=([\d.]+) max=([\d.]+)", out) 57 m = re.search(r"bench ms: median=([\d.]+) min=([\d.]+) max=([\d.]+)", out)
58 h = re.search(r"bench out fnv1a: (\w+)", out) 58 h = re.search(r"bench out fnv1a: (\w+)", out)
59 dev = re.search(r"device: (.*) \(subgroup", out) 59 dev = re.search(r"device: (.*) \(subgroup", out)
60 if r.returncode or not m or "0 mismatches" not in out: 60 if r.returncode or not m or not h or "0 mismatches" not in out:
61 return None, out.strip().splitlines()[-1:] or ["no output"], None 61 why = f"exit {r.returncode}" if r.returncode else "no 'bench ms' / 'bench out fnv1a' line (rebuild vk_compute_test)"
62 return None, why + ": " + (out.strip().splitlines()[-1:] or ["no output"])[0], None
62 return (float(m.group(1)), float(m.group(2))), h.group(1), dev.group(1) if dev else "?" 63 return (float(m.group(1)), float(m.group(2))), h.group(1), dev.group(1) if dev else "?"
63 64
64 65
@@ -77,7 +78,7 @@ def main():
77 print(f"{a.shader}: {a.groups} workgroups of the shader's group size, {a.procs} x {a.reps} timed dispatches") 78 print(f"{a.shader}: {a.groups} workgroups of the shader's group size, {a.procs} x {a.reps} timed dispatches")
78 if seg: 79 if seg:
79 print(f"emulated: {seg[0]} segments, {seg[1]} of them continuation segments (one extra round each)") 80 print(f"emulated: {seg[0]} segments, {seg[1]} of them continuation segments (one extra round each)")
80 hashes, rows = set(), [] 81 hashes, rows = {}, []
81 for name, driver, emulate in CONFIGS: 82 for name, driver, emulate in CONFIGS:
82 med, mins, dev = [], [], None 83 med, mins, dev = [], [], None
83 for _ in range(a.procs): 84 for _ in range(a.procs):
@@ -88,13 +89,20 @@ def main():
88 break 89 break
89 med.append(t[0]) 90 med.append(t[0])
90 mins.append(t[1]) 91 mins.append(t[1])
91 hashes.add(h) 92 hashes.setdefault(name, set()).add(h)
92 if med: 93 if med:
93 rows.append((name, dev, statistics.median(med), min(mins), min(med), max(med))) 94 rows.append((name, dev, statistics.median(med), min(mins), min(med), max(med)))
94 for name, dev, m, lo, a_, b_ in rows: 95 for name, dev, m, lo, a_, b_ in rows:
95 print(f"{name:26} {dev:34} median {m:8.3f} ms best {lo:8.3f} process medians {a_:.3f}..{b_:.3f}") 96 print(f"{name:26} {dev:34} median {m:8.3f} ms best {lo:8.3f} process medians {a_:.3f}..{b_:.3f}")
96 print("output identical in every configuration" if len(hashes) == 1 else f"OUTPUT DIFFERS: {sorted(hashes)}") 97 ref_name = CONFIGS[0][0]
97 return 0 if len(hashes) <= 1 else 1 98 ref = hashes.get(ref_name)
99 if not ref or len(ref) != 1:
100 print(f"no reference output from {ref_name}: cannot compare")
101 return 1
102 bad = [n for n, _, _ in CONFIGS[1:] if n in hashes and hashes[n] != ref]
103 print(f"reference output hash: {next(iter(ref))} ({ref_name})")
104 print("emulated output equals the reference" if not bad else f"OUTPUT DIFFERS from the reference: {', '.join(bad)}")
105 return 1 if bad or len(hashes) < len(CONFIGS) else 0
98 106
99 107
100if __name__ == "__main__": 108if __name__ == "__main__":
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index 7da402afe..3ec52a788 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -474,7 +474,7 @@ def run_suite(a, work: str) -> int:
474 "cs_w64x_readlane", "cs_w64x_writelane", "cs_w64x_readfirstlane", "cs_w64x_bpermute", 474 "cs_w64x_readlane", "cs_w64x_writelane", "cs_w64x_readfirstlane", "cs_w64x_bpermute",
475 "cs_w64x_branch", "cs_w64x_ballot", "cs_w64x_wg128_branches", "cs_w64x_lds_raw", 475 "cs_w64x_branch", "cs_w64x_ballot", "cs_w64x_wg128_branches", "cs_w64x_lds_raw",
476 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load", 476 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load",
477 "cs_w64x_mask_reuse"): 477 "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier"):
478 cs_dump_wants = { 478 cs_dump_wants = {
479 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800], 479 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800],
480 # base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone 480 # base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone
@@ -492,6 +492,8 @@ def run_suite(a, work: str) -> int:
492 "cs_w64x_bpermute": [36, 316, 253, 218, 435, 225, 0, 442], 492 "cs_w64x_bpermute": [36, 316, 253, 218, 435, 225, 0, 442],
493 "cs_w64x_branch": [0, 0, 0, 0, 5, 5, 9, 9], 493 "cs_w64x_branch": [0, 0, 0, 0, 5, 5, 9, 9],
494 "cs_w64x_mask_reuse": [8, 40, 8, 40, 2, 20, 10, 64], 494 "cs_w64x_mask_reuse": [8, 40, 8, 40, 2, 20, 10, 64],
495 "cs_w64x_mask_reuse2": [10, 20, 8, 8, 5, 2, 132, 131],
496 "cs_w64x_chain_barrier": [564, 563, 500, 627],
495 "cs_w64x_ballot": [2053, 2061, 2069, 2077, 2085, 2093, 2101, 2109], 497 "cs_w64x_ballot": [2053, 2061, 2069, 2077, 2085, 2093, 2101, 2109],
496 "cs_w64x_wg128_branches": [121, 121, 343, 343, 14, 31, 19812, 22728], 498 "cs_w64x_wg128_branches": [121, 121, 343, 343, 14, 31, 19812, 22728],
497 "cs_w64x_lds_raw": [132, 137, 100, 108, 131, 101, 149, 118], 499 "cs_w64x_lds_raw": [132, 137, 100, 108, 131, 101, 149, 118],