Skip to content

Commit ebdb81d

Browse files
committed
Compare arena-index prefix relocation on hosted GPU
1 parent fa76bef commit ebdb81d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎tools/gpu-return-trace.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111
assert hashlib.sha256(fixture.read_bytes()).hexdigest()==receipt['generated_c_sha256']
1212
shutil.copyfile(fixture,out/'pin_program.c')
1313
results=[]
14-
for name,kq in [('host-trace',0)]:
14+
for name,kq in [('host-trace',0),('index-prefix',0)]:
1515
d=out/name;d.mkdir(exist_ok=True)
1616
rt=d/'rt';shutil.copytree(root/'rt',rt,dirs_exist_ok=True)
1717
gpu=(rt/'gpu.h').read_text()
18-
if name=='phase-trace':
18+
if name=='index-prefix':
19+
gpu=gpu.replace('if((mask&((KW)1<<i)) && v-base<bytes) v=KPTR(c,h0)+(v-base);',
20+
'if((mask&((KW)1<<i)) && k_in(&out,v) && KIX(&out,v)>=lo && KIX(&out,v)<out.hp) v=KPTR(c,h0+KIX(&out,v)-lo);')
21+
gpu=gpu.replace('KW relocated=KPTR(c,h0)+(root-base);','KW relocated=KPTR(c,h0+KIX(&out,root)-lo);')
22+
elif name=='phase-trace':
1923
validator=r"""
2024
KNOINLINE bool k_trace_value(KTHR KCtx *c,KW v,KW root,KU stage) {
2125
if(KIS_LI(v,0) || (k_in(c,v) && !(v&7) && c->H[KIX(c,v)-1]==(K_BARE|2))) return true;
@@ -60,7 +64,7 @@
6064
assert gpu.count(old)==1
6165
gpu=gpu.replace(old,'return r; // diagnostic control only\n '+old)
6266

63-
if name=='host-trace':
67+
if name in ('host-trace','index-prefix'):
6468
host=(rt/'gpuhost.h').read_text()
6569
helper=r"""
6670
static KW trace_roots[512];static unsigned trace_nr;

0 commit comments

Comments
 (0)