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/gpu_om_ir_boundary_mutant.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 / gpu_om_ir_boundary_mutant.py` 53 lines · 2582 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Reverting the generic replay bound must fail the same boundary regression. 4 5 The default build replays through the seeded unit (omega_cg_replay), whose bound 6 is the BW_IR_LAST argument; the C replay under CUDAPP_MIGRATION_PENDING_C_CODEGEN_BASE 7 is the oracle and carries its own bound. Each is reverted where it is compiled, 8 and the unmutated source must pass in both builds first, so a kill is the bound 9 and not a broken build. 10 """ 11 import os 12 from pathlib import Path 13 import shlex 14 import subprocess 15 import tempfile 16 17 source = Path("src/omega_gpu_om_ir.c").read_text() 18 OLD_BOUND = "BW_IR_ATOMG_ADD_F32_STRONG_GPU" 19 cases = [ 20 # (name, extra cflags, site, reverted site) 21 ("omega-replay", [], " BW_IR_LAST) != OMEGA_OK) return OMEGA_OM_IR_BRIDGE;", 22 " " + OLD_BOUND + ") != OMEGA_OK) return OMEGA_OM_IR_BRIDGE;"), 23 ("c-oracle", ["-DCUDAPP_MIGRATION_PENDING_C_CODEGEN_BASE=1"], "r[0] > (uint64_t)BW_IR_LAST", 24 "r[0] > (uint64_t)" + OLD_BOUND), 25 ] 26 cc = shlex.split(os.environ.get("CC", "cc")) 27 lib = os.environ.get("OMEGA_TEST_LIB", "build/libomega_gpu.a") 28 29 30 def run(root, name, flags, text): 31 unit = root / (name + ".c") 32 unit.write_text(text) 33 binary = root / name 34 subprocess.run(cc + ["-std=gnu11", "-O2", "-Isrc", "-Itests", "-I./m16"] + flags + 35 ["-o", str(binary), "tests/gpu_om_ir_boundary_test.c", str(unit), lib, 36 "-lpthread", "-lm"], check=True) 37 return subprocess.run([str(binary)], text=True, capture_output=True) 38 39 40 with tempfile.TemporaryDirectory(prefix="om-ir-boundary-") as tmp: 41 root = Path(tmp) 42 for name, flags, site, reverted in cases: 43 if source.count(site) != 1: 44 raise SystemExit(f"om-ir-boundary-mutant: FAIL ({name} mutation site not unique)") 45 control = run(root, name + "-control", flags, source) 46 if control.returncode != 0: 47 raise SystemExit(f"om-ir-boundary-mutant: FAIL ({name} unmutated control failed: " 48 f"{control.stderr.strip()})") 49 mutant = run(root, name + "-mutant", flags, source.replace(site, reverted)) 50 if mutant.returncode != 1 or "om-ir-boundary: FAIL" not in mutant.stderr: 51 raise SystemExit(f"om-ir-boundary-mutant: FAIL ({name} reverted bound survived)") 52 print(f"om-ir-boundary-mutant: {name} control PASS, reverted-bound mutant killed") 53 print("om-ir-boundary-mutant: PASS (Omega replay and C oracle reverted-bound mutants killed)")