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/ampcorp.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 / ampcorp.sh` 82 lines · 4500 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # ampcorp acceptance: tools/ampere_corpus.c (seeded Omega om/tools/ampcorp.om) against its C oracle 4 # (-DCUDAPP_MIGRATION_PENDING_C_TOOLS_AMPCORP) through tests/tools-om/ampcorp_diff.c, which supplies the SM86 5 # encoder outcome per case: exit or signal, stderr and every written file byte for byte, a flipped-record 6 # negative control, and recompiled mutants. TOOLS_OM_COVERAGE=DIR also writes gcov branch data of the oracle. 7 # Run under: bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 8 set -eu 9 ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) 10 cd "$ROOT" 11 tmp=$(mktemp -d) 12 trap 'rm -rf "$tmp"' EXIT 13 . tests/tools-om/lib.sh 14 tom_pin 15 SRC=tools/ampere_corpus.c 16 DRV=tests/tools-om/ampcorp_diff.c 17 OFF=-DCUDAPP_MIGRATION_PENDING_C_TOOLS_AMPCORP 18 $CC $TOM_CFLAGS $OFF -o "$tmp/ac_c" $DRV $SRC 19 $CC $TOM_CFLAGS -o "$tmp/ac_om" $DRV $SRC src/cudapp_om_ampcorp.c 20 run() { mkdir -p "$2.d" && (cd "$2.d" && "$1") > "$2.out"; } 21 run "$tmp/ac_c" "$tmp/c" 22 run "$tmp/ac_om" "$tmp/om" 23 cmp "$tmp/c.out" "$tmp/om.out" || { echo "FAIL ampcorp differential"; diff "$tmp/c.out" "$tmp/om.out" | head -20; exit 1; } 24 cases=$(grep -c '^case ' "$tmp/c.out") 25 files=$(grep -c '^ file ' "$tmp/c.out") 26 outs=$(grep -E '^ (exit|signal) ' "$tmp/c.out" | sort | uniq -c | tr -s ' \n' ' ') 27 echo "differential: $cases cases identical ($files files; outcomes:$outs)" 28 tom_flip "$tmp/c.out" "$tmp/om.out" 29 30 killed=0 31 mut() { # NAME SITE REPLACEMENT 32 tom_mutant "$1" om/tools/ampcorp.om "$2" "$3" 33 $CC $TOM_CFLAGS -o "$tmp/$1.bin" $DRV $SRC "$tmp/$1.c" 34 run "$tmp/$1.bin" "$tmp/$1" 35 if cmp -s "$tmp/c.out" "$tmp/$1.out"; then echo "FAIL mutant $1 survived"; exit 1; fi 36 echo "mutant $1: killed ($(diff "$tmp/c.out" "$tmp/$1.out" | grep -m1 '^[<>]' | cut -c1-60))" 37 killed=$((killed + 1)) 38 } 39 mut dotdot 'if eq sub i s 2' 'if eq sub i s 3' 40 mut backslash 'if eq get d i uchar 92' 'if eq get d i uchar 93' 41 mut lg2 'if gt and op `4294967295` get f 8' 'if ge and op `4294967295` get f 8' 42 mut f2e4 'if eq im get f 12' 'if ne im get f 12' 43 mut stray 'if ne get code i uchar 165' 'if eq get code i uchar 0' 44 mut pathmax 'if ge n ACMAX' 'if gt n ACMAX' 45 mut rcsign 'if ne shr rc 63 0' 'if eq shr rc 63 0' 46 mut lenchk 'if or ne rc 0 ne nb get f 5' 'if ne rc 0' 47 echo "ampcorp mutants: $killed killed" 48 49 if [ -n "${TOOLS_OM_COVERAGE:-}" ]; then 50 mkdir -p "$TOOLS_OM_COVERAGE" "$tmp/cov" 51 cp $SRC "$tmp/cov/ampere_corpus.c" 52 (cd "$tmp/cov" && $CC -std=gnu11 -D_GNU_SOURCE -O0 --coverage -I"$ROOT/src" $OFF -DAMPCORP_GCOV -o ac_cov "$ROOT/$DRV" ampere_corpus.c) 53 run "$tmp/cov/ac_cov" "$tmp/cov/r" 54 (cd "$tmp/cov" && gcov -b -c ac_cov-ampere_corpus.c > "$TOOLS_OM_COVERAGE/ampcorp.gcov.txt" 2>&1) 55 cp "$tmp/cov/ampere_corpus.c.gcov" "$TOOLS_OM_COVERAGE/ampere_corpus.c.gcov" 56 echo "coverage: $TOOLS_OM_COVERAGE/ampcorp.gcov.txt" 57 fi 58 59 # TOOLS_OM_AMPCORP_REAL=1: the corpus producers of test-ampere-encoder-oracle (the SM86 encoder is real), built 60 # with CUDAPP_AMPERE_CORPUS=1 both ways in two OUT_DIRs, one corpus folder per producer; every file name (pid 61 # replaced) and sha256 must match. Builds the library twice. 62 real= 63 if [ -n "${TOOLS_OM_AMPCORP_REAL:-}" ]; then 64 for v in om c; do 65 sw=0; [ $v = c ] && sw=1 66 make -j3 OUT_DIR="$tmp/b-$v" CUDAPP_AMPERE_CORPUS=1 CUDAPP_MIGRATION_PENDING_C_TOOLS_AMPCORP=$sw \ 67 "$tmp/b-$v/ampere_encoder_test" "$tmp/b-$v/ampere_families" "$tmp/b-$v/ampere_matmul_families" \ 68 > "$tmp/b-$v.log" 2>&1 || { tail -20 "$tmp/b-$v.log"; echo "FAIL building the $v producers"; exit 1; } 69 for p in ampere_encoder_test ampere_families 'ampere_matmul_families --dump'; do 70 d="$tmp/b-$v/corpus-${p%% *}" 71 mkdir -p "$d" 72 OMEGA_AMPERE_CORPUS_DIR="$d" "$tmp/b-$v/"$p > "$d.log" 2>&1 || { echo "FAIL $v $p"; exit 1; } 73 (cd "$d" && for f in *; do echo "${p%% *} $(echo "$f" | sed 's/^[0-9]*-/PID-/') $(sha256sum < "$f" | cut -c1-64)"; done) \ 74 | sort -V >> "$tmp/b-$v.manifest" 75 done 76 done 77 cmp "$tmp/b-c.manifest" "$tmp/b-om.manifest" || { echo "FAIL ampcorp real producers"; exit 1; } 78 tom_flip "$tmp/b-c.manifest" "$tmp/b-om.manifest" 79 real=", real producers $(wc -l < "$tmp/b-c.manifest") files" 80 echo "real producers: $(wc -l < "$tmp/b-c.manifest") corpus files identical ($(cut -d' ' -f2 "$tmp/b-c.manifest" | sed 's/^PID-[0-9]*\.//' | sort | uniq -c | tr -s ' \n' ' '))" 81 fi 82 echo "tools-om ampcorp: PASS (differential $cases cases$real, negative control, $killed mutants killed)"