diff options
Diffstat (limited to 'scripts/bench_wave64.py')
| -rw-r--r-- | scripts/bench_wave64.py | 22 |
1 files changed, 15 insertions, 7 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 - | |||
| 7 | vk_compute_test with VKC_BENCH=`reps` timed dispatches of `groups` workgroups; the table gives the median over all | 7 | vk_compute_test with VKC_BENCH=`reps` timed dispatches of `groups` workgroups; the table gives the median over all |
| 8 | dispatches, the spread of the per-process medians (other programs share the GPU, so look at it), the number of | 8 | dispatches, the spread of the per-process medians (other programs share the GPU, so look at it), the number of |
| 9 | translated segments (static: blocks + continuation segments; every continuation segment is one more workgroup barrier | 9 | translated segments (static: blocks + continuation segments; every continuation segment is one more workgroup barrier |
| 10 | on the path through it) and whether the output bytes are the same in every configuration (they must be). | 10 | on 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 | """ |
| 12 | import argparse | 12 | import argparse |
| 13 | import json | 13 | import 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 | ||
| 100 | if __name__ == "__main__": | 108 | if __name__ == "__main__": |