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/tests/codegen_pfhost_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 / tests / codegen_pfhost_mutants.py` 38 lines · 2179 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Verification-only Omega source mutants; never edit canonical generated output.""" 4 import os 5 from pathlib import Path 6 import subprocess 7 import sys 8 import tempfile 9 10 root = Path(__file__).resolve().parents[1] 11 out = Path(sys.argv[1]).resolve() 12 parts = [root / 'om/codegen' / name for name in ( 13 'cg_pfhost_emit.om', 'cg_pfhost_rl.om', 'cg_pfhost_mc.om', 'cg_pfhost.om')] 14 mutants = ( 15 ('router-address', 1, 'ph_wide ins st 0 8 mul get cf 0 4 0', 'ph_wide ins st 0 8 mul get cf 0 8 0'), 16 ('combine-address', 2, 'ph_wide ins st 1 5 mul get cf 1 4 1', 'ph_wide ins st 1 5 mul get cf 1 8 1'), 17 ) 18 for name, index, before, after in mutants: 19 with tempfile.TemporaryDirectory(prefix='pfhost-mutant-') as work: 20 tmp = Path(work) 21 src = parts[index].read_text() 22 if src.count(before) != 1: 23 raise SystemExit('FAIL mutant site must be unique: ' + name) 24 mutant = tmp / parts[index].name 25 mutant.write_text(src.replace(before, after)) 26 sources = parts.copy() 27 sources[index] = mutant 28 env = dict(os.environ, OMEGA_UNITS='cg_pfhost=' + ','.join(map(str, sources)), OMEGA_UNITS_DEST=str(tmp)) 29 subprocess.run(['sh', 'om/units.sh'], cwd=root, env=env, check=True, stdout=subprocess.DEVNULL) 30 subprocess.run([os.environ.get('CC', 'cc'), '-O2', '-Wall', '-Wextra', '-Werror', '-Isrc', '-Itests', 31 'tests/codegen_pfhost_diff.c', str(tmp / 'cudapp_om_cg_pfhost.c'), 32 str(out / 'codegen_pfhost_oracle.o'), str(out / 'libomega_gpu.a'), '-lpthread', '-lm', 33 '-o', str(tmp / 'diff')], cwd=root, check=True) 34 run = subprocess.run([str(tmp / 'diff'), '--quick'], cwd=root, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 35 if run.returncode != 1 or not run.stdout.startswith('FAIL '): 36 raise SystemExit('FAIL mutant not killed by differential: ' + name + '\n' + run.stdout) 37 print('PASS Omega mutant killed: ' + name + ': ' + run.stdout.strip(), flush=True) 38 print('PASS pfhost Omega source mutants killed', flush=True)