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_dnn_half_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 / gpu_dnn_half_mutants.py` 41 lines · 2095 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Each altered seeded encoder must compile, then fail the native-word regression.""" 4 import os 5 from pathlib import Path 6 import shlex 7 import subprocess 8 import tempfile 9 10 source = Path("om/encoder/bw_enc_sm121.om").read_text() 11 mutants = [ 12 ("widen-opcode", "wd o `4278219312`", "wd o `4278219313`"), 13 ("widen-source", "or `536870912` rb o 2", "or `536870912` rb o 3"), 14 ("widen-format", "16640 ctl o `17811968`", "16641 ctl o `17811968`"), 15 ("narrow-opcode", "wd o 29444", "wd o 29445"), 16 ("narrow-format", "`2099200` ctl o `17704960`", "`2101248` ctl o `17704960`"), 17 ] 18 bridge = Path(os.environ["OMEGA_BRIDGE"]) / "tools/bridge-seeded" 19 env = dict(os.environ, OMEGA_SEEDED_OMC=os.environ["OMEGA_OMC"]) 20 with tempfile.TemporaryDirectory(prefix="dnn-half-mutants-") as tmp: 21 root = Path(tmp) 22 for name, before, after in mutants: 23 if source.count(before) != 1: 24 raise SystemExit(f"dnn-half-mutants: FAIL ({name}: mutation site not unique)") 25 path = root / f"{name}.om" 26 path.write_text(source.replace(before, after)) 27 generated = root / f"{name}.c" 28 with generated.open("w") as out: 29 subprocess.run(["sh", str(bridge), "c", str(path)], env=env, stdout=out, check=True) 30 binary = root / name 31 command = shlex.split(os.environ.get("CC", "cc")) + [ 32 "-std=gnu11", "-O2", "-ffp-contract=off", "-Isrc", "-Itests", "-I./m16", 33 "tests/gpu_dnn_half_test.c", "src/omega_numeric.c", str(generated), 34 os.environ.get("OMEGA_TEST_LIB", "build/libomega_gpu.a"), 35 "-lpthread", "-lm", "-o", str(binary)] 36 subprocess.run(command, check=True) 37 run = subprocess.run([str(binary)], text=True, capture_output=True) 38 if run.returncode != 1 or "dnn-half: FAIL" not in run.stdout: 39 raise SystemExit(f"dnn-half-mutants: FAIL ({name}: compiled mutant survived)") 40 print(f"dnn-half mutant {name}: KILLED", flush=True) 41 print("dnn-half-mutants: PASS (5 compiled seeded encoder mutants killed)")