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 / 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/admit.om').read_text() |
| 7 | mutants={ |
| 8 | 'drop_column_offset':('last = add last 36','last = add last 0'), |
| 9 | 'overflow_offset_boundary':('le last 8388607','le last 8388643'), |
| 10 | 'drop_last_row_group':('sub mul rt 16 8','sub mul rt 16 16'), |
| 11 | 'drop_large_shape':('eq rt 8 eq warps 8','eq rt 7 eq warps 8'), |
| 12 | 'admit_large_overbudget_warps':('eq rt 8 eq warps 8','eq rt 8 eq warps 16'), |
| 13 | 'drop_small_shape':('eq rt 2 eq warps 4','eq rt 3 eq warps 4'), |
| 14 | 'drop_incumbent':('eq rt 4 eq warps 8','eq rt 5 eq warps 8'), |
| 15 | 'admit_unsafe_one_row_group':('eq rt 2 eq warps 4','eq rt 1 eq warps 2'), |
| 16 | 'ignore_warp_count':('eq rt 2 eq warps 4','eq rt 2 eq rt 2'), |
| 17 | } |
| 18 | ident=(root/'src/cudapp_om_prefill_shape.ident').read_text().strip() |
| 19 | pins=dict(part.split('=',1) for part in ident.split() if '=' in part) |
| 20 | assert hashlib.sha256(Path(os.environ['OMEGA_OMC']).read_bytes()).hexdigest()==pins['omc'] |
| 21 | env=dict(os.environ,OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC']) |
| 22 | bridge=Path(os.environ['OMEGA_BRIDGE'])/'tools/bridge-seeded' |
| 23 | assert hashlib.sha256(bridge.read_bytes()).hexdigest()==pins['frontend'] |
| 24 | assert hashlib.sha256((bridge.parent.parent/'src/toc.om').read_bytes()).hexdigest()==pins['converter'] |
| 25 | with tempfile.TemporaryDirectory(prefix='prefill-shape-mutants-') as t: |
| 26 | t=Path(t) |
| 27 | for name,(old,new) in mutants.items(): |
| 28 | assert source.count(old)==1 |
| 29 | om=t/(name+'.om');om.write_text(source.replace(old,new)) |
| 30 | c=t/(name+'.c');so=t/(name+'.so') |
| 31 | with c.open('w') as f:subprocess.run(['sh',str(bridge),'c',str(om)],env=env,stdout=f,check=True) |
| 32 | subprocess.run([os.environ.get('CC','cc'),'-O2','-shared','-fPIC',str(c),'-o',str(so)],check=True) |
| 33 | p=subprocess.run(['python3',str(root/'om/prefill-shape/check.py'),str(so)],capture_output=True,text=True) |
| 34 | assert p.returncode!=0,name+' escaped oracle' |
| 35 | assert 'AssertionError' in p.stderr,(name,p.stderr) |
| 36 | print(name+': caught',flush=True) |