interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / tests / dagsim / mutant_omega.sh

92 lines · 4754 bytes Raw Blame History
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.
6set -eu
7ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
8cd "$ROOT"
9OMC=${OMEGA_OMC:-$HOME/work/cudastack/omega-mv/seed/out/omc}
10BRIDGE=${OMEGA_BRIDGE:-$HOME/work/cudastack/omega-bridge}
11PIN=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f
12[ "$(sha256sum < "$OMC" | cut -c1-64)" = "$PIN" ] || { echo "NOT_RUN: omc pin"; exit 3; }
13ORACLE=${1:-}
14tmp=$(mktemp -d)
15trap 'rm -rf "$tmp"' EXIT
16CC=${CC:-cc}
17cflags="-std=gnu11 -Wall -Wextra -D_GNU_SOURCE -O2 -ffp-contract=off -Isrc -Itools/dagsim"
18units="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"
19units="$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
22if [ -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
27fi
28
29cat > "$tmp/cycle.oev" <<'EOF'
30oev version=1
31machine id=t soc=t cores=1 mem_bytes=100 prov=specified src=test
32build repo=omega-mv sha=0000000000000000000000000000000000000000
33calibration id=c taken=2026-10-19 valid_days=3650 load1=0 src=synthetic
34resource id=cpu kind=compute slots=1 prov=specified src=test
35energy instrument=none
36op id=A kind=compute engine=cpu t_ns=10 prov=synthetic src=test
37op id=B kind=compute engine=cpu t_ns=10 prov=synthetic src=test
38dep A B
39dep B A
40EOF
41cat > "$tmp/alone.oev" <<'EOF'
42oev version=1
43machine id=t soc=t cores=1 mem_bytes=100 prov=specified src=test
44build repo=omega-mv sha=0000000000000000000000000000000000000000
45calibration id=c taken=2026-10-19 valid_days=3650 load1=0 src=synthetic
46resource id=cpu kind=compute slots=1 prov=specified src=test
47resource id=mem kind=capacity cap=100 prov=specified src=test
48op id=A kind=compute engine=cpu t_ns=10 prov=synthetic src=test
49buffer id=big bytes=200 cap=mem first=A last=A
50energy instrument=none
51EOF
52
53kill_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
73kill_one cycle 's/if eq dag_topo m s 0/if eq dag_topo m s 9/' "$tmp/cycle.oev" 'dependency cycle'
74kill_one cap 's/rc = dag_cap m s/rc = ulong 0/' "$tmp/alone.oev" 'alone exceeds'
75kill_one life 's/rc = dag_life m s/rc = ulong 0/' tests/dagsim/fixtures/inverted_lone.oev 'inverted lifetime'
76kill_one ledg 's/rc = dag_ledg m s/rc = ulong 0/' tests/dagsim/fixtures/capacity_two_80.oev 'REFUSED_CAPACITY'
77kill_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"
81python3 - "$tmp/flip.in" "$tmp/flip.out" <<'PY'
82import sys
83b = open(sys.argv[1], "rb").read()
84i = b.index(b"280")
85open(sys.argv[2], "wb").write(b[:i] + b"281" + b[i+3:])
86PY
87if cmp -s "$tmp/flip.in" "$tmp/flip.out"; then
88 echo "negative control: flip was not caught"
89 exit 1
90fi
91echo "negative control: record flip caught"
92echo "omega mutants: 5 killed"