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/regalloc_om/checkers_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 / regalloc_om / checkers_mutants.py` 52 lines · 3045 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Run after checkers.sh, inside its device-free namespace. Compile refusal is failure.""" 4 import os 5 from pathlib import Path 6 import subprocess 7 ROOT = Path(__file__).resolve().parents[2] 8 OUT = ROOT / 'build/checkers-om' 9 BRIDGE = Path(os.environ['OMEGA_BRIDGE']) 10 OMC = os.environ['OMEGA_OMC'] 11 CASES = [ 12 ('emit-var-pending', 'cg_em', 'pn = uint 3\n', 'pn = uint 2\n'), 13 ('emit-predicate-preserve', 'cg_em', 'if eq pred 0\n', 'if eq pred 1\n'), 14 ('prefetch-held', 'cg_em', 'put w 1 or get w 1 ulong shl uint 1 sb\n', 'put w 1 get w 1\n'), 15 ('consume-release', 'cg_em', 'put w 1 and get w 1 xor mk `4294967295`\n', 'put w 1 get w 1\n'), 16 ('loop-capacity', 'cg_em', 'if ge a 4\n', 'if ge a 3\n'), 17 ('interval-equal-start', 'cg_em', 'ge c b lt c endval\n', 'gt c b lt c endval\n'), 18 ('join-bssy-opcode', 'cg_reconv', 'ne rc_g w 2 54 ', 'ne rc_g w 2 55 '), 19 ('join-exit-opcode', 'cg_reconv', 'if ne rc_g w 3 46\n', 'if ne rc_g w 3 47\n'), 20 ('join-depth-decrement', 'cg_reconv', 'put w 0 rc_u sub rc_g w 0 1\n', 'put w 0 get w 0\n'), 21 ('join-relative-immediate', 'cg_reconv', 'ret sub add rc_g w 1 1 rc_g w 0\n', 'ret sub rc_g w 1 rc_g w 0\n'), 22 ] 23 def run(cmd, log, **kw): 24 with log.open('wb') as f: 25 p = subprocess.run(cmd, cwd=ROOT, stdout=f, stderr=subprocess.STDOUT, **kw) 26 if p.returncode: 27 raise RuntimeError(f'NOT_KILLED rc={p.returncode}: {log}') 28 def main(): 29 reference = (OUT/'oracle.out').read_bytes() 30 rows=[] 31 for name, stem, before, after in CASES: 32 work=OUT/'mutants'/name 33 work.mkdir(parents=True, exist_ok=True) 34 source=(ROOT/'om/codegen'/f'{stem}.om').read_text() 35 if source.count(before)!=1: raise RuntimeError(f'{name}: nonunique anchor') 36 om=work/f'{stem}.om'; om.write_text(source.replace(before,after)) 37 generated=work/f'{stem}.c' 38 with generated.open('wb') as f, (work/'compile.log').open('wb') as e: 39 p=subprocess.run(['sh',str(BRIDGE/'tools/bridge-seeded'),'c',str(om)],cwd=ROOT, 40 env=dict(os.environ,OMEGA_SEEDED_OMC=OMC),stdout=f,stderr=e) 41 if p.returncode: raise RuntimeError(f'{name}: NOT_KILLED compiler rc={p.returncode}') 42 units=[str(generated) if x==stem else f'src/cudapp_om_{x}.c' for x in ('cg_em','cg_reconv')] 43 binary=work/'checkers' 44 run([os.environ.get('CC','cc'),'-std=gnu11','-O2','-ffunction-sections','-fdata-sections','-Isrc', 45 'tests/regalloc_om/checkers.c',*units,'-Wl,--gc-sections','-o',str(binary)],work/'link.log') 46 run([str(binary)],work/'exercise.out') 47 if (work/'exercise.out').read_bytes()==reference: raise RuntimeError(f'{name}: SURVIVED') 48 rows.append(f'{name}\tcompile=0\texercise=0\tdifferential=1') 49 print('KILLED',rows[-1],flush=True) 50 (OUT/'mutants.tsv').write_text('\n'.join(rows)+'\n') 51 print(f'PASS checker recompiled Omega semantic mutants={len(rows)}') 52 if __name__=='__main__': main()