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/tools-om/artexp.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 / tools-om / artexp.sh` 217 lines · 13090 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # artexp acceptance: tools/artifact_export.c (seeded Omega om/tools/artexp.om) against its C oracle 4 # (-DCUDAPP_MIGRATION_PENDING_C_TOOLS_ARTEXP). Both builds link the real library (host only, no device). 5 # Every case runs each build in a fresh directory and compares stdout, stderr, exit and every file the 6 # export wrote (name, size, sha256) byte for byte. Then a flipped-record negative control and recompiled 7 # mutants. TOOLS_OM_COVERAGE=DIR writes gcov branch data of the oracle. 8 # Run under: bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 9 set -eu 10 ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) 11 cd "$ROOT" 12 tmp=$(mktemp -d) 13 trap 'rm -rf "$tmp"' EXIT 14 . tests/tools-om/lib.sh 15 tom_pin 16 SRC=tools/artifact_export.c 17 OFF=-DCUDAPP_MIGRATION_PENDING_C_TOOLS_ARTEXP 18 make -j3 OUT_DIR="$tmp/b" "$tmp/b/libomega_gpu.a" > "$tmp/b.log" 2>&1 || 19 { tail -20 "$tmp/b.log"; echo "FAIL building the library"; exit 1; } 20 LIBS="src/omega_native_artifact.c src/omega_cubin.c $tmp/b/libomega_gpu.a -lpthread -lm" 21 $CC $TOM_CFLAGS $OFF -o "$tmp/ae_c" $SRC $LIBS 22 $CC $TOM_CFLAGS -o "$tmp/ae_om" $SRC $LIBS 23 24 CM=`647116fc1ba1e1394982fc8ba181ce565293f160a6b56afc0f02b2128a675704` 25 AT=`003696e422bba7274877ba9e01a61076ea0f862f32760cbaa06c60f85a115359` 26 G=`0123456789abcdef0123456789abcdef01234567` 27 LONG=$(printf 'p%.0s' $(seq 1 5000)) 28 # One case per line: SETUP then the arguments (shell words). SETUP: - nothing, exists (out.cubin is there), 29 # link (out.manifest is a symlink), nodir (the prefix names a missing directory). 30 cat > "$tmp/cases" < "$d/out.cubin" ;; 156 link) ln -s /nonexistent "$d/out.manifest" ;; 157 esac 158 rc=0 159 (cd "$d" && "$bin" "$@" < /dev/null > "$tmp/o" 2> "$tmp/e") || rc=$? 160 echo "case $setup $(printf '%s|' "$@" | cut -c1-200)" 161 sed 's/^/ out /' "$tmp/o" 162 sed 's/^/ err /' "$tmp/e" 163 echo " exit $rc" 164 (cd "$d" && find . \( -type f -o -type l \) | LC_ALL=C sort | while read -r f; do 165 if [ -L "$f" ]; then echo " link $f"; else echo " file $f $(wc -c < "$f") $(sha256sum < "$f" | cut -c1-64)"; fi 166 done) 167 } 168 run() { # BIN OUT: every case of $tmp/cases 169 bin=$1 170 while IFS= read -r line; do 171 eval "set -- $line" 172 one "$bin" "$@" 173 done < "$tmp/cases" > "$2" 174 } 175 run "$tmp/ae_c" "$tmp/c.out" 176 run "$tmp/ae_om" "$tmp/om.out" 177 cmp "$tmp/c.out" "$tmp/om.out" || { echo "FAIL artexp differential"; diff "$tmp/c.out" "$tmp/om.out" | head -20; exit 1; } 178 cases=$(grep -c '^case ' "$tmp/c.out") 179 files=$(grep -c '^ file ' "$tmp/c.out") 180 outs=$(grep '^ exit ' "$tmp/c.out" | sort | uniq -c | tr -s ' \n' ' ') 181 grep -q '^ out artifact_id=' "$tmp/c.out" || { echo "FAIL artexp oracle exported nothing"; exit 1; } 182 echo "differential: $cases cases identical, $files files written (exits:$outs)" 183 tom_flip "$tmp/c.out" "$tmp/om.out" 184 185 killed=0 186 mut() { # NAME SITE REPLACEMENT 187 tom_mutant "$1" om/tools/artexp.om "$2" "$3" 188 $CC $TOM_CFLAGS -o "$tmp/$1.bin" $SRC "$tmp/$1.c" $LIBS 189 run "$tmp/$1.bin" "$tmp/$1.out" 190 if cmp -s "$tmp/c.out" "$tmp/$1.out"; then echo "FAIL mutant $1 survived"; exit 1; fi 191 echo "mutant $1: killed ($(diff "$tmp/c.out" "$tmp/$1.out" | grep -m1 '^[<>]' | cut -c1-60))" 192 killed=$((killed + 1)) 193 } 194 mut ktile 'if ne rem k 16 0' 'if ne rem k 8 0' 195 mut single 'if eq get s 14 16' 'if eq get s 14 32' 196 mut colgrid 'gx = div n 8' 'gx = div n 16' 197 mut hexbase 'b = ulong 16' 'b = ulong 10' 198 mut overflow 'ov = ulong 1' 'ov = ulong 0' 199 mut u32max 'if gt v `4294967295`' 'if gt v `4294967296`' 200 mut shared 'sh = and mul sh 512 `4294967295`' 'sh = and mul sh 256 `4294967295`' 201 mut lowhex 'if not or and ge c 48 le c 57 and ge c 97 le c 102' 'if not or and ge c 48 le c 57 and ge c 97 le c 101' 202 mut pow2 'while lt shl ulong 1 l r bound 64' 'while le shl ulong 1 l r bound 64' 203 mut hbound 'if gt get s 17 64' 'if gt get s 17 63' 204 echo "artexp mutants: $killed killed" 205 206 if [ -n "${TOOLS_OM_COVERAGE:-}" ]; then 207 mkdir -p "$TOOLS_OM_COVERAGE" "$tmp/cov" 208 cp $SRC "$tmp/cov/artifact_export.c" 209 (cd "$tmp/cov" && $CC -std=gnu11 -D_GNU_SOURCE -O0 --coverage -I"$ROOT/src" $OFF -o ae_cov artifact_export.c \ 210 "$ROOT/src/omega_native_artifact.c" "$ROOT/src/omega_cubin.c" "$tmp/b/libomega_gpu.a" -lpthread -lm) 211 run "$tmp/cov/ae_cov" "$tmp/cov/r.out" 212 cmp -s "$tmp/c.out" "$tmp/cov/r.out" || { echo "FAIL artexp coverage build differs from the oracle"; exit 1; } 213 (cd "$tmp/cov" && gcov -b -c ae_cov-artifact_export.c > "$TOOLS_OM_COVERAGE/artexp.gcov.txt" 2>&1) 214 cp "$tmp/cov/artifact_export.c.gcov" "$TOOLS_OM_COVERAGE/artifact_export.c.gcov" 215 echo "coverage: $TOOLS_OM_COVERAGE/artexp.gcov.txt" 216 fi 217 echo "tools-om artexp: PASS (differential $cases cases, $files files, negative control, $killed mutants killed)"