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 / sm121dis / om_mutants.sh
| 1 | # ORACLE-free mutation harness (pinned omc + omega-bridge regenerate each mutant; no NVIDIA tool runs here). |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # om_mutants.sh <out-dir> <kernel-dir>: three one-line mutants of om/disasm/sm121_dis.om (CUDA++ C6, DRA-475). Each is |
| 4 | # regenerated through om/units.sh by the pinned compiler and bridge into its own binding, linked into its own sm121dis, |
| 5 | # and run on every kernel of <kernel-dir>; its text must differ from the unmutated decoder's on at least one kernel. |
| 6 | # Needs OMEGA_OMC and OMEGA_BRIDGE (om/units.sh refuses other pins with exit 3, reported NOT_RUN). |
| 7 | set -u |
| 8 | ROOT=$(cd "$(dirname "$0")/../.." && pwd) |
| 9 | OUT=$1; K=$2 |
| 10 | CC=${CC:-gcc} |
| 11 | SRC=$ROOT/om/disasm/sm121_dis.om |
| 12 | # 1: the first source register field read one bit too high; 2: PT printed as QT; 3: the MOV rows' fixed hi bits |
| 13 | set -- 's/^ret pk 0 24 8$/ret pk 0 25 8/' 's/^lit o s 21584$/lit o s 21585/' 's/^put t 1 3840$/put t 1 3841/' |
| 14 | mkdir -p "$OUT" |
| 15 | D0=$OUT/om-mut0 |
| 16 | mkdir -p "$D0" |
| 17 | "$CC" -std=gnu11 -Wall -Wextra -Werror -O2 -I"$ROOT/src" -o "$D0/sm121dis" "$ROOT/tools/sm121dis/sm121dis.c" \ |
| 18 | "$ROOT/src/omega_sm121_disasm.c" "$ROOT/src/cudapp_om_sm121_dis.c" "$ROOT/src/cudapp_om_words.c" || exit 1 |
| 19 | for f in "$K"/*.bin; do "$D0/sm121dis" --pairs "$f"; done > "$D0/all.txt" 2>&1 |
| 20 | n=0 |
| 21 | for m in "$@"; do |
| 22 | n=$((n + 1)); d=$OUT/om-mut$n |
| 23 | mkdir -p "$d" |
| 24 | sed "$m" "$SRC" > "$d/sm121_dis.om" |
| 25 | if cmp -s "$d/sm121_dis.om" "$SRC"; then echo "MUTANT $n BROKEN: '$m' changed nothing"; exit 1; fi |
| 26 | rc=0 |
| 27 | # the word unit too: the command line reads its words through it, and the mutant's header must declare it |
| 28 | OMEGA_UNITS="$d/sm121_dis.om $ROOT/om/disasm/words.om" OMEGA_UNITS_DEST=$d sh "$ROOT/om/units.sh" \ |
| 29 | > "$d/units.log" 2>&1 || rc=$? |
| 30 | if [ "$rc" = 3 ]; then cat "$d/units.log"; echo "VERDICT NOT_RUN: pinned omc and bridge needed"; exit 3; fi |
| 31 | [ "$rc" = 0 ] || { cat "$d/units.log"; echo "MUTANT $n: regeneration failed ($rc)"; exit 1; } |
| 32 | # -I$d first: the mutant's own generated cudapp_native.h declares its omega_sm121_dis |
| 33 | "$CC" -std=gnu11 -Wall -Wextra -Werror -O2 -I"$d" -I"$ROOT/src" -o "$d/sm121dis" "$ROOT/tools/sm121dis/sm121dis.c" \ |
| 34 | "$ROOT/src/omega_sm121_disasm.c" "$d/cudapp_om_sm121_dis.c" "$d/cudapp_om_words.c" || exit 1 |
| 35 | for f in "$K"/*.bin; do "$d/sm121dis" --pairs "$f"; done > "$d/all.txt" 2>&1 |
| 36 | if cmp -s "$D0/all.txt" "$d/all.txt"; then echo "MUTANT $n SURVIVED: '$m'"; exit 1; fi |
| 37 | echo "mutant $n red ('$m'): $(diff "$D0/all.txt" "$d/all.txt" | grep -c '^<') corpus words print differently" |
| 38 | done |
| 39 | echo "VERDICT PASS: every .om mutant changes the corpus text" |