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_attn_any_mutants.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # Mutate copies only; source generation must succeed, then the behavioral test |
| 4 | # (not compiler rejection) must kill each mutant. Never opens the device. |
| 5 | set -eu |
| 6 | ulimit -c 0 |
| 7 | ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) |
| 8 | cd "$ROOT" |
| 9 | : "${OMEGA_OMC:?set pinned OMEGA_OMC}" |
| 10 | : "${OMEGA_BRIDGE:?set pinned OMEGA_BRIDGE}" |
| 11 | OUT_DIR=${OUT_DIR:-build} |
| 12 | CC=${CC:-cc} |
| 13 | T=$(mktemp -d) |
| 14 | trap 'rm -rf "$T"' EXIT HUP INT TERM |
| 15 | for mutant in mask group normalize tail refusal half device; do |
| 16 | mkdir -p "$T/$mutant/src" "$T/$mutant/gen" |
| 17 | cp om/attn-any/*.om "$T/$mutant/src/" |
| 18 | cp tests/gpu_attn_any_test.c "$T/$mutant/test.c" |
| 19 | python3 - "$T/$mutant/src" "$mutant" "$T/$mutant/test.c" <<'PY' |
| 20 | import pathlib, sys |
| 21 | root = pathlib.Path(sys.argv[1]) |
| 22 | changes = { |
| 23 | 'mask': ('kernel.om', 'if ne and mode 256 0', 'if eq and mode 256 0'), |
| 24 | 'group': ('plan.om', 'kh = div head div get s 3 get s 4', 'kh = ulong 0'), |
| 25 | 'normalize': ('kernel.om', 'aa_rg get r 22 get r 12 AN AN', 'aa_rg get r 22 get r 44 AN AN'), |
| 26 | 'tail': ('kernel.om', 'flags = or flags 1536', 'flags = ulong 0'), |
| 27 | 'refusal': ('plan.om', 'gt get s 2 256', 'gt get s 2 257'), |
| 28 | 'half': ('emit.om', 'if eq and mode 255 2', 'if eq and mode 255 3'), |
| 29 | } |
| 30 | if sys.argv[2] == 'device': |
| 31 | f='test.c' |
| 32 | p=pathlib.Path(sys.argv[3]) |
| 33 | old=' refusals();' |
| 34 | new=' (void)omega_gpu_session_open();\n refusals();' |
| 35 | else: |
| 36 | f, old, new = changes[sys.argv[2]] |
| 37 | p = root/f |
| 38 | text = p.read_text() |
| 39 | assert text.count(old) == 1, (f, old, text.count(old)) |
| 40 | p.write_text(text.replace(old, new)) |
| 41 | PY |
| 42 | OMEGA_UNITS="attn_any=$T/$mutant/src/emit.om,$T/$mutant/src/kernel.om attn_any_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; } |
| 43 | "$CC" -std=gnu11 -O2 -ffp-contract=off -Isrc -Itests "$T/$mutant/test.c" "$T/$mutant/gen/cudapp_om_attn_any.c" "$T/$mutant/gen/cudapp_om_attn_any_plan.c" "$OUT_DIR/libomega_gpu.a" -Wl,--wrap=omega_gpu_session_open,--wrap=omega_gpu_session_lock,--wrap=omega_gpu_session_unlock,--wrap=omega_gpu_session_free,--wrap=omega_gpu_session_alloc -lpthread -lm -o "$T/$mutant/test" |
| 44 | if "$T/$mutant/test" --sim --quick > "$T/$mutant/test.log" 2>&1; then |
| 45 | echo "attn-any mutant SURVIVED: $mutant" |
| 46 | cat "$T/$mutant/test.log" |
| 47 | exit 1 |
| 48 | else |
| 49 | status=$? |
| 50 | fi |
| 51 | if [ "$mutant" = device ]; then |
| 52 | [ "$status" -eq 134 ] || { cat "$T/$mutant/test.log"; echo "attn-any device guard did not abort"; exit 1; } |
| 53 | cat "$T/$mutant/test.log" |
| 54 | fi |
| 55 | echo "attn-any mutant KILLED: $mutant" |
| 56 | done |
| 57 | echo 'attn-any source mutants: PASS (6 seeded mutants and session-open abort control killed after successful compilation)' |