Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/amd-kfd-launch/plan-check.py # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / amd-kfd-launch / plan-check.py` 194 lines · 14104 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # External CPU oracle for the native Omega plan executor. 3 import json,os,struct,subprocess,sys,tempfile,shutil,hashlib,datetime 4 from pathlib import Path 5 root=Path(__file__).resolve().parents[2] 6 gate=Path(sys.argv[1]).resolve() 7 qemu=shutil.which('qemu-x86_64');assert qemu 8 cases=[] 9 def run(name,args,want): 10 p=subprocess.run(list(map(str,args)),capture_output=True,timeout=90) 11 assert p.returncode==want,(name,p.returncode,want,p.stdout[-3000:],p.stderr[-3000:]) 12 previous=cases[-1] if cases else None 13 log=gate/('plan-row-'+str(len(cases))) 14 log.with_suffix('.stdout').write_bytes(p.stdout);log.with_suffix('.stderr').write_bytes(p.stderr) 15 cases.append({'kind':'baseline','case':name,'command':list(map(str,args)),'exit':p.returncode,'expected':want,'timestamp':datetime.datetime.now(datetime.timezone.utc).isoformat(),'stdout_path':str(log.with_suffix('.stdout')),'stderr_path':str(log.with_suffix('.stderr')),'stdout_sha256':hashlib.sha256(p.stdout).hexdigest(),'stderr_sha256':hashlib.sha256(p.stderr).hexdigest()}) 16 if want not in (0,77) and not name.startswith(('CONTROL ','caller deadline','missing completion')): 17 assert previous and ' positive twin ' in previous['case'],name 18 assert b'OMEGA step open_kfd' in Path(previous['stdout_path']).read_bytes(),previous['case'] 19 previous['value_asserted']=True 20 pair(name,previous['case']) 21 return p 22 def pair(refusal,twin): 23 rows={r['case']:r for r in cases};r,t=rows[refusal],rows[twin] 24 assert t['exit']==t['expected'] and t['expected'] in (0,77) 25 assert t.get('value_asserted'),twin 26 a=[x for x in r['command'] if x!='env'];b=[x for x in t['command'] if x!='env'] 27 if len(a)==len(b):assert sum(x!=y for x,y in zip(a,b))==1,(refusal,a,b) 28 else: 29 assert abs(len(a)-len(b))==1,(refusal,a,b) 30 long,short=(a,b) if len(a)>len(b) else (b,a) 31 assert any(long[:i]+long[i+1:]==short for i in range(len(long))),(refusal,a,b) 32 common=[x if x==y else '' for x,y in zip(a,b)] if len(a)==len(b) else short 33 setup=hashlib.sha256(json.dumps(common).encode()).hexdigest() 34 r.update(kind='refusal',twin=twin,setup_sha256=setup);t.update(kind='twin',setup_sha256=setup) 35 def plan_value(p): 36 assert b'OMEGA_PLAN ids=[`1073741824`,`1073741824`,`1073741824`]\n' in p.stdout 37 assert b'packets=60 freed=all' in p.stderr 38 def slow_plan_value(p): 39 plan_value(p) 40 assert p.stdout.count(b'OMEGA alarm slow_dispatch_ns=')==3,p.stdout 41 def refuse(name,args,want,twinargs,verify): 42 twin='positive twin '+name 43 p=run(twin,twinargs,0);verify(p);cases[-1]['value_asserted']=True 44 p=run(name,args,want);pair(name,twin);return p 45 46 with tempfile.TemporaryDirectory(prefix='plan-',dir='/tmp') as td: 47 d=Path(td); nodes=d/'nodes'; node=nodes/'2';node.mkdir(parents=True) 48 (node/'gpu_id').write_text('1\n') 49 (node/'properties').write_text('gfx_target_version 90402\ndrm_render_minor 128\nsimd_count 32\nsimd_per_cu 4\nmax_waves_per_simd 8\narray_count 8\nsimd_arrays_per_engine 2\nnum_xcc 2\n') 50 weight=d/'weights';weight.write_bytes(bytes(8)+struct.pack('<256H',*([0x3f80]*256))+bytes(8)+struct.pack('<256f',*([1.0]*256))) 51 # Two independently parsed code objects, raw plan data, BF16 file widening, 52 # zero remainder, 20 dependent dispatches per step, and three generated tokens. 53 names=b'vaddvadd';data=struct.pack('<256f',*([1.0]*256)) 54 header=b'OMPLAN01'+struct.pack('<7Q',2,1,3,20,1,3,2) 55 codes=struct.pack('<4Q',0,4,4,4) 56 buffers=b''.join(struct.pack('<6Q',*b) for b in [(1024,3,0,0,1024,1),(1024,2,0,8,512,1),(1024,0,0,0,0,2)]) 57 prompt=struct.pack('&-; exec "$@"','number-stderr',*deadlineargv(value)] 82 p=run(arch+' positive twin closed stderr',closedstderr('0'),77) 83 assert b'OMEGA step open_kfd' in p.stdout 84 p=run(arch+' numeric diagnostic I/O failure',closedstderr('not-a-number'),74) 85 assert p.stdout==p.stderr==b'' 86 p=run(arch+' positive twin argc',planargv(pth),77) 87 assert b'OMEGA step open_kfd' in p.stdout 88 p=run(arch+' refuses argc',planargv(pth)[:-1],64) 89 assert p.stdout==b'OMEGA refuse plan field=argc\n' 90 mutations={ 91 'bad-magic':(0,b'BADPLAN!'), 'zero-code':(8,struct.pack('