Remove unused variable forgotten to remove
[ppcg.git] / opencl_test.sh.in
blobb974d002e339c52df84303eba5944611a56d6d96
1 #!/bin/sh
3 keep=no
5 for option; do
6 case "$option" in
7 --keep)
8 keep=yes
9 ;;
10 esac
11 done
13 EXEEXT=@EXEEXT@
14 VERSION=@GIT_HEAD_VERSION@
15 CC="@CC@"
16 CFLAGS="--std=gnu99"
17 srcdir="@srcdir@"
19 if [ $keep = "yes" ]; then
20 OUTDIR="opencl_test.$VERSION"
21 mkdir "$OUTDIR" || exit 1
22 else
23 if test "x$TMPDIR" = "x"; then
24 TMPDIR=/tmp
26 OUTDIR=`mktemp -d $TMPDIR/ppcg.XXXXXXXXXX` || exit 1
29 run_tests () {
30 subdir=$1
31 ppcg_options=$2
33 echo Test with PPCG options \'$ppcg_options\'
34 mkdir ${OUTDIR}/${subdir} || exit 1
35 for i in $srcdir/tests/*.c; do
36 echo $i
37 name=`basename $i`
38 name="${name%.c}"
39 out_c="${OUTDIR}/${subdir}/$name.ppcg.c"
40 out="${OUTDIR}/${subdir}/$name.ppcg$EXEEXT"
41 options="--target=opencl --opencl-no-use-gpu $ppcg_options"
42 functions="$srcdir/tests/${name}_opencl_functions.cl"
43 if test -f $functions; then
44 options="$options --opencl-include-file=$functions"
45 options="$options --opencl-compiler-options=-I."
47 ./ppcg$EXEEXT $options $i -o "$out_c" || exit
48 $CC $CFLAGS -I "$srcdir" "$srcdir/ocl_utilities.c" -lOpenCL \
49 -I. "$out_c" -o "$out" || exit
50 $out || exit
51 done
54 run_tests default
55 run_tests embed --opencl-embed-kernel-code
57 for i in $srcdir/examples/*.c; do
58 echo $i
59 name=`basename $i`
60 name="${name%.c}"
61 exe_ref="${OUTDIR}/$name.ref$EXEEXT"
62 gen_ocl="${OUTDIR}/$name.ppcg.c"
63 exe_ocl="${OUTDIR}/$name.ppcg$EXEEXT"
64 output_ref="${OUTDIR}/$name.ref.out"
65 output_ocl="${OUTDIR}/$name.ppcg.out"
66 $CC $CFLAGS $i -o $exe_ref || exit
67 ./ppcg$EXEEXT --target=opencl --opencl-no-use-gpu $i -o "$gen_ocl" || \
68 exit
69 $CC $CFLAGS -I "$srcdir" "$srcdir/ocl_utilities.c" -lOpenCL \
70 "$gen_ocl" -o "$exe_ocl" || exit
71 $exe_ref > $output_ref || exit
72 $exe_ocl > $output_ocl || exit
73 cmp $output_ref $output_ocl || exit
74 done
76 if [ $keep = "no" ]; then
77 rm -r "${OUTDIR}"