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 / tests / dagsim / mutant_omega.sh
| 1 | #!/bin/sh |
| 2 | # Kill five semantic mutants of om/tools/dag_eval.om. |
| 3 | # Each mutant is recompiled through the pinned bridge and linked as the |
| 4 | # default scheduler. A kill is a changed eval of a fixture the unmutated |
| 5 | # scheduler still answers correctly. A record flip of that answer must fail cmp. |
| 6 | set -eu |
| 7 | ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) |
| 8 | cd "$ROOT" |
| 9 | OMC=${OMEGA_OMC:-$HOME/work/cudastack/omega-mv/seed/out/omc} |
| 10 | BRIDGE=${OMEGA_BRIDGE:-$HOME/work/cudastack/omega-bridge} |
| 11 | PIN=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f |
| 12 | [ "$(sha256sum < "$OMC" | cut -c1-64)" = "$PIN" ] || { echo "NOT_RUN: omc pin"; exit 3; } |
| 13 | ORACLE=${1:-} |
| 14 | tmp=$(mktemp -d) |
| 15 | trap 'rm -rf "$tmp"' EXIT |
| 16 | CC=${CC:-cc} |
| 17 | cflags="-std=gnu11 -Wall -Wextra -D_GNU_SOURCE -O2 -ffp-contract=off -Isrc -Itools/dagsim" |
| 18 | units="src/cudapp_om_core_sha.c src/cudapp_om_cm_sort.c src/cudapp_om_cm_math.c src/cudapp_om_cm_fit.c src/cudapp_om_cm_stats.c src/cudapp_om_cm_features.c src/cudapp_om_cm_quantile.c src/cudapp_om_cm_decision.c src/cudapp_om_cm_prediction.c src/cudapp_om_cm_calibration.c src/cudapp_om_cm_blob.c src/cudapp_om_cm_digest.c" |
| 19 | units="$units src/cudapp_om_cm_route.c" |
| 20 | $CC $cflags -c -o "$tmp/dagsim.o" tools/dagsim/dagsim.c |
| 21 | $CC $cflags -c -o "$tmp/rx.o" src/runtime/rx_costmodel.c |
| 22 | if [ -z "$ORACLE" ]; then |
| 23 | OMEGA_SEEDED_OMC="$OMC" sh "$BRIDGE/tools/bridge-seeded" c om/tools/dag_eval.om > "$tmp/base.c" |
| 24 | $CC $cflags -c -o "$tmp/base.o" "$tmp/base.c" |
| 25 | $CC $cflags -o "$tmp/oracle" tools/dagsim/dagsim_cli.c "$tmp/dagsim.o" "$tmp/rx.o" "$tmp/base.o" src/sha256.c $units src/cudapp_om_dag_parse.c src/cudapp_om_dag_fmt.c src/cudapp_om_dag_res.c src/cudapp_om_dag_diff.c src/cudapp_om_dag_jstr.c -lm |
| 26 | ORACLE=$tmp/oracle |
| 27 | fi |
| 28 | |
| 29 | cat > "$tmp/cycle.oev" <<'EOF' |
| 30 | oev version=1 |
| 31 | machine id=t soc=t cores=1 mem_bytes=100 prov=specified src=test |
| 32 | build repo=omega-mv sha=0000000000000000000000000000000000000000 |
| 33 | calibration id=c taken=2026-10-19 valid_days=3650 load1=0 src=synthetic |
| 34 | resource id=cpu kind=compute slots=1 prov=specified src=test |
| 35 | energy instrument=none |
| 36 | op id=A kind=compute engine=cpu t_ns=10 prov=synthetic src=test |
| 37 | op id=B kind=compute engine=cpu t_ns=10 prov=synthetic src=test |
| 38 | dep A B |
| 39 | dep B A |
| 40 | EOF |
| 41 | cat > "$tmp/alone.oev" <<'EOF' |
| 42 | oev version=1 |
| 43 | machine id=t soc=t cores=1 mem_bytes=100 prov=specified src=test |
| 44 | build repo=omega-mv sha=0000000000000000000000000000000000000000 |
| 45 | calibration id=c taken=2026-10-19 valid_days=3650 load1=0 src=synthetic |
| 46 | resource id=cpu kind=compute slots=1 prov=specified src=test |
| 47 | resource id=mem kind=capacity cap=100 prov=specified src=test |
| 48 | op id=A kind=compute engine=cpu t_ns=10 prov=synthetic src=test |
| 49 | buffer id=big bytes=200 cap=mem first=A last=A |
| 50 | energy instrument=none |
| 51 | EOF |
| 52 | |
| 53 | kill_one() { |
| 54 | name=$1 |
| 55 | src_sed=$2 |
| 56 | fixture=$3 |
| 57 | expect=$4 |
| 58 | sed "$src_sed" om/tools/dag_eval.om > "$tmp/$name.om" |
| 59 | cmp -s om/tools/dag_eval.om "$tmp/$name.om" && { echo "mutant $name: sed changed nothing"; exit 1; } |
| 60 | OMEGA_SEEDED_OMC="$OMC" sh "$BRIDGE/tools/bridge-seeded" c "$tmp/$name.om" > "$tmp/$name.c" |
| 61 | $CC $cflags -c -o "$tmp/$name.o" "$tmp/$name.c" |
| 62 | $CC $cflags -o "$tmp/$name.bin" tools/dagsim/dagsim_cli.c "$tmp/dagsim.o" "$tmp/rx.o" "$tmp/$name.o" src/sha256.c $units src/cudapp_om_dag_parse.c src/cudapp_om_dag_fmt.c src/cudapp_om_dag_res.c src/cudapp_om_dag_diff.c src/cudapp_om_dag_jstr.c -lm |
| 63 | "$ORACLE" eval "$fixture" --asof 2026-10-20 > "$tmp/$name.good" || true |
| 64 | grep -q "$expect" "$tmp/$name.good" || { echo "mutant $name: oracle missing $expect"; cat "$tmp/$name.good"; exit 1; } |
| 65 | "$tmp/$name.bin" eval "$fixture" --asof 2026-10-20 > "$tmp/$name.bad" || true |
| 66 | if cmp -s "$tmp/$name.good" "$tmp/$name.bad"; then |
| 67 | echo "mutant $name survived" |
| 68 | exit 1 |
| 69 | fi |
| 70 | echo "mutant $name: killed" |
| 71 | } |
| 72 | |
| 73 | kill_one cycle 's/if eq dag_topo m s 0/if eq dag_topo m s 9/' "$tmp/cycle.oev" 'dependency cycle' |
| 74 | kill_one cap 's/rc = dag_cap m s/rc = ulong 0/' "$tmp/alone.oev" 'alone exceeds' |
| 75 | kill_one life 's/rc = dag_life m s/rc = ulong 0/' tests/dagsim/fixtures/inverted_lone.oev 'inverted lifetime' |
| 76 | kill_one ledg 's/rc = dag_ledg m s/rc = ulong 0/' tests/dagsim/fixtures/capacity_two_80.oev 'REFUSED_CAPACITY' |
| 77 | kill_one span 's/if gt t ms/if gt ms t/' tests/dagsim/fixtures/mw_baseline.oev '"nominal": 280' |
| 78 | |
| 79 | # Negative control: one flipped byte of a passing record must fail the compare. |
| 80 | "$ORACLE" eval tests/dagsim/fixtures/mw_baseline.oev --asof 2026-10-20 > "$tmp/flip.in" |
| 81 | python3 - "$tmp/flip.in" "$tmp/flip.out" <<'PY' |
| 82 | import sys |
| 83 | b = open(sys.argv[1], "rb").read() |
| 84 | i = b.index(b"280") |
| 85 | open(sys.argv[2], "wb").write(b[:i] + b"281" + b[i+3:]) |
| 86 | PY |
| 87 | if cmp -s "$tmp/flip.in" "$tmp/flip.out"; then |
| 88 | echo "negative control: flip was not caught" |
| 89 | exit 1 |
| 90 | fi |
| 91 | echo "negative control: record flip caught" |
| 92 | echo "omega mutants: 5 killed" |