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/qmma_probe_rest_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 / qmma_probe_rest_mutants.py` 41 lines · 2817 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] 8 BRIDGE=Path(os.environ['OMEGA_BRIDGE']) 9 ENV=dict(os.environ,OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC']) 10 host=(ROOT/'om/codegen/qm_host.om').read_text() 11 selfsrc=(ROOT/'om/codegen/qm_self.om').read_text() 12 # Link exactly what test-qmma-probe-rest links: the make recipe passes $(QMMA_REST_SRC). 13 sources=os.environ.get('QMMA_REST_SRC','').split() 14 for unit in ('src/cudapp_om_qm_host.c','src/cudapp_om_qm_self.c'): 15 if unit not in sources:raise SystemExit('FAIL QMMA_REST_SRC lacks '+unit+'; run make test-qmma-probe-rest-mutants') 16 mutants=[('mark','host','eq a 16 eq b','eq a 15 eq b'),('read','host','shl b 8','shl b 9'),('f2-word','host','ne e `75526399`','ne e `75526398`'),('qmma-word','host','65535 29306','65535 29307'),('hmma-word','host','`4294967040` 268288','`4294967040` 268289'),('counts','host','add op 65536','add op 65535'),('self-store','self','put x 6 64','put x 6 68'),('self-f2','self','put x 13 1\nput x 6 `1178940467`','put x 13 0\nput x 6 `1178940467`')] 17 def run(args,**kwargs):return subprocess.run(args,cwd=ROOT,env=ENV,text=True,**kwargs) 18 def link(src,exe):return run(['cc','-std=gnu11','-O2','-Isrc','-ffunction-sections','-fdata-sections','-Wl,--gc-sections','tests/qmma_probe_rest_test.c',*src,'-lm','-o',str(exe)],capture_output=True) 19 with tempfile.TemporaryDirectory(prefix='qmma-rest-mutants-') as td: 20 tmp=Path(td) 21 for name,unit,before,after in mutants: 22 text=host if unit=='host' else selfsrc 23 if text.count(before)!=1:raise SystemExit('ambiguous mutant '+name) 24 om=tmp/(name+'.om');c=tmp/(name+'.c');exe=tmp/name 25 changed=text.replace(before,after) 26 if unit=='self':changed=(ROOT/'om/codegen/cg_qmma.om').read_text()+'\n'+changed 27 om.write_text(changed) 28 with c.open('w') as f:r=run(['sh',str(BRIDGE/'tools/bridge-seeded'),'c',str(om)],stdout=f) 29 if r.returncode:raise SystemExit(name+' converter failed, not a kill') 30 replaced='src/cudapp_om_qm_'+('host' if unit=='host' else 'self')+'.c' 31 r=link([str(c) if p==replaced else p for p in sources],exe) 32 if r.returncode:raise SystemExit(name+' link failed, not a kill: '+r.stderr) 33 r=run([str(exe)],capture_output=True) 34 if r.returncode!=1 or 'QMMA-REST' not in r.stderr or 'FAIL' not in r.stderr:raise SystemExit(name+' survived: '+r.stdout+r.stderr) 35 print('QMMA-REST MUTANT '+name+' KILLED',flush=True) 36 for unit in ('host','self'): 37 symbol='omega_qm_'+unit 38 r=link([p for p in sources if p!='src/cudapp_om_qm_'+unit+'.c'],tmp/('missing-'+unit)) 39 if r.returncode==0 or symbol not in r.stderr:raise SystemExit('strong-link '+unit+' failed') 40 print('QMMA-REST STRONG-LINK '+unit+' PASS',flush=True) 41 print('QMMA-REST MUTANTS PASS (8 killed)')