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 / gpu_dnn_activations_mutants.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # Each mutated source must pass seeded compilation AND checked-C generation. |
| 4 | # Exit 1 (wrong behavior) or the expected refusal guard abort counts as a kill. |
| 5 | set -eu |
| 6 | ulimit -c 0 |
| 7 | ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) |
| 8 | cd "$ROOT" |
| 9 | : "${OMEGA_OMC:?set pinned compiler}" |
| 10 | : "${OMEGA_BRIDGE:?set pinned bridge}" |
| 11 | OUT_DIR=${OUT_DIR:-build} |
| 12 | CC=${CC:-cc} |
| 13 | mkdir -p "$OUT_DIR" |
| 14 | T=$(mktemp -d "$OUT_DIR/dnn-activations-mutants.XXXXXX") |
| 15 | "$CC" -std=gnu11 -O2 -ffp-contract=off -DDA_GUARD_MUTANT -Isrc -Itests -Wl,--wrap=omega_gpu_session_open -Wl,--wrap=omega_gpu_session_lock -Wl,--wrap=omega_gpu_session_unlock -Wl,--wrap=omega_gpu_session_free -Wl,--wrap=omega_gpu_session_alloc tests/gpu_dnn_activations_test.c "$OUT_DIR/libomega_gpu.a" -lpthread -lm -o "$T/guard" |
| 16 | rc=0 |
| 17 | "$T/guard" --sim > "$T/guard.log" 2>&1 || rc=$? |
| 18 | if [ "$rc" != 134 ]; then cat "$T/guard.log";echo "guard mutant survived rc=$rc";exit 1;fi |
| 19 | case $(cat "$T/guard.log") in *"DNN-HOST-GUARD session_open"*) ;; *) cat "$T/guard.log";exit 1;; esac |
| 20 | echo 'dnn-activations isolation control: PASS (compiled direct-open mutant aborts under --sim)' |
| 21 | for mutant in relu erf tanh silu tail dtype refusal; do |
| 22 | mkdir -p "$T/$mutant/src" "$T/$mutant/gen" |
| 23 | cp om/dnn-activations/*.om "$T/$mutant/src/" |
| 24 | python3 - "$T/$mutant/src" "$mutant" <<'PY' |
| 25 | import pathlib,sys |
| 26 | changes={ |
| 27 | 'relu':('kernel.om','aa_mov x m 12 0','da_copy x m 12 8'), |
| 28 | 'erf':('kernel.om','0.3275911f32','0.4275911f32'), |
| 29 | 'tanh':('kernel.om','0.044715f32','0.44715f32'), |
| 30 | 'silu':('kernel.om','da_mulc x m 11 9 -1.0f32','da_mulc x m 11 9 1.0f32'), |
| 31 | 'tail':('kernel.om','aa_mad x m 7 1 32 0','aa_mad x m 7 1 31 0'), |
| 32 | 'dtype':('kernel.om','aa_load x m 8 4 0 dtype','aa_load x m 8 4 0 0'), |
| 33 | 'refusal':('plan.om','if or eq n 0 gt n 4294967295','if or eq n 999 gt n 4294967295'), |
| 34 | } |
| 35 | f,old,new=changes[sys.argv[2]] |
| 36 | p=pathlib.Path(sys.argv[1])/f |
| 37 | s=p.read_text();assert s.count(old)==1,(f,old,s.count(old)) |
| 38 | p.write_text(s.replace(old,new)) |
| 39 | PY |
| 40 | OMEGA_UNITS="dnn_activations=om/attn-any/emit.om,$T/$mutant/src/kernel.om dnn_activations_plan=$T/$mutant/src/plan.om" OMEGA_UNITS_DEST="$T/$mutant/gen" sh om/units.sh > "$T/$mutant/generate.log" 2>&1 || { cat "$T/$mutant/generate.log"; exit 1; } |
| 41 | "$CC" -std=gnu11 -O2 -ffp-contract=off -Isrc -Itests -Wl,--wrap=omega_gpu_session_open -Wl,--wrap=omega_gpu_session_lock -Wl,--wrap=omega_gpu_session_unlock -Wl,--wrap=omega_gpu_session_free -Wl,--wrap=omega_gpu_session_alloc tests/gpu_dnn_activations_test.c "$T/$mutant/gen/cudapp_om_dnn_activations.c" "$T/$mutant/gen/cudapp_om_dnn_activations_plan.c" "$OUT_DIR/libomega_gpu.a" -lpthread -lm -o "$T/$mutant/test" |
| 42 | rc=0 |
| 43 | "$T/$mutant/test" --quick > "$T/$mutant/test.log" 2>&1 || rc=$? |
| 44 | if [ "$mutant:$rc" = refusal:134 ]; then |
| 45 | case $(cat "$T/$mutant/test.log") in *"DNN-HOST-GUARD session_lock"*) ;; *) cat "$T/$mutant/test.log";exit 1;; esac |
| 46 | elif [ "$rc" != 1 ]; then |
| 47 | echo "dnn-activations mutant INVALID/SURVIVED: $mutant rc=$rc" |
| 48 | cat "$T/$mutant/test.log";exit 1 |
| 49 | fi |
| 50 | echo "dnn-activations mutant KILLED after seeded compile: $mutant" |
| 51 | done |
| 52 | echo "dnn-activations mutation evidence: $T" |
| 53 | echo 'dnn-activations source mutants: PASS (7 compiled, 7 behaviorally killed)' |