reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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
#!/bin/sh

keep=no

for option; do
	case "$option" in
		--keep)
			keep=yes
			;;
	esac
done

EXEEXT=@EXEEXT@
VERSION=@GIT_HEAD_VERSION@
CC="@CC@"
CFLAGS="--std=gnu99"
srcdir="@srcdir@"

if [ $keep = "yes" ]; then
	OUTDIR="opencl_test.$VERSION"
	mkdir "$OUTDIR" || exit 1
else
	if test "x$TMPDIR" = "x"; then
		TMPDIR=/tmp
	fi
	OUTDIR=`mktemp -d $TMPDIR/ppcg.XXXXXXXXXX` || exit 1
fi

run_tests () {
	subdir=$1
	ppcg_options=$2

	echo Test with PPCG options \'$ppcg_options\'
	mkdir ${OUTDIR}/${subdir} || exit 1
	for i in $srcdir/tests/*.c; do
		echo $i
		name=`basename $i`
		name="${name%.c}"
		out_c="${OUTDIR}/${subdir}/$name.ppcg.c"
		out="${OUTDIR}/${subdir}/$name.ppcg$EXEEXT"
		options="--target=opencl --opencl-no-use-gpu $ppcg_options"
		functions="$srcdir/tests/${name}_opencl_functions.cl"
		if test -f $functions; then
			options="$options --opencl-include-file=$functions"
			options="$options --opencl-compiler-options=-I."
		fi
		./ppcg$EXEEXT $options $i -o "$out_c" || exit
		$CC $CFLAGS -I "$srcdir" "$srcdir/ocl_utilities.c" -lOpenCL \
			-I. "$out_c" -o "$out" || exit
		$out || exit
	done
}

run_tests default
run_tests embed --opencl-embed-kernel-code

for i in $srcdir/examples/*.c; do
	echo $i
	name=`basename $i`
	name="${name%.c}"
	exe_ref="${OUTDIR}/$name.ref$EXEEXT"
	gen_ocl="${OUTDIR}/$name.ppcg.c"
	exe_ocl="${OUTDIR}/$name.ppcg$EXEEXT"
	output_ref="${OUTDIR}/$name.ref.out"
	output_ocl="${OUTDIR}/$name.ppcg.out"
	$CC $CFLAGS $i -o $exe_ref || exit
	./ppcg$EXEEXT --target=opencl --opencl-no-use-gpu $i -o "$gen_ocl" || \
		exit
	$CC $CFLAGS -I "$srcdir" "$srcdir/ocl_utilities.c" -lOpenCL \
		"$gen_ocl" -o "$exe_ocl" || exit
	$exe_ref > $output_ref || exit
	$exe_ocl > $output_ocl || exit
	cmp $output_ref $output_ocl || exit
done

if [ $keep = "no" ]; then
	rm -r "${OUTDIR}"
fi