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/omega-blas/blob/main/tests/netlib/run.sh # omega-blas aien-dev/omega-blas 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 `omega-blas / tests / netlib / run.sh` 113 lines ยท 6508 bytes Raw Blame History 1 #!/bin/sh 2 # tests/netlib/run.sh: the netlib reference BLAS test drivers (sblat2, sblat3) and CBLAS test 3 # drivers (c_sblat2, c_sblat3) from LAPACK 3.12.1, linked unmodified against libomegablas.so. 4 # Only the implemented routines are enabled in the input decks (SGEMV, SGEMM; error exits on); 5 # every other routine the drivers reference is an abort() stub, so a stray call fails loudly. 6 # Usage: LAPACK= FC= sh tests/netlib/run.sh 7 # OMB_BUILD= library directory (default build; build-gb10 for make GB10=1) 8 # OMEGABLAS_DEVICE=gb10 run on the GB10 device path (README.md); each driver must then report 9 # host 0 and gb10 > 0 calls (OMEGABLAS_ROUTE_REPORT line in its log) 10 # GB10_HOOKS= link tests/gb10/hooks.c into the drivers (OMB_TEST_BACKEND=model runs the 11 # device glue on the chip-exact HMMA model; OMB_TEST_MUTANT=1 the negative control) 12 # THRESH= replace the decks' 16.0: a measurement run that prints every routine's 13 # maximum test ratio (SUSPECT lines are then expected); fails only on FATAL, 14 # FAILED or a missing END OF TESTS. Not a gate. 15 # DRIVERS="" run only these of sblat2 sblat3 c_sblat2 c_sblat3 (to fit a chip hold); 16 # the others print NOT_RUN and the exit status is 1 17 # Exit 0 only if all four drivers report every enabled routine PASSED and none FAILED. 18 set -eu 19 ROOT=$(cd "$(dirname "$0")/../.." && pwd) 20 LAPACK=${LAPACK:?set LAPACK to an unpacked lapack-3.12.1 tree (tests/netlib/fetch.sh)} 21 FC=${FC:-gfortran} 22 CC=${CC:-cc} 23 OMB_BUILD=$(cd "$ROOT" && cd "${OMB_BUILD:-build}" && pwd) 24 DEV=${OMEGABLAS_DEVICE:-host} 25 THRESH=${THRESH:-} 26 W=$OMB_BUILD/netlib 27 rm -rf "$W"; mkdir -p "$W" 28 LIB="-L$OMB_BUILD -lomegablas -Wl,-rpath,$OMB_BUILD" 29 [ "$DEV" = gb10 ] && export OMEGABLAS_ROUTE_REPORT=1 30 echo "netlib: library $OMB_BUILD/libomegablas.so, device $DEV${THRESH:+, THRESH $THRESH (measurement)}" 31 32 stubs() { 33 for r in "$@"; do printf 'void %s(void) { fputs("omega-blas test stub: %s called\\n", stderr); abort(); }\n' "$r" "$r"; done 34 } 35 { 36 echo '#include '; echo '#include ' 37 stubs sgbmv_ sger_ ssbmv_ sspmv_ sspr_ sspr2_ ssymv_ ssyr_ ssyr2_ stbmv_ stbsv_ stpmv_ stpsv_ \ 38 strmv_ strsv_ sgemmtr_ ssymm_ ssyr2k_ ssyrk_ strmm_ strsm_ 39 stubs cblas_sgbmv cblas_sger cblas_ssbmv cblas_sspmv cblas_sspr cblas_sspr2 cblas_ssymv \ 40 cblas_ssyr cblas_ssyr2 cblas_stbmv cblas_stbsv cblas_stpmv cblas_stpsv cblas_strmv \ 41 cblas_strsv cblas_sgemmtr cblas_ssymm cblas_ssyr2k cblas_ssyrk cblas_strmm cblas_strsm 42 } > "$W/stubs.c" 43 $CC -O1 -c -o "$W/stubs.o" "$W/stubs.c" 44 HOOKS= 45 if [ -n "${GB10_HOOKS:-}" ]; then 46 $CC -O1 -I"$GB10_HOOKS/src" -I"$GB10_HOOKS/tests" -c -o "$W/hooks.o" "$ROOT/tests/gb10/hooks.c" 47 HOOKS="$W/hooks.o" 48 fi 49 50 # input decks: keep the SGEMV / SGEMM lines enabled, disable every other routine 51 # (fixed-column reads: flip the T in place, keep the spacing) 52 deck() { 53 sed -E "/^(cblas_)?[sS][A-Za-z0-9]+ +[TF] /{ /^$2 /!s/^([A-Za-z0-9_]+ +)T/\\1F/; }" "$1" | 54 if [ -n "$THRESH" ]; then sed -E "s/^16\\.0( +THRESHOLD VALUE)/$THRESH\\1/"; else cat; fi 55 } 56 deck "$LAPACK/BLAS/TESTING/sblat2.in" SGEMV > "$W/sblat2.in" 57 deck "$LAPACK/BLAS/TESTING/sblat3.in" SGEMM > "$W/sblat3.in" 58 deck "$LAPACK/CBLAS/testing/sin2" cblas_sgemv > "$W/sin2" 59 deck "$LAPACK/CBLAS/testing/sin3" cblas_sgemm > "$W/sin3" 60 grep -q "^${THRESH:-16.0} *THRESHOLD VALUE" "$W/sblat2.in" "$W/sin3" || { echo "deck threshold not set"; exit 1; } 61 62 FFLAGS="-O0 -fno-optimize-sibling-calls" 63 $FC $FFLAGS -o "$W/sblat2" "$LAPACK/BLAS/TESTING/sblat2.f" "$W/stubs.o" $HOOKS $LIB 64 $FC $FFLAGS -o "$W/sblat3" "$LAPACK/BLAS/TESTING/sblat3.f" "$W/stubs.o" $HOOKS $LIB 65 printf '#ifndef F77_GLOBAL\n#define F77_GLOBAL(lcname,UCNAME) lcname##_\n#endif\n' > "$W/cblas_mangling.h" 66 CI="-I$W -I$LAPACK/CBLAS/include -DADD_" 67 T=$LAPACK/CBLAS/testing 68 for f in c_sblas2 c_s2chke c_sblas3 c_s3chke auxiliary c_xerbla; do $CC -O1 $CI -c -o "$W/$f.o" "$T/$f.c"; done 69 $FC $FFLAGS -o "$W/c_sblat2" "$T/c_sblat2.f" "$W/c_sblas2.o" "$W/c_s2chke.o" "$W/auxiliary.o" "$W/c_xerbla.o" "$W/stubs.o" $HOOKS $LIB 70 $FC $FFLAGS -o "$W/c_sblat3" "$T/c_sblat3.f" "$W/c_sblas3.o" "$W/c_s3chke.o" "$W/auxiliary.o" "$W/c_xerbla.o" "$W/stubs.o" $HOOKS $LIB 71 72 rc=0 73 check() { # name log nblocks routine runlog: require END OF TESTS, no failure/suspect lines, the 74 # error-exit PASSED line and nblocks computational PASSED lines (2 for CBLAS: column- and 75 # row-major); on the GB10, the route line of runlog with host 0 and gb10 > 0 76 n=$1; log=$2; want=$3; r=$4; run=$5 77 if [ "$DEV" = gb10 ]; then 78 rl=$(grep "^omega-blas routes:" "$run" || true) 79 echo "$n: $rl" 80 case "$rl" in 81 "omega-blas routes: device gb10 host 0 gb10 0 "*|"") echo "$n: FAIL (no calls reached the GB10)"; rc=1; return ;; 82 "omega-blas routes: device gb10 host 0 gb10 "*) ;; 83 *) echo "$n: FAIL (calls ran on the host)"; rc=1; return ;; 84 esac 85 fi 86 if [ -n "$THRESH" ]; then 87 grep "MAXIMUM TEST RATIO\|PASSED" "$log" | sed "s/^/$n: /" 88 if grep -q "FATAL\|FAILED" "$log" || [ "$(grep -c "END OF TESTS" "$log" || true)" != 1 ]; then echo "$n: FAIL"; rc=1; return; fi 89 echo "$n: measured (THRESH $THRESH)"; return 90 fi 91 if grep -q "FAIL\|SUSPECT\|\*\*\*\*\*\*" "$log"; then echo "$n: FAIL"; grep -n "FAIL\|SUSPECT\|\*\*\*\*\*\*" "$log" | head -20; rc=1; return; fi 92 c=$(grep -c "^ *$r *PASSED THE .*COMPUTATIONAL TESTS" "$log" || true) 93 e=$(grep -c "^ *$r *PASSED THE TESTS OF ERROR-EXITS" "$log" || true) 94 t=$(grep -c "END OF TESTS" "$log" || true) 95 if [ "$c" != "$want" ] || [ "$e" != 1 ] || [ "$t" != 1 ]; then 96 echo "$n: FAIL (computational PASSED $c/$want, error-exits PASSED $e/1, END OF TESTS $t/1)"; rc=1; return 97 fi 98 echo "$n: PASS"; grep "^ *$r *PASSED" "$log" 99 } 100 cd "$W" 101 # the F77 drivers write their summary to sblat?.out (named in the deck); the CBLAS ones to stdout 102 run() { # driver deck summary nblocks routine 103 case " ${DRIVERS:-sblat2 sblat3 c_sblat2 c_sblat3} " in *" $1 "*) ;; *) echo "$1: NOT_RUN (DRIVERS)"; rc=1; return ;; esac 104 t0=$(date +%s.%N) 105 ./$1 < $2 > $1.log 2>&1 || { echo "$1 exit $?"; rc=1; } 106 echo "$1: wall $(echo "$(date +%s.%N) - $t0" | bc) s" 107 check $1 $3 $4 $5 $1.log 108 } 109 run sblat2 sblat2.in sblat2.out 1 SGEMV 110 run sblat3 sblat3.in sblat3.out 1 SGEMM 111 run c_sblat2 sin2 c_sblat2.log 2 cblas_sgemv 112 run c_sblat3 sin3 c_sblat3.log 2 cblas_sgemm 113 exit $rc