Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/om/standalone-oracles/mutants.py # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / om / standalone-oracles / mutants.py` 38 lines · 2414 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 # External verification, never a production dependency. Run in device-empty bwrap. 3 import hashlib, os, subprocess, tempfile 4 from pathlib import Path 5 root=Path(__file__).resolve().parents[2] 6 lane=root/'om/standalone-oracles' 7 source=(lane/'oracles.om').read_text() 8 pins=dict(s.split('=',1) for s in (root/'src/cudapp_om_standalone_oracles.ident').read_text().split() if '=' in s) 9 bridge=Path(os.environ['OMEGA_BRIDGE'])/'tools/bridge-seeded' 10 assert hashlib.sha256(Path(os.environ['OMEGA_OMC']).read_bytes()).hexdigest()==pins['omc'] 11 assert hashlib.sha256(bridge.read_bytes()).hexdigest()==pins['frontend'] 12 assert hashlib.sha256((bridge.parent.parent/'src/toc.om').read_bytes()).hexdigest()==pins['converter'] 13 assert not list(Path('/dev').glob('nvidia*')), 'run inside the documented device-empty bwrap' 14 env=dict(os.environ,OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC']) 15 mutants={ 16 'vadd_multiplier':('`2654435761`','`2654435760`'), 17 'grid_round_down':('ret div add a 255 256','ret div a 256'), 18 'mirror_threshold':('ge b 1024','ge b 1025'), 19 'cache_admit_extra':('if lt a 2','if lt a 3'), 20 'reading_boundary':('if eq op 15\nif le a 64','if eq op 15\nif lt a 64'), 21 'budget_short':('ret `2147483648`','ret `2147483647`'), 22 'accept_infinity':('if lt and a `2147483647` `2139095040`','if le and a `2147483647` `2139095040`'), 23 'rng_multiplier':('`1664525`','`1664526`'), 24 'norm_sparse_tail':('if eq a 5119','if eq a 5120'), 25 } 26 with tempfile.TemporaryDirectory(prefix='standalone-mutants-') as directory: 27 tmp=Path(directory) 28 for name,(old,new) in mutants.items(): 29 assert source.count(old)==1,(name,'site not unique') 30 om=tmp/(name+'.om');om.write_text(source.replace(old,new)) 31 c=tmp/(name+'.c');exe=tmp/name 32 with c.open('w') as output: 33 subprocess.run(['sh',str(bridge),'c',str(om)],env=env,stdout=output,check=True) 34 subprocess.run([os.environ.get('CC','cc'),'-O2','-ffp-contract=off',str(lane/'scalar-check.c'),str(lane/'oracle-c.c'),str(c),'-o',str(exe)],check=True) 35 result=subprocess.run([str(exe)],capture_output=True,text=True) 36 assert result.returncode==1 and 'scalar mismatch' in result.stderr,(name,'escaped or failed for the wrong reason',result) 37 print('KILLED '+name+': '+result.stderr.strip(),flush=True) 38 print('PASS standalone Omega mutants: all nine compiled source mutants killed',flush=True)