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 / graph / headscale-mutants.py

26 lines · 1726 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/graph/headscale.om').read_text()
5cc=os.environ.get('CC','cc')
6bridge=pathlib.Path(os.environ['OMEGA_BRIDGE'])
7env=dict(os.environ,OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC'])
8test=root/'tests/test_graph_headscale.c'
9mutants=[('identity','528482304','1065353216'),('zero','528482304','0'),('negative','528482304','2675965952'),('half','528482304','520093696'),('skip','len x','0'),('add','mul get x i','add get x i')]
10with tempfile.TemporaryDirectory() as td:
11 d=pathlib.Path(td)
12 subprocess.run([cc,'-O2','-ffp-contract=off','-I'+str(root/'src'),str(test),str(root/'src/cudapp_om_graph_headscale.c'),'-o',str(d/'green')],check=True)
13 subprocess.run([str(d/'green')],check=True)
14 p=subprocess.run([cc,'-I'+str(root/'src'),str(test),'-o',str(d/'missing')],capture_output=True)
15 if p.returncode==0: raise SystemExit('FAIL strong link negative control')
16 print('PASS missing binding refused')
17 for name,old,new in mutants:
18 assert source.count(old)==1
19 om=d/(name+'.om'); om.write_text(source.replace(old,new))
20 with (d/'mut.c').open('w') as out:
21 subprocess.run(['sh',str(bridge/'tools/bridge-seeded'),'--runtime-views','c',str(om)],env=env,stdout=out,check=True)
22 subprocess.run([cc,'-O2','-ffp-contract=off','-I'+str(root/'src'),str(test),str(d/'mut.c'),'-o',str(d/'mut')],check=True)
23 p=subprocess.run([str(d/'mut')],capture_output=True)
24 if p.returncode==0: raise SystemExit('FAIL survived '+name)
25 print('KILLED '+name)
26print('PASS graph head scaling red control and six mutants')