nki-kernel-bench / tools /startup_split.py
jburtoft's picture
nki-kernel-bench v0.1
0fef070
Raw History Blame Contribute Delete
849 Bytes
"""Split a profile's total_time into start-up wait and kernel body.
start-up = time until the first non-control instruction (not EVENT_SEMAPHORE/NOP/DRAIN/NOTIFY/
TENSOR_LOAD/COMPARE_BRANCH) or first DMA packet, whichever is earlier."""
import pandas as pd
CTRL = {"EVENT_SEMAPHORE", "NOP", "DRAIN", "NOTIFY", "TENSOR_LOAD", "COMPARE_BRANCH", "PSEUDO_CORE_BARRIER"}
def split(pdir):
I = pd.read_parquet(pdir + "/Instruction.parquet", columns=["opcode", "start_ts", "end_ts"])
D = pd.read_parquet(pdir + "/DmaPacketAggregated.parquet", columns=["start_ts"])
S = pd.read_parquet(pdir + "/Summary.parquet", columns=["total_time"]).iloc[0]
t0 = I.start_ts.min()
w = I[~I.opcode.isin(CTRL)].start_ts.min()
if len(D): w = min(w, D.start_ts.min())
st = max(0.0, (w - t0) / 1e3); tot = S.total_time * 1e6
return st, tot - st