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
CUDApp / om / prefill-shape / scoped-mutants.py
| 1 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | # External call-isolation fault tests; not a production dependency. |
| 3 | from pathlib import Path |
| 4 | import os,subprocess,sys,tempfile |
| 5 | r=Path(__file__).resolve().parents[2] |
| 6 | archive=Path(sys.argv[1]).resolve();src=(r/'src/omega_gpu_pfgemm.c').read_text() |
| 7 | mutants={ |
| 8 | 'ignore_scoped_options':('if (scoped) s = *scoped;','if (scoped && 0) s = *scoped;'), |
| 9 | 'leak_options_to_global':('const OmegaQgSpec s = qg_scoped_spec(rt, warps, wait, group);','omega_gpu_pf_qgemm_set_shape(rt, warps, wait); omega_gpu_pf_qgemm_set_group(group);\n const OmegaQgSpec s = qg_scoped_spec(rt, warps, wait, group);'), |
| 10 | 'wrong_tile_height':('uint64_t p[32] = {5, 0, 16, s.rt, 1};','uint64_t p[32] = {5, 0, 8, s.rt, 1};'), |
| 11 | } |
| 12 | with tempfile.TemporaryDirectory(prefix='qg-scoped-faults-') as d: |
| 13 | d=Path(d) |
| 14 | for name,(old,new) in mutants.items(): |
| 15 | assert src.count(old)==1,name |
| 16 | f=d/(name+'.c');f.write_text(src.replace(old,new));exe=d/name |
| 17 | subprocess.run([os.environ.get('CC','cc'),'-std=gnu11','-O2','-Wall','-Wextra','-Werror','-I'+str(r/'src'),str(f),str(r/'om/prefill-shape/scoped-check.c'),str(archive),'-Wl,--wrap=omega_gpu_pf_open_locked','-Wl,--wrap=omega_gpu_pf_kernel_locked','-lpthread','-lm','-o',str(exe)],check=True) |
| 18 | q=subprocess.run([str(exe)],capture_output=True,text=True) |
| 19 | assert q.returncode==1 and 'scoped qgemm isolation: FAIL' in q.stdout,(name,q.returncode,q.stdout,q.stderr) |
| 20 | print(name+': caught',flush=True) |