mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-08-29 17:56:07 +00:00
viz: cleanup sqtt loader (#13417)
This commit is contained in:
+9
-10
@@ -225,10 +225,6 @@ def load_sqtt(profile:list[ProfileEvent]) -> None:
|
||||
if not rctx.inst_execs: return err("EMPTY SQTT OUTPUT", f"{len(sqtt_events)} SQTT events recorded, none got decoded")
|
||||
steps:list[dict] = []
|
||||
for name,waves in rctx.inst_execs.items():
|
||||
units:dict[str, int] = {}
|
||||
events:list[ProfileEvent] = []
|
||||
prg = trace.keys[r].ret if (r:=ref_map.get(name)) else None
|
||||
steps.append(first:=create_step(prg.name if prg is not None else name, ("/counters", len(ctxs), len(steps))))
|
||||
# Idle: The total time gap between the completion of previous instruction and the beginning of the current instruction.
|
||||
# The idle time can be caused by:
|
||||
# * Arbiter loss
|
||||
@@ -236,7 +232,9 @@ def load_sqtt(profile:list[ProfileEvent]) -> None:
|
||||
# * Instruction cache miss
|
||||
# Stall: The total number of cycles the hardware pipe couldn't issue an instruction.
|
||||
# Duration: Total latency in cycles, defined as "Stall time + Issue time" for gfx9 or "Stall time + Execute time" for gfx10+.
|
||||
wave_insts:dict[str, dict] = {}
|
||||
units:dict[str, int] = {}
|
||||
events:list[ProfileEvent] = []
|
||||
wave_execs:dict[str, dict] = {}
|
||||
for w in waves:
|
||||
if (row:=f"SE:{w.se} CU:{w.cu} SIMD:{w.simd} WAVE:{w.wave_id}") not in units: units[row] = 0
|
||||
units[row] += 1
|
||||
@@ -247,12 +245,13 @@ def load_sqtt(profile:list[ProfileEvent]) -> None:
|
||||
prev_instr = max(prev_instr, e.time + e.dur)
|
||||
summary = [{"label":"Total Cycles", "value":w.end_time-w.begin_time}, {"label":"SE", "value":w.se}, {"label":"CU", "value":w.cu},
|
||||
{"label":"SIMD", "value":w.simd}, {"label":"Wave ID", "value":w.wave_id}, {"label":"Run number", "value":units[row]}]
|
||||
wave_insts[f"{row} N:{units[row]}"] = {"rows":rows, "cols":["Instruction", "Clk", "Idle", "Duration", "Stall", "Type"], "summary":summary}
|
||||
|
||||
for k in sorted(wave_insts, key=row_tuple):
|
||||
steps.append(create_step(k, ("/counters", len(ctxs), len(steps)), wave_insts[k], depth=2))
|
||||
wave_execs[f"{row} N:{units[row]}"] = {"rows":rows, "cols":["Instruction", "Clk", "Idle", "Duration", "Stall", "Type"], "summary":summary}
|
||||
# gather and sort all wave execs of this kernel
|
||||
events = [ProfilePointEvent(unit, "start", unit, ts=Decimal(0)) for unit in units]+events
|
||||
first["data"] = {"value":get_profile(events, sort_fn=row_tuple), "content_type":"application/octet-stream"}
|
||||
kernel = trace.keys[r].ret if (r:=ref_map.get(name)) else None
|
||||
steps.append(create_step(kernel.name if kernel is not None else name, ("/counters", len(ctxs), len(steps)),
|
||||
{"value":get_profile(events, sort_fn=row_tuple), "content_type":"application/octet-stream"}, depth=1))
|
||||
for k in sorted(wave_execs, key=row_tuple): steps.append(create_step(k, ("/counters", len(ctxs), len(steps)), wave_execs[k], depth=2))
|
||||
ctxs.append({"name":"Counters", "steps":steps})
|
||||
|
||||
def get_profile(profile:list[ProfileEvent], sort_fn:Callable[[str], Any]|None=None) -> bytes|None:
|
||||
|
||||
Reference in New Issue
Block a user