interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / evidence / amd-speed-20261114 / raw / unpacked / amd-launch-gap / card / run3 / gap-evidence / logs / gap-hipmicro.py

28 lines · 1663 bytes Raw Blame History
1# Instrument (not Omega): HIP graph replay of N step_advance launches per step, the same kernel
2# object as the Omega micro plan (driver-real2.py's embedded objects), timed the way real2 times
3# a step: perf_counter before hipGraphLaunch, after hipStreamSynchronize. Also times the parts:
4# launch call return, synchronize return, and a 4-byte token readback (tok.item()).
5# Usage: gap-hipmicro.py DRIVER N STEPS OUT.json
6import importlib.util,json,statistics,sys,time
7from pathlib import Path
8driver,N,S,out=Path(sys.argv[1]),int(sys.argv[2]),int(sys.argv[3]),Path(sys.argv[4])
9spec=importlib.util.spec_from_file_location('real2driver',driver);drv=importlib.util.module_from_spec(spec);spec.loader.exec_module(drv)
10import torch
11hip=drv.Hip(torch)
12pos=torch.zeros(1,dtype=torch.int32,device='cuda');tok=torch.zeros(1,dtype=torch.int32,device='cuda')
13cap=131072
14def emit():
15 for _ in range(N):hip.launch('step_advance',1,1,pos,cap)
16torch.cuda.synchronize()
17g=hip.capture(emit)
18rows=[]
19try:
20 for s in range(S+1):
21 t0=time.perf_counter();hip.replay(g);t1=time.perf_counter();hip.sync();t2=time.perf_counter();v=int(tok.item());t3=time.perf_counter()
22 if s:rows.append(((t2-t0)*1e6,(t1-t0)*1e6,(t2-t1)*1e6,(t3-t2)*1e6))
23finally:hip.release_graph(g)
24cols=list(zip(*rows))
25res=dict(N=N,steps=S,step_us=list(cols[0]),median_step_us=statistics.median(cols[0]),median_launch_call_us=statistics.median(cols[1]),
26 median_sync_us=statistics.median(cols[2]),median_token_readback_us=statistics.median(cols[3]),position=int(pos.item()))
27out.write_text(json.dumps(res)+'\n')
28print('HIPMICRO',json.dumps({k:v for k,v in res.items() if k!='step_us'}))