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/graph/residue-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 / graph / residue-mutants.py` 49 lines · 2570 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Compile semantic Omega mutants and require the real differential to turn red. 4 Run only inside the documented bwrap environment, including every child. 5 """ 6 import os 7 from pathlib import Path 8 import shlex 9 import subprocess 10 11 root = Path(__file__).resolve().parents[2] 12 os.chdir(root) 13 out = Path(os.environ.get('OUT_DIR', 'build')).resolve() 14 work = out / 'graph-residue-mutants' 15 work.mkdir(parents=True, exist_ok=True) 16 def run(args, **kw): 17 return subprocess.run(args, check=True, **kw) 18 expected = subprocess.check_output([str(out / 'graph-residue')]) 19 mutants = [ 20 ('poison', 'hello_host', 'hello.om', 'uint `4290838510`', 'uint `4290838509`'), 21 ('input-period', 'hello_host', 'hello.om', 'rem i 7', 'rem i 6'), 22 ('checker-sub', 'hello_host', 'hello.om', 'bitcast uint add x y', 'bitcast uint sub x y'), 23 ('shape-cap', 'model_graph_residue', 'residue.om', 'gt hd 5120', 'gt hd 4096'), 24 ('timeline-room', 'model_graph_residue', 'residue.om', 'sub get c 2 get c 0', 'add sub get c 2 get c 0 1'), 25 ('perm-stride', 'model_graph_table', 'table.om', 'mul rem div j 4 32 16', 'mul rem div j 4 32 8'), 26 ('load-scoreboard', 'hello_plan', 'hello-plan.om', 'wb = 0', 'wb = 1'), 27 ] 28 for name, unit, filename, old, new in mutants: 29 source = (root / 'om/graph' / filename).read_text() 30 if source.count(old) != 1: 31 raise SystemExit(f'FAIL {name}: mutation site count {source.count(old)}') 32 lane = work / name 33 lane.mkdir(exist_ok=True) 34 om = lane / 'mutant.om' 35 om.write_text(source.replace(old, new)) 36 env = dict(os.environ, OMEGA_UNITS=f'{unit}={om}', OMEGA_UNITS_DEST=str(lane)) 37 with (lane/'generate.log').open('w') as log: 38 run(['sh', 'om/units.sh'], env=env, stdout=log, stderr=log) 39 binary = lane / 'test' 40 with (lane/'compile.log').open('w') as log: 41 run(shlex.split(os.environ.get('CC','cc')) + shlex.split(os.environ['GRAPH_RESIDUE_FLAGS']) + 42 ['tests/test_graph_residue.c', str(lane/f'cudapp_om_{unit}.c'), str(out/'libomega_gpu.a'), 43 '-lpthread','-lm','-o',str(binary)], stdout=log, stderr=log) 44 result = subprocess.run([str(binary)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 45 (lane/'run.log').write_bytes(result.stdout) 46 if result.returncode == 0 and result.stdout == expected: 47 raise SystemExit(f'FAIL mutant {name} survived') 48 print(f'mutant {name} killed rc={result.returncode}', flush=True) 49 print(f'PASS graph residue: {len(mutants)} compiled semantic mutants killed')