ppcg_scop: store pointer to pet_scop rather than copying most of its members
[ppcg.git] / polybench_test.sh.in
blob98d5363e7861563305323a327213a1024a3e6e5d
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 srcdir="@srcdir@"
24 if [ $keep = "yes" ]; then
25 OUTDIR="out.$VERSION"
26 mkdir "$OUTDIR" || exit 1
27 else
28 if test "x$TMPDIR" = "x"; then
29 TMPDIR=/tmp
31 OUTDIR=`mktemp -d $TMPDIR/ppcg.XXXXXXXXXX` || exit 1
33 CPPFLAGS="-DPOLYBENCH_USE_C99_PROTO -DPOLYBENCH_DUMP_ARRAYS"
34 CPPFLAGS="$CPPFLAGS $SIZE -I $DIR/utilities"
35 CFLAGS="-lm --std=gnu99"
37 echo "Running tests in folder ${OUTDIR}"
39 run_tests () {
40 ext=$1
42 ppcg_options=$2
43 cc_options=$3
45 if [ "x$ppcg_options" = "x" ]; then
46 ppcg_option_str="none"
47 else
48 ppcg_option_str=$ppcg_options
51 if [ "x$cc_options" = "x" ]; then
52 cc_option_str="none"
53 else
54 cc_option_str=$cc_options
57 echo Test: $ext, ppcg options: $ppcg_option_str, CC options: $cc_option_str
58 for i in `cat $DIR/utilities/benchmark_list`; do
59 echo $i
60 name=`basename $i`
61 name=${name%.c}
62 source_opt="${OUTDIR}/$name.$ext.c"
63 prog_orig=${OUTDIR}/$name.orig${EXEEXT}
64 prog_opt=${OUTDIR}/$name.$ext${EXEEXT}
65 output_orig=${OUTDIR}/$name.orig.out
66 output_opt=${OUTDIR}/$name.$ext.out
67 dir=`dirname $i`
68 if [ $verbose = "yes" ]; then
69 echo ./ppcg$EXEEXT -I $DIR/$dir $DIR/$i \
70 $CPPFLAGS -o $source_opt $ppcg_options
72 ./ppcg$EXEEXT -I $DIR/$dir $DIR/$i $CPPFLAGS \
73 -o $source_opt $ppcg_options || exit
74 $CC -I $DIR/$dir $CPPFLAGS $DIR/$i -o $prog_orig \
75 $DIR/utilities/polybench.c $CFLAGS
76 $prog_orig 2> $output_orig
77 if [ $verbose = "yes" ]; then
78 echo $CC -I $DIR/$dir $CPPFLAGS $source_opt \
79 -o $prog_opt $DIR/utilities/polybench.c \
80 $CFLAGS $cc_options
82 $CC -I $DIR/$dir $CPPFLAGS $source_opt -o $prog_opt \
83 $DIR/utilities/polybench.c $CFLAGS $cc_options || exit
85 $prog_opt 2> $output_opt
86 cmp $output_orig $output_opt || exit
87 done
90 run_tests ppcg --target=c
91 run_tests ppcg_live "--target=c --no-live-range-reordering"
93 # Test OpenMP code, if compiler supports openmp
94 echo | $CC -x c - -fsyntax-only -fopenmp -Werror 1> /dev/null 2> /dev/null
95 OUT=$?
96 if [ $OUT -eq 0 ]; then
97 run_tests ppcg_omp "--target=c --openmp" -fopenmp
98 echo Introduced `grep -R 'omp parallel' "${OUTDIR}" | wc -l` '"pragma omp parallel for"'
99 else
100 echo Compiler does not support OpenMP. Skipping OpenMP tests.
103 if [ $HAVE_OPENCL = "yes" ]; then
104 run_tests ppcg_opencl "--target=opencl --opencl-no-use-gpu" \
105 "$srcdir/ocl_utilities.c -lOpenCL"
108 if [ $keep = "no" ]; then
109 rm -r "${OUTDIR}"