[gegl] tests: Run composition tests with and without OpenCL
- From: Daniel Sabo <daniels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] tests: Run composition tests with and without OpenCL
- Date: Thu, 17 Oct 2013 18:24:26 +0000 (UTC)
commit befea5f220c5c7eaa63f931bfb592d7ea069dd87
Author: Daniel Sabo <DanielSabo gmail com>
Date: Wed Oct 16 21:17:24 2013 -0700
tests: Run composition tests with and without OpenCL
tests/compositions/Makefile.am | 40 ++++++++++++++++++++++++++++++++++------
tools/.gitignore | 11 +++++++----
tools/Makefile.am | 2 +-
tools/detect_opencl.c | 38 ++++++++++++++++++++++++++++++++++++++
4 files changed, 80 insertions(+), 11 deletions(-)
---
diff --git a/tests/compositions/Makefile.am b/tests/compositions/Makefile.am
index d786ffa..67659b2 100644
--- a/tests/compositions/Makefile.am
+++ b/tests/compositions/Makefile.am
@@ -18,18 +18,24 @@ builddir_gegl_env = GEGL_SWAP=RAM GEGL_PATH=$(top_builddir)/operations
# Binary paths
gegl_bin = $(top_builddir)/bin/gegl$(EXEEXT)
img_cmp_bin = $(top_builddir)/tools/img_cmp$(EXEEXT)
+detect_opencl_bin = $(top_builddir)/tools/detect_opencl$(EXEEXT)
# Commands run in a builddir env
builddir_gegl = $(builddir_gegl_env) $(gegl_bin)
builddir_img_cmp = $(builddir_gegl_env) $(img_cmp_bin)
+builddir_detect_opencl = $(builddir_gegl_env) $(detect_opencl_bin)
+
+TESTS_ENVIRONMENT = \
+ GEGL_TEST_HAVE_OPENCL=$(shell $(builddir_detect_opencl))
# These strings must not be inside XML file names; we use $(subst ...)
+opencl_testprefix = run-opencl-
testprefix = run-
testsuffix = .sh
# List of tests. The .sh suffix allows us to use $(wildcard $(srcdir)/*.xml) in
# EXTRA_DISTS
-TESTS = \
+BASE_TESTS = \
run-affine-with-negative.xml.sh \
run-checkerboard.xml.sh \
run-clones.xml.sh \
@@ -46,19 +52,24 @@ TESTS = \
run-reflect2.xml.sh \
run-reinhard05.xml.sh \
run-rgb-params.xml.sh \
- run-rgbe-load.xml.sh \
- run-rgbe-save.xml.sh \
run-rotate.xml.sh \
run-simple-scale.xml.sh \
run-softglow.xml.sh \
run-transform.xml.sh \
- run-rectangles.xml.sh \
+ run-rectangles.xml.sh
+
+NO_OPENCL_TESTS = \
+ run-rgbe-load.xml.sh \
+ run-rgbe-save.xml.sh \
run-pnm-raw-load.xml.sh \
run-pnm-ascii-load.xml.sh
#run-matting-global.xml.sh
#run-matting-global-big.xml.sh
+TESTS = $(foreach basetest,$(BASE_TESTS),$(basetest) $(subst
$(testprefix),$(opencl_testprefix),$(basetest)))
+TESTS += $(NO_OPENCL_TESTS)
+
# Conditional tests
if HAVE_JASPER
TESTS += run-jp2-load.xml.sh
@@ -67,7 +78,24 @@ if HAVE_UMFPACK
TESTS += run-matting-levin.xml.sh
endif
+
+
# Create a separate executable script for each composition test to run
+opencl_test_to_xml = $(abs_srcdir)/$(subst $(testsuffix),,$(subst $(opencl_testprefix),,$(1)))
+opencl_test_to_ref = $(wildcard $(abs_srcdir)/reference/$(basename $(notdir $(call
opencl_test_to_xml,$(1)))).*)
+opencl_test_to_out = $(abs_builddir)/output/opencl-$(notdir $(call opencl_test_to_ref,$(1)))
+$(opencl_testprefix)%.xml.sh: Makefile.am $(call opencl_test_to_xml,$@) $(call opencl_test_to_ref,$@)
+ @xml_file=$(call opencl_test_to_xml,$@) ;\
+ ref_img=$(call opencl_test_to_ref,$@) ;\
+ out_img=$(call opencl_test_to_out,$@) ;\
+ echo "#!/bin/bash" > $@ ;\
+ echo "if [ \"x\$$GEGL_TEST_HAVE_OPENCL\" = \"xno\" ]; then exit 77; fi" > $@ ;\
+ echo "mkdir -p $(abs_builddir)/output" >> $@ ;\
+ echo "if [ -a $$out_img ]; then rm $$out_img ; fi" >> $@ ;\
+ echo "$(builddir_gegl) $$xml_file -o $$out_img" >> $@ ;\
+ echo GEGL_USE_OPENCL=no "$(builddir_img_cmp) $$ref_img $$out_img" >> $@ ;\
+ chmod +x $@
+
test_to_xml = $(abs_srcdir)/$(subst $(testsuffix),,$(subst $(testprefix),,$(1)))
test_to_ref = $(wildcard $(abs_srcdir)/reference/$(basename $(notdir $(call test_to_xml,$(1)))).*)
test_to_out = $(abs_builddir)/output/$(notdir $(call test_to_ref,$(1)))
@@ -78,8 +106,8 @@ $(testprefix)%.xml.sh: Makefile.am $(call test_to_xml,$@) $(call test_to_ref,$@)
echo "#!/bin/bash" > $@ ;\
echo "mkdir -p $(abs_builddir)/output" >> $@ ;\
echo "if [ -a $$out_img ]; then rm $$out_img ; fi" >> $@ ;\
- echo "$(builddir_gegl) $$xml_file -o $$out_img" >> $@ ;\
- echo "$(builddir_img_cmp) $$ref_img $$out_img" >> $@ ;\
+ echo GEGL_USE_OPENCL=no "$(builddir_gegl) $$xml_file -o $$out_img" >> $@ ;\
+ echo GEGL_USE_OPENCL=no "$(builddir_img_cmp) $$ref_img $$out_img" >> $@ ;\
chmod +x $@
clean-local:
diff --git a/tools/.gitignore b/tools/.gitignore
index cae195e..312b285 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -1,8 +1,11 @@
/.deps
/.libs
+*.o
+*.exe
/Makefile
/Makefile.in
-/exp_combine*
-/img_cmp*
-/introspect*
-/operation_reference*
+/exp_combine
+/img_cmp
+/introspect
+/operation_reference
+/detect_opencl
\ No newline at end of file
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 8f1077d..ce2bc2d 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -24,7 +24,7 @@ AM_LDFLAGS = \
$(top_builddir)/gegl/libgegl-$(GEGL_API_VERSION).la \
$(DEP_LIBS) $(BABL_LIBS)
-noinst_PROGRAMS = introspect operation_reference img_cmp
+noinst_PROGRAMS = introspect operation_reference img_cmp detect_opencl
if HAVE_EXIV2
noinst_PROGRAMS += exp_combine
diff --git a/tools/detect_opencl.c b/tools/detect_opencl.c
new file mode 100644
index 0000000..d66894f
--- /dev/null
+++ b/tools/detect_opencl.c
@@ -0,0 +1,38 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (C) 2013 Daniel Sabo
+ */
+
+#include <stdio.h>
+
+#include "gegl.h"
+#include "opencl/gegl-cl.h"
+
+int main(int argc, char **argv)
+{
+ gegl_init(&argc, &argv);
+ if (gegl_cl_is_accelerated())
+ {
+ printf ("yes");
+ gegl_exit ();
+ return 0;
+ }
+ else
+ {
+ printf ("no");
+ gegl_exit ();
+ return 1;
+ }
+}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]