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/runtime/api_plan_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 / runtime / api_plan_mutants.py` 44 lines · 2182 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Two compiling source mutations per policy; the unchanged C oracle kills each.""" 4 import os 5 from pathlib import Path 6 import shlex 7 import subprocess 8 import tempfile 9 10 root = Path(__file__).resolve().parents[2] 11 env = dict(os.environ) 12 cc = shlex.split(os.environ.get('CC', 'cc')) 13 mutants = ( 14 ('mm', 0, 'gt m 8192', 'gt m 8191'), 15 ('mm', 0, 'budget = 1024', 'budget = 1023'), 16 ('at', 1, 'gt h 256', 'gt h 255'), 17 ('at', 1, 'lt l 4', 'lt l 3'), 18 ('ew', 2, 'gt dim 16384', 'gt dim 16383'), 19 ('ew', 2, 'ni = 131072', 'ni = 131071'), 20 ('bf', 3, 'w = ulong 16', 'w = ulong 32'), 21 ('bf', 3, 'put a 11 ulong 96', 'put a 11 ulong 95'), 22 ('da', 4, 'gt layers 64', 'gt layers 63'), 23 ('da', 4, 'depth = 4', 'depth = 3'), 24 ('rt', 5, 'e = 128', 'e = 256'), 25 ('rt', 5, 'add ulong 8 get a 2', 'add ulong 7 get a 2'), 26 ) 27 for unit, family, old, new in mutants: 28 name = 'api_' + unit + '_plan' 29 source = (root / 'om/components' / (name + '.om')).read_text() 30 assert source.count(old) == 1, (name, old) 31 with tempfile.TemporaryDirectory(prefix='cudapp-api-plan-') as tmp: 32 tmp = Path(tmp) 33 om = tmp / (name + '.om') 34 om.write_text(source.replace(old, new)) 35 generated = tmp / ('cudapp_om_' + name + '.c') 36 mutant_env = dict(env, OMEGA_UNITS=name + '=' + str(om), OMEGA_UNITS_DEST=str(tmp)) 37 subprocess.run(['sh', str(root / 'om/units.sh')], env=mutant_env, cwd=root, check=True) 38 others = [str(p) for p in sorted((root / 'src').glob('cudapp_om_api_*_plan.c')) if p.name != 'cudapp_om_' + name + '.c'] 39 exe = tmp / 'mutant' 40 subprocess.run(cc + ['-O2', '-Wall', '-Wextra', '-Werror', '-I' + str(root / 'src'), str(root / 'tests/runtime/api_plan_unit.c'), str(generated)] + others + ['-o', str(exe)], check=True) 41 result = subprocess.run([str(exe), str(family)], capture_output=True, text=True) 42 assert result.returncode != 0 and 'API PLAN differential FAIL' in result.stderr, result 43 print('API PLAN mutant killed:', name, old, '=>', new, flush=True) 44 print('API PLAN 12 source mutants PASS')