sqtt: show total cycles of kernel in viz (#13169)

This commit is contained in:
qazal 2025-11-08 21:00:40 +08:00 committed by GitHub
commit 8a7fa9e7b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View file

@ -716,8 +716,8 @@ async function main() {
}
}
metadata.appendChild(tabulate(ret.summary.map(s => {
const div = d3.create("div").style("background", cycleColors(colorScheme.CATEGORICAL, s.idx)).style("width", "24px").style("height", "100%");
return [s.label.trim(), div.node()];
const div = d3.create("div").style("background", cycleColors(colorScheme.CATEGORICAL, s.idx)).style("width", "100%").style("height", "100%");
return [s.label.trim(), div.text(s.value.toLocaleString()).node()];
})).node());
} else root.appendChild(codeBlock(ret.src, ret.lang || "txt"));
return document.querySelector("#custom").replaceChildren(root);

View file

@ -206,9 +206,10 @@ def load_sqtt(profile:list[ProfileEvent]) -> None:
except Exception: return err("DECODER IMPORT ISSUE")
try:
rctx = decode(profile)
summary = [[{"label":"Total Cycles", "value":x[-1].time-x[0].time if x else 0}] for i,x in enumerate(rctx.inst_execs.values())]
steps = [{"name":str(x[0]), "depth":0, "data":{"rows":[(e.inst, e.time, e.time-x[1][i-1].time if i else 0, e.dur, e.stall,
str(e.typ).split("_")[-1]) for i,e in enumerate(x[1])],
"cols":["Instruction", "Clk", "Wait", "Duration", "Stall", "Type"], "summary":[]},
"cols":["Instruction", "Clk", "Wait", "Duration", "Stall", "Type"], "summary":summary[i]},
"query":f"/render?ctx={len(ctxs)}&step={i}&fmt=counters"} for i,x in enumerate(rctx.inst_execs.items())]
if not steps: return err("EMPTY SQTT OUTPUT", f"{len(sqtt_events)} SQTT events recorded, none got decoded")
except Exception: return err("DECODER ERROR")