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 / tools / c5 / mutants.py
| 1 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | """Verification-only mutation generator. No runtime policy is implemented here.""" |
| 3 | from pathlib import Path |
| 4 | import sys |
| 5 | |
| 6 | root = Path(__file__).resolve().parent |
| 7 | out = Path(sys.argv[1]) |
| 8 | policy = (root / "policy.om").read_text() |
| 9 | model = (root / "model.om").read_text() |
| 10 | cases = (root / "cases.om").read_text() |
| 11 | mutants = { |
| 12 | "deadline": ("policy", "eq limit 0 ge now limit", "eq limit 0 gt now limit"), |
| 13 | "overflow": ("policy", "if gt start sub UMAX budget", "if false"), |
| 14 | "owner": ("policy", "if or eq pid 0 ne pid owner", "if eq pid 0"), |
| 15 | "generation": ("policy", "ret and ne epoch 0 eq epoch token", "ret ne epoch 0"), |
| 16 | "range": ("policy", "ret le size sub capacity off", "ret true"), |
| 17 | "ack": ("policy", "if not ack", "if false"), |
| 18 | "order": ("policy", "if eq state CHANNEL\nret CONTEXT", "if eq state CHANNEL\nret CLOSED"), |
| 19 | "epoch": ("model", "put epochs p omega_c5_epoch get epochs p", "put epochs p get epochs p"), |
| 20 | "stale": ("model", "if ne token get epochs p", "if false"), |
| 21 | } |
| 22 | for name, (unit, old, new) in mutants.items(): |
| 23 | source = policy if unit == "policy" else model |
| 24 | if source.count(old) != 1: |
| 25 | raise SystemExit(f"FAIL: {name} mutation site count {source.count(old)}") |
| 26 | changed = source.replace(old, new) |
| 27 | content = changed + model if unit == "policy" else policy + changed |
| 28 | (out / f"{name}.om").write_text(content + cases) |