Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
import sys,collections
|
|
sys.path.insert(0,"/data/leleka-e2e/decode/tools")
|
|
import lct as L
|
|
t=L.Trace(sys.argv[1])
|
|
byc=collections.defaultdict(list)
|
|
for k in t.kernels: byc[k.corr].append(k)
|
|
big=[c for c,v in byc.items() if len(v)>=900]
|
|
big.sort(key=lambda c:min(k.start for k in byc[c])); big=big[2:-2]
|
|
# classify stream by dominant family
|
|
cls={}
|
|
for c in big[:50]:
|
|
for k in byc[c]:
|
|
n=t.names.get(k.name,"")
|
|
cls.setdefault(k.stream,collections.Counter())[("wait_flag" in n or "gu_swiglu" in n or "native_down_multi" in n) and "expert" or ("mmvq_il" in n and "qsa" or "main")]+=1
|
|
role={s:c.most_common(1)[0][0] for s,c in cls.items()}
|
|
print(role)
|
|
two=0.0; comb=collections.defaultdict(float); N=len(big)
|
|
for c in big:
|
|
ks=byc[c]; ev=[]
|
|
for k in ks: ev.append((k.start,1,k.stream)); ev.append((k.end,-1,k.stream))
|
|
ev.sort(); act=collections.Counter(); last=None
|
|
for tm,d,s in ev:
|
|
if last is not None and tm>last:
|
|
roles=frozenset(role.get(x,"main") for x,v in act.items() if v>0)
|
|
nstr=sum(1 for v in act.values() if v>0)
|
|
if nstr>=2: two+=tm-last; comb["+".join(sorted(roles))]+=tm-last
|
|
act[s]+=d; last=tm
|
|
print("wall time with >=2 streams active: %.3f ms/graph"%(two/N/1e6))
|
|
for k,v in sorted(comb.items(),key=lambda x:-x[1]): print(" %-24s %.3f ms/graph"%(k,v/N/1e6))
|