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 / prefill-shape / order-mutants.py

33 lines · 1790 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2# External source-mutant verification, not a production dependency.
3import hashlib,os,subprocess,tempfile
4from pathlib import Path
5root=Path(__file__).resolve().parents[2]
6source=(root/'om/prefill-shape/order.om').read_text()
7mutants={
8 'drop_tail_guard':('if eq guard 1','if eq guard 0'),
9 'floor_grid':('div add tiles sub size 1 size','div tiles size'),
10 'bad_row_group':('at 3 37 size','at 3 37 1'),
11 'bad_column_shift':('at 2 0 group','at 2 0 0'),
12 'bad_row_mask':('sub size 1','sub size 2'),
13}
14
15ident=(root/'src/cudapp_om_prefill_order.ident').read_text().strip()
16pins=dict(part.split('=',1) for part in ident.split() if '=' in part)
17assert hashlib.sha256(Path(os.environ['OMEGA_OMC']).read_bytes()).hexdigest()==pins['omc']
18env=dict(os.environ,OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC'])
19bridge=Path(os.environ['OMEGA_BRIDGE'])/'tools/bridge-seeded'
20assert hashlib.sha256(bridge.read_bytes()).hexdigest()==pins['frontend']
21assert hashlib.sha256((bridge.parent.parent/'src/toc.om').read_bytes()).hexdigest()==pins['converter']
22with tempfile.TemporaryDirectory(prefix='prefill-order-mutants-') as t:
23 t=Path(t)
24 for name,(old,new) in mutants.items():
25 assert source.count(old)>=1
26 om=t/(name+'.om');om.write_text(source.replace(old,new,1))
27 c=t/(name+'.c');so=t/(name+'.so')
28 with c.open('w') as f:subprocess.run(['sh',str(bridge),'c',str(om)],env=env,stdout=f,check=True)
29 subprocess.run([os.environ.get('CC','cc'),'-O2','-shared','-fPIC',str(c),'-o',str(so)],check=True)
30 p=subprocess.run(['python3',str(root/'om/prefill-shape/order-check.py'),str(so)],capture_output=True,text=True)
31 assert p.returncode!=0,name+' escaped oracle'
32 assert 'AssertionError' in p.stderr,(name,p.stderr)
33 print(name+': caught',flush=True)