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_admit_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_admit_mutants.py` 32 lines · 2388 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 import os 4 from pathlib import Path 5 import subprocess 6 import tempfile 7 ROOT=Path(__file__).resolve().parents[1];OUT=Path(os.environ.get('OUT_DIR','build')) 8 BRIDGE=Path(os.environ['OMEGA_BRIDGE']);ENV=dict(os.environ,OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC']) 9 source=(ROOT/'om/codegen/pf_admit.om').read_text() 10 mutants=[('mutant-limit','gt m 2','gt m 1'),('mc-ceiling','gt k 4096','gt k 2048'),('mc-width','lt e 4','lt e 8'),('rl-ceiling','gt k 16384','gt k 8192'),('rl-width','gt e 1024','gt e 128'),('tiling','ne rem t div e 32 0','ne rem t div e 16 0'),('shared','mul t 512','mul t 256')] 11 def run(args,**kw):return subprocess.run(args,cwd=ROOT,env=ENV,text=True,**kw) 12 link=['cc','-std=gnu11','-O2','-Isrc','tests/codegen_pfhost_admit_diff.c',str(OUT/'codegen_pfhost_oracle.o')] 13 with tempfile.TemporaryDirectory(prefix='pfhost-admit-mutants-') as td: 14 tmp=Path(td) 15 for name,before,after in mutants: 16 if source.count(before)!=1:raise SystemExit('ambiguous site '+name) 17 om=tmp/(name+'.om');c=tmp/(name+'.c');exe=tmp/name;om.write_text(source.replace(before,after)) 18 with c.open('w') as f:r=run(['sh',str(BRIDGE/'tools/bridge-seeded'),'c',str(om)],stdout=f) 19 if r.returncode:raise SystemExit(name+' converter failed, not killed') 20 r=run(link+[str(c),str(OUT/'libomega_gpu.a'),'-lpthread','-lm','-o',str(exe)]) 21 if r.returncode:raise SystemExit(name+' link failed, not killed') 22 r=run([str(exe)],capture_output=True) 23 if r.returncode!=1 or 'PFHOST-ADMIT-DIFF FAIL' not in r.stderr:raise SystemExit(name+' survived') 24 print('PFHOST-ADMIT MUTANT '+name+' KILLED',flush=True) 25 missing=tmp/'missing.o';archive=tmp/'missing.a' 26 if run(['cc','-O2','-Isrc','-Domega_pf_admit=removed_omega_pf_admit','-c','src/cudapp_om_pf_admit.c','-o',str(missing)]).returncode:raise SystemExit('negative compile failed') 27 objects=[str(p) for p in OUT.glob('*.o') if p.name not in ('cudapp_om_pf_admit.o','codegen_pfhost_oracle.o')] 28 if run(['ar','rcs',str(archive),*objects,str(missing)]).returncode:raise SystemExit('negative archive failed') 29 r=run(link+[str(archive),'-lpthread','-lm','-o',str(tmp/'missing')],capture_output=True) 30 if r.returncode==0 or 'omega_pf_admit' not in r.stderr:raise SystemExit('strong-link negative failed') 31 print('PFHOST-ADMIT STRONG-LINK PASS') 32 print('PFHOST-ADMIT MUTANTS PASS (7 killed)')