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

20 lines · 1342 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]
4src=(root/'om/graph/table.om').read_text(); bridge=pathlib.Path(os.environ['OMEGA_BRIDGE']);cc=os.environ.get('CC','cc')
5env=dict(os.environ,OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC'])
6old='end\nret i\nend\nfn grpslot'
7mutants=[('original-tail',old,'end\nret add r sub add 128 j p\nend\nfn grpslot'),('tail-zero',old,'end\nret 0\nend\nfn grpslot'),('tail-plus-one',old,'end\nret add i 1\nend\nfn grpslot'),('pair-boundary','if lt j p','if le j p'),('rotary-half','p = div r 2','p = div r 4')]
8with tempfile.TemporaryDirectory() as td:
9 d=pathlib.Path(td)
10 def run(s,name):
11 om=d/'table.om';om.write_text(s);c=d/'table.c'
12 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)
13 subprocess.run([cc,'-O2','-I'+str(root/'src'),str(root/'tests/test_graph_table_perm.c'),str(c),'-o',str(d/'test')],check=True)
14 return subprocess.run([str(d/'test')]).returncode
15 if run(src,'green'):raise SystemExit('FAIL original')
16 for name,a,b in mutants:
17 assert src.count(a)==1
18 if run(src.replace(a,b),name)==0:raise SystemExit('FAIL survived '+name)
19 print('KILLED '+name)
20print('PASS graph table five compiled mutants')