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