1#!/bin/sh 2 3keep=no 4verbose=no 5 6for option; do 7 case "$option" in 8 --keep) 9 keep=yes 10 ;; 11 --verbose) 12 verbose=yes 13 ;; 14 esac 15done 16 17EXEEXT=@EXEEXT@ 18DIR=@POLYBENCH_DIR@ 19VERSION=@GIT_HEAD_VERSION@ 20SIZE=-DMINI_DATASET 21CC="@CC@" 22HAVE_OPENCL=@HAVE_OPENCL@ 23HAVE_OPENMP=@HAVE_OPENMP@ 24srcdir="@srcdir@" 25if [ $keep = "yes" ]; then 26 OUTDIR="out.$VERSION" 27 mkdir "$OUTDIR" || exit 1 28else 29 if test "x$TMPDIR" = "x"; then 30 TMPDIR=/tmp 31 fi 32 OUTDIR=`mktemp -d $TMPDIR/ppcg.XXXXXXXXXX` || exit 1 33fi 34CPPFLAGS="-DPOLYBENCH_USE_C99_PROTO -DPOLYBENCH_DUMP_ARRAYS" 35CPPFLAGS="$CPPFLAGS $SIZE -I $DIR/utilities" 36CFLAGS="-lm --std=gnu99" 37 38echo "Running tests in folder ${OUTDIR}" 39 40run_tests () { 41 ext=$1 42 43 ppcg_options=$2 44 cc_options=$3 45 46 if [ "x$ppcg_options" = "x" ]; then 47 ppcg_option_str="none" 48 else 49 ppcg_option_str=$ppcg_options 50 fi 51 52 if [ "x$cc_options" = "x" ]; then 53 cc_option_str="none" 54 else 55 cc_option_str=$cc_options 56 fi 57 58 echo Test: $ext, ppcg options: $ppcg_option_str, CC options: $cc_option_str 59 for i in `cat $DIR/utilities/benchmark_list`; do 60 echo $i 61 name=`basename $i` 62 name=${name%.c} 63 source_opt="${OUTDIR}/$name.$ext.c" 64 prog_orig=${OUTDIR}/$name.orig${EXEEXT} 65 prog_opt=${OUTDIR}/$name.$ext${EXEEXT} 66 output_orig=${OUTDIR}/$name.orig.out 67 output_opt=${OUTDIR}/$name.$ext.out 68 dir=`dirname $i` 69 if [ $verbose = "yes" ]; then 70 echo ./ppcg$EXEEXT -I $DIR/$dir $DIR/$i \ 71 $CPPFLAGS -o $source_opt $ppcg_options 72 fi 73 ./ppcg$EXEEXT -I $DIR/$dir $DIR/$i $CPPFLAGS \ 74 -o $source_opt $ppcg_options || exit 75 $CC -I $DIR/$dir $CPPFLAGS $DIR/$i -o $prog_orig \ 76 $DIR/utilities/polybench.c $CFLAGS 77 $prog_orig 2> $output_orig 78 if [ $verbose = "yes" ]; then 79 echo $CC -I $DIR/$dir $CPPFLAGS $source_opt \ 80 -o $prog_opt $DIR/utilities/polybench.c \ 81 $CFLAGS $cc_options 82 fi 83 $CC -I $DIR/$dir $CPPFLAGS $source_opt -o $prog_opt \ 84 $DIR/utilities/polybench.c $CFLAGS $cc_options || exit 85 86 $prog_opt 2> $output_opt 87 cmp $output_orig $output_opt || exit 88 done 89} 90 91run_tests ppcg "--target=c --tile" 92run_tests ppcg_live "--target=c --no-live-range-reordering --tile" 93 94# Test OpenMP code, if compiler supports openmp 95if [ $HAVE_OPENMP = "yes" ]; then 96 run_tests ppcg_omp "--target=c --openmp" -fopenmp 97 echo Introduced `grep -R 'omp parallel' "${OUTDIR}" | wc -l` '"pragma omp parallel for"' 98else 99 echo Compiler does not support OpenMP. Skipping OpenMP tests. 100fi 101 102if [ $HAVE_OPENCL = "yes" ]; then 103 run_tests ppcg_opencl "--target=opencl --opencl-no-use-gpu" \ 104 "-I $srcdir $srcdir/ocl_utilities.c -lOpenCL" 105fi 106 107if [ $keep = "no" ]; then 108 rm -r "${OUTDIR}" 109fi 110