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_predict.sh

44 lines · 2517 bytes Raw Blame History
1#!/bin/sh
2# Drop the unsupported-return and refused checks. Leave the p.known test in
3# place. The named assertions must fail: a prediction can be marked known and
4# still be a refusal.
5set -eu
6ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
7cd "$ROOT"
8src=tools/dagsim/dagsim.c
9grep -q 'PREDICT_REFUSAL_CHECK' "$src"
10tmp=$(mktemp -d)
11trap 'rm -rf "$tmp"' EXIT
12sed '/PREDICT_REFUSAL_CHECK/s/st == RX_CM_ERR_UNSUPPORTED || p->refused || //' "$src" > "$tmp/dagsim.c"
13grep -q 'PREDICT_REFUSAL_CHECK' "$tmp/dagsim.c" || { echo "mutant: deleted the check tag"; exit 1; }
14grep -q 'RX_CM_ERR_UNSUPPORTED' "$tmp/dagsim.c" && { echo "mutant: unsupported check still present"; exit 1; }
15grep -q 'predict_unusable' "$tmp/dagsim.c" || { echo "mutant: deleted the call"; exit 1; }
16
17CC=${CC:-cc}
18# -Wno-unused-parameter: dropping the use of st must not die at compile time.
19# The kill is the named assertion, not a warning.
20cflags="-std=gnu11 -Wall -Wextra -Werror -Wno-unused-parameter -D_GNU_SOURCE -O2 -ffp-contract=off -DCUDAPP_MIGRATION_PENDING_C_TOOLS -DCUDAPP_MIGRATION_PENDING_C_DAGSIM_RESOLVE=1 -Isrc -Itools/dagsim"
21$CC $cflags -c -o "$tmp/dagsim.o" "$tmp/dagsim.c"
22$CC $cflags -ffp-contract=off -c -o "$tmp/rx_costmodel.o" src/runtime/rx_costmodel.c
23# CUDA++ has no src/omega_om_units.c; src/sha256.c is sha256_hash on every host and calls the core_sha unit (Makefile DS_SHA_SRC).
24sha=src/sha256.c
25$CC $cflags -o "$tmp/unit" tests/dagsim/dagsim_unit.c "$tmp/dagsim.o" "$tmp/rx_costmodel.o" "$sha" 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 src/cudapp_om_cm_route.c src/cudapp_om_dag_parse.c src/cudapp_om_dag_fmt.c -Wl,--wrap=rx_cm_predict -lm
26set +e
27"$tmp/unit" > "$tmp/out" 2>&1
28rc=$?
29set -e
30if [ "$rc" -eq 0 ]; then
31 echo "mutant survived: unit suite passed after dropping the predict refusal check"
32 exit 1
33fi
34if ! grep -q 'predict_unsupported_despite_known' "$tmp/out"; then
35 echo "mutant did not fail named assertion predict_unsupported_despite_known"
36 cat "$tmp/out"
37 exit 1
38fi
39if ! grep -q 'predict_refused_despite_known' "$tmp/out"; then
40 echo "mutant did not fail named assertion predict_refused_despite_known"
41 cat "$tmp/out"
42 exit 1
43fi
44echo "mutant killed: predict_unsupported_despite_known predict_refused_despite_known"