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
CUDApp / om / prefill-shape / order-mutants.py
| 1 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | # External source-mutant verification, not a production dependency. |
| 3 | import hashlib,os,subprocess,tempfile |
| 4 | from pathlib import Path |
| 5 | root=Path(__file__).resolve().parents[2] |
| 6 | source=(root/'om/prefill-shape/order.om').read_text() |
| 7 | mutants={ |
| 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 | |
| 15 | ident=(root/'src/cudapp_om_prefill_order.ident').read_text().strip() |
| 16 | pins=dict(part.split('=',1) for part in ident.split() if '=' in part) |
| 17 | assert hashlib.sha256(Path(os.environ['OMEGA_OMC']).read_bytes()).hexdigest()==pins['omc'] |
| 18 | env=dict(os.environ,OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC']) |
| 19 | bridge=Path(os.environ['OMEGA_BRIDGE'])/'tools/bridge-seeded' |
| 20 | assert hashlib.sha256(bridge.read_bytes()).hexdigest()==pins['frontend'] |
| 21 | assert hashlib.sha256((bridge.parent.parent/'src/toc.om').read_bytes()).hexdigest()==pins['converter'] |
| 22 | with 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) |