Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/gpu_dnn_rows_mutants.sh # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / gpu_dnn_rows_mutants.sh` 62 lines · 3658 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 set -eu 4 ulimit -c 0 5 ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) 6 cd "$ROOT" 7 : "${OMEGA_OMC:?set pinned OMEGA_OMC}" 8 : "${OMEGA_BRIDGE:?set pinned OMEGA_BRIDGE}" 9 OUT_DIR=${OUT_DIR:-build} 10 CC=${CC:-cc} 11 T="$OUT_DIR/dnn-rows-evidence/mutants" 12 mkdir -p "$T" 13 for mutant in maximum normalize tail epsilon refusal half; do 14 mkdir -p "$T/$mutant/src" "$T/$mutant/gen" 15 cp om/dnn-rows/*.om "$T/$mutant/src/" 16 python3 - "$T/$mutant/src" "$mutant" <<'PY' 17 import pathlib,sys 18 changes={ 19 'maximum':('kernel.om','aa_bin x m 37 9 9 8','aa_bin x m 30 9 9 8'), 20 'normalize':('kernel.om','aa_bin x m 32 8 8 11','aa_bin x m 32 8 8 15'), 21 'tail':('kernel.om','aa_load x m 8 4 0 or mode 1536','aa_load x m 8 4 0 mode'), 22 'epsilon':('kernel.om','aa_bin x m 30 9 9 13','aa_bin x m 30 9 9 21'), 23 'refusal':('plan.om','ge get s 4 `2139095040`','gt get s 4 `2139095040`'), 24 'half':('kernel.om','aa_load x m 8 4 0 or mode 1536','aa_load x m 8 4 0 or and mode 1 1536')} 25 f,old,new=changes[sys.argv[2]] 26 p=pathlib.Path(sys.argv[1])/f 27 s=p.read_text();assert s.count(old)==1,(f,old,s.count(old));p.write_text(s.replace(old,new)) 28 PY 29 ABS=$(CDPATH= cd "$T/$mutant" && pwd) 30 OMEGA_UNITS="dnn_rows=om/attn-any/emit.om,$ABS/src/kernel.om dnn_rows_plan=$ABS/src/plan.om" OMEGA_UNITS_DEST="$ABS/gen" sh om/units.sh > "$T/$mutant/generate.log" 2>&1 || { cat "$T/$mutant/generate.log";exit 1; } 31 "$CC" -std=gnu11 -O2 -ffp-contract=off -Isrc -Itests tests/gpu_dnn_rows_test.c "$T/$mutant/gen/cudapp_om_dnn_rows.c" "$T/$mutant/gen/cudapp_om_dnn_rows_plan.c" "$OUT_DIR/libomega_gpu.a" -Wl,--wrap=omega_gpu_session_open,--wrap=omega_gpu_session_alloc,--wrap=omega_gpu_session_lock,--wrap=omega_gpu_session_unlock,--wrap=omega_gpu_session_free -lpthread -lm -o "$T/$mutant/test" 32 if "$T/$mutant/test" --quick > "$T/$mutant/test.log" 2>&1; then 33 echo "dnn-rows mutant SURVIVED: $mutant";cat "$T/$mutant/test.log";exit 1 34 else 35 rc=$? 36 echo "behavior_rc=$rc" > "$T/$mutant/result.txt" 37 if test "$mutant" = refusal; then 38 test "$rc" = 134 && grep -q 'HOST DEVICE GUARD: session_lock' "$T/$mutant/test.log" || { echo "refusal mutant failed without device guard: rc=$rc";exit 1; } 39 else 40 test "$rc" = 1 || { echo "mutant crashed rather than behavioral rejection: $mutant rc=$rc";exit 1; } 41 fi 42 fi 43 echo "dnn-rows mutant KILLED: $mutant (generation and C compilation succeeded)" 44 done 45 mkdir -p "$T/direct-open" 46 python3 - "$T/direct-open/test.c" <<'PY' 47 import pathlib,sys 48 s=pathlib.Path('tests/gpu_dnn_rows_test.c').read_text() 49 old=' allow_chip=chip;' 50 assert s.count(old)==1 51 pathlib.Path(sys.argv[1]).write_text(s.replace(old,old+'\n if(!chip) omega_gpu_session_open();')) 52 PY 53 "$CC" -std=gnu11 -O2 -ffp-contract=off -Isrc -Itests "$T/direct-open/test.c" "$OUT_DIR/libomega_gpu.a" -Wl,--wrap=omega_gpu_session_open,--wrap=omega_gpu_session_alloc,--wrap=omega_gpu_session_lock,--wrap=omega_gpu_session_unlock,--wrap=omega_gpu_session_free -lpthread -lm -o "$T/direct-open/test" 54 if "$T/direct-open/test" --sim > "$T/direct-open/test.log" 2>&1; then 55 echo 'dnn-rows direct-open guard mutant SURVIVED';exit 1 56 else 57 rc=$? 58 echo "behavior_rc=$rc" > "$T/direct-open/result.txt" 59 test "$rc" = 134 && grep -q 'HOST DEVICE GUARD: session_open' "$T/direct-open/test.log" || { echo "direct-open mutant failed without guard: rc=$rc";exit 1; } 60 fi 61 echo 'dnn-rows direct-open guard mutant: PASS (compiled; killed by abort under --sim)' 62 echo 'dnn-rows source mutants: PASS (5 behavioral failures, refusal guard abort, direct-open guard abort; all compiled)'