This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/tests/kernel_report_check.sh
T
griffin-warrior 1f4f4420e9 kbench: a report whose counts disagree with each other fails a test
The checked-in libr4d section of Rows nothing ran said 239 not reached
over a table of 243: 486c9331 added the four kv_store_streamed rows to
the table without the count (the previous regeneration, 1e968f6e, was
consistent at 239/239). The generator prints header and table from one
vector, so a file like this cannot be one run's output: it is a hand-
merged regeneration, and its headline (132 of 510) and section totals
read four rows short of the tables.

Count the rows each section emits (tests/kernel_report_check.sh), fail
the fast tier when a header and its table disagree or the headline no
longer adds up, and correct the report to the numbers its own tables
show: libr4d 243 not reached, 291 declared (the four rows are in
r4d_rows.cpp and the library reports them), headline 132 of 514.
Regenerating the report from one run on a rig with cards supersedes the
corrected numbers; the test keeps the file honest.
2026-10-28 11:37:51 +01:00

48 lines
2.1 KiB
Bash
Executable File

#!/bin/sh
# kernel_report_check.sh -- the checked-in kernel report is internally consistent.
#
# docs/KERNELS.md is generated by `rad-kbench --report` and reviewed by hand. A hand-merged
# regeneration can carry a per-library "N row(s) not reached" header from one run and the table
# below it from another: at v1.13.0 the libr4d header says 239 while its table lists 243 rows
# (the four kv_store_streamed rows landed in 486c9331 without the count moving), so the section
# total (378) and the headline "132 of 510 declared row(s) were reached" both read four rows
# short of the tables. The generator cannot produce this from one run -- header and table come
# from one vector -- so the report is checked here, and a partially regenerated file fails.
#
# A check that cannot fail is not a check (docs/DEVLOG-decode-floor.md).
set -u
REPORT=$1
test -f "$REPORT" || { echo "kernel_report_check: no report at $REPORT"; exit 1; }
python3 - "$REPORT" <<'PY'
import re, sys
lines = open(sys.argv[1]).read().split("\n")
pat = re.compile(r"`lib\w+`: (\d+) row\(s\) not reached:")
heads = [(i, m.group(1)) for i, l in enumerate(lines) if (m := pat.match(l))]
bad = 0
for j, (a, claimed) in enumerate(heads):
# The library's table ends at the next library header or the next section header.
b = len(lines)
for i in range(a + 1, len(lines)):
if pat.match(lines[i]) or lines[i].startswith("## "):
b = i
break
rows = sum(1 for l in lines[a:b] if l.startswith("| `"))
name = re.match(r"`(\w+)`", lines[a]).group(1)
print(f" {name}: header {claimed}, table {rows}")
if int(claimed) != rows:
bad += 1
text = "\n".join(lines)
m = re.search(r"(\d+) of (\d+) declared row\(s\) were reached", text)
if m:
ran, declared = int(m.group(1)), int(m.group(2))
missed = sum(int(x) for x in pat.findall(text))
if ran + missed != declared:
print(f" headline: {ran} reached + {missed} not reached != {declared} declared")
bad += 1
if bad:
print(f"kernel_report_check: {bad} inconsistent count(s); regenerate the report from one run.")
sys.exit(1)
print("kernel_report_check: the report's counts agree.")
PY