update pet for support for recent clangs
[ppcg.git] / polybench_test.sh.in
blob4d54cb9211862600c30b9b6cbf646b1952b00fe7
1 #!/bin/sh
3 keep=no
4 verbose=no
6 for option; do
7 case "$option" in
8 --keep)
9 keep=yes
11 --verbose)
12 verbose=yes
14 esac
15 done
17 EXEEXT=@EXEEXT@
18 DIR=@POLYBENCH_DIR@
19 VERSION=@GIT_HEAD_VERSION@
20 SIZE=-DMINI_DATASET
21 CC="@CC@"
22 HAVE_OPENCL=@HAVE_OPENCL@
23 HAVE_OPENMP=@HAVE_OPENMP@
24 srcdir="@srcdir@"
25 if [ $keep = "yes" ]; then
26 OUTDIR="out.$VERSION"
27 mkdir "$OUTDIR" || exit 1
28 else
29 if test "x$TMPDIR" = "x"; then
30 TMPDIR=/tmp
32 OUTDIR=`mktemp -d $TMPDIR/ppcg.XXXXXXXXXX` || exit 1
34 CPPFLAGS="-DPOLYBENCH_USE_C99_PROTO -DPOLYBENCH_DUMP_ARRAYS"
35 CPPFLAGS="$CPPFLAGS $SIZE -I $DIR/utilities"
36 CFLAGS="-lm --std=gnu99"
38 echo "Running tests in folder ${OUTDIR}"
40 run_tests () {
41 ext=$1
43 ppcg_options=$2
44 cc_options=$3
46 if [ "x$ppcg_options" = "x" ]; then
47 ppcg_option_str="none"
48 else
49 ppcg_option_str=$ppcg_options
52 if [ "x$cc_options" = "x" ]; then
53 cc_option_str="none"
54 else
55 cc_option_str=$cc_options
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
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
83 $CC -I $DIR/$dir $CPPFLAGS $source_opt -o $prog_opt \
84 $DIR/utilities/polybench.c $CFLAGS $cc_options || exit
86 $prog_opt 2> $output_opt
87 cmp $output_orig $output_opt || exit
88 done
91 run_tests ppcg "--target=c --tile"
92 run_tests ppcg_live "--target=c --no-live-range-reordering --tile"
94 # Test OpenMP code, if compiler supports openmp
95 if [ $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"'
98 else
99 echo Compiler does not support OpenMP. Skipping OpenMP tests.
102 if [ $HAVE_OPENCL = "yes" ]; then
103 run_tests ppcg_opencl "--target=opencl --opencl-no-use-gpu" \
104 "-I $srcdir $srcdir/ocl_utilities.c -lOpenCL"
107 if [ $keep = "no" ]; then
108 rm -r "${OUTDIR}"