Harness (one TU including upstream fused_gr.cu whole, ours from the sealed PTX through the driver API plus an nvcc cubin), GPU queue stub, and the method note with input sha256. Not run on the GPU yet. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
88 lines
3.9 KiB
Python
88 lines
3.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Per-T tables from the CSV lines of microbench (stdlib only): python3 -I summarize.py result.txt
|
|
|
|
CSV,mode,T,variant,median,p10,p90,min,mean,round_median_lo,round_median_hi,n (microseconds per launch)
|
|
A difference "resolved" means |ours - upstream| is larger than the spread of the per-round medians of both (noise bound of the run).
|
|
Sign: delta = ours - upstream; positive = upstream is faster.
|
|
"""
|
|
import sys
|
|
from collections import defaultdict
|
|
|
|
SHORT = {
|
|
"upstream_mask0_plain": "up_m0",
|
|
"upstream_mask5_batched_staging_loads": "up_m5",
|
|
"upstream_mask133_register_blocked_dot": "up_m133",
|
|
"ours_down_t2w8_nb4_sealed_ptx": "ours_ptx",
|
|
"ours_down_t2w8_nb4_nvcc_cubin": "ours_cubin",
|
|
"ours_split_plus_down_sealed_ptx": "ours_split+down",
|
|
"empty_kernel_with_upstream_mask133_launch_shape": "empty_up",
|
|
"empty_kernel_with_our_launch_shape": "empty_ours",
|
|
"pipeline_upstream_mask0_down_plus_up": "pipe_up_m0",
|
|
"pipeline_upstream_mask5_down_plus_up": "pipe_up_m5",
|
|
"pipeline_upstream_mask133_down_plus_up": "pipe_up_m133",
|
|
"pipeline_ours_split_down_up8_sealed_ptx": "pipe_ours",
|
|
}
|
|
|
|
|
|
def load(path):
|
|
data = defaultdict(lambda: defaultdict(dict))
|
|
for line in open(path, errors="replace"):
|
|
if not line.startswith("CSV,"):
|
|
continue
|
|
f = line.rstrip("\n").split(",")
|
|
mode, t, name = f[1], int(f[2]), SHORT.get(f[3], f[3])
|
|
v = [float(x) for x in f[4:11]]
|
|
data[mode][t][name] = dict(median=v[0], p10=v[1], p90=v[2], mn=v[3], mean=v[4], lo=v[5], hi=v[6])
|
|
return data
|
|
|
|
|
|
def table(data, mode, cols, title):
|
|
if mode not in data:
|
|
return
|
|
print(f"\n== {title}: median us per launch (p10..p90)")
|
|
print("T " + "".join(f"{c:>26}" for c in cols))
|
|
for t in sorted(data[mode]):
|
|
row = data[mode][t]
|
|
cells = []
|
|
for c in cols:
|
|
x = row.get(c)
|
|
cells.append(f"{x['median']:8.3f} ({x['p10']:6.2f}..{x['p90']:6.2f})" if x else "-")
|
|
print(f"{t:<2} " + "".join(f"{c:>26}" for c in cells))
|
|
|
|
|
|
def deltas(data, mode, ours, ups, title):
|
|
if mode not in data:
|
|
return
|
|
print(f"\n== {title}: delta = {ours} - upstream, us per launch (positive: upstream faster); '*' = larger than the round-to-round spread of both")
|
|
print("T " + "".join(f"{u:>26}" for u in ups))
|
|
for t in sorted(data[mode]):
|
|
row = data[mode][t]
|
|
if ours not in row:
|
|
continue
|
|
cells = []
|
|
for u in ups:
|
|
if u not in row:
|
|
cells.append("-")
|
|
continue
|
|
a, b = row[ours], row[u]
|
|
d = a["median"] - b["median"]
|
|
spread = (a["hi"] - a["lo"]) + (b["hi"] - b["lo"])
|
|
cells.append(f"{d:+8.3f} ({100 * d / b['median']:+6.1f}%) {'*' if abs(d) > spread else ' '}")
|
|
print(f"{t:<2} " + "".join(f"{c:>26}" for c in cells))
|
|
|
|
|
|
def main(path):
|
|
d = load(path)
|
|
down = ["up_m0", "up_m5", "up_m133", "ours_ptx", "ours_cubin", "ours_split+down", "empty_up", "empty_ours"]
|
|
for mode, title in (("graph_cold_weights", "graph-batched, cold weights (headline)"), ("graph_warm_weights", "graph-batched, warm weights (L2-resident)"),
|
|
("single_launch_cold_weights", "single launch with events (includes event overhead; see the empty-kernel columns)")):
|
|
table(d, mode, down, title)
|
|
deltas(d, mode, "ours_ptx", ["up_m133", "up_m5", "up_m0"], title + ", our down kernel alone")
|
|
deltas(d, mode, "ours_split+down", ["up_m133", "up_m5", "up_m0"], title + ", our split+down (upstream's down kernel also does the norm's sum of squares and staging)")
|
|
table(d, "graph_cold_weights", ["pipe_up_m0", "pipe_up_m5", "pipe_up_m133", "pipe_ours"], "whole read (down+up for upstream, split+down+up8 for ours), cold weights")
|
|
deltas(d, "graph_cold_weights", "pipe_ours", ["pipe_up_m133", "pipe_up_m5", "pipe_up_m0"], "whole read")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main(sys.argv[1])
|