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 / om / apirest / pfhost-mutants.py

29 lines · 1694 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2import os,pathlib,subprocess,tempfile
3root=pathlib.Path(__file__).resolve().parents[2]
4source=(root/'om/apirest/pfhost.om').read_text()
5entry=(root/'om/apirest/pfreg.om').read_text()
6env=dict(os.environ,OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC'])
7cc=os.environ.get('CC','cc'); bridge=pathlib.Path(os.environ['OMEGA_BRIDGE'])
8mutants=[('limit','65536','65535'),('warp','ulong 32','ulong 31'),('compare','if gt mul','if ge mul'),('poison','-999.0f32','-998.0f32'),('count','add n 1','add n 2'),('skip','len x','0')]
9with tempfile.TemporaryDirectory() as td:
10 d=pathlib.Path(td)
11 def build(src,name):
12 files=[]
13 for unit,suffix in [('count',''),('reg',entry)]:
14 om=d/(unit+'.om');om.write_text(src+'\n'+suffix)
15 c=d/(unit+'.c')
16 with c.open('w') as out: subprocess.run(['sh',str(bridge/'tools/bridge-seeded'),'--runtime-views','c',str(om)],env=env,stdout=out,check=True)
17 files.append(str(c))
18 exe=d/name
19 subprocess.run([cc,'-O2','-ffp-contract=off','-I'+str(root/'src'),str(root/'tests/test_prefill_host_rest.c'),*files,'-o',str(exe)],check=True)
20 return subprocess.run([str(exe)]).returncode
21 if build(source,'green'): raise SystemExit('FAIL original')
22 p=subprocess.run([cc,'-I'+str(root/'src'),str(root/'tests/test_prefill_host_rest.c'),'-o',str(d/'missing')],capture_output=True)
23 if p.returncode==0: raise SystemExit('FAIL missing binding accepted')
24 print('PASS strong binding negative control')
25 for name,old,new in mutants:
26 assert source.count(old)==1
27 if build(source.replace(old,new),name)==0: raise SystemExit('FAIL survived '+name)
28 print('KILLED '+name)
29print('PASS prefill host red control and six mutants')