[Pixman] [PATCH 5/5] test: added OpenMP support for better utilization of multiple CPU cores
Siarhei Siamashka
siarhei.siamashka at gmail.com
Tue May 25 10:15:08 PDT 2010
From: Siarhei Siamashka <siarhei.siamashka at nokia.com>
Some of the tests are quite heavy CPU users and may benefit from
using multiple CPU cores, so the programs from 'test' directory
are now built with OpenMP support. OpenMP is easy to use, portable
and also takes care of making a decision about how many threads
to spawn.
---
configure.ac | 4 ++++
test/Makefile.am | 3 +++
test/utils.c | 2 ++
test/utils.h | 1 +
4 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index c9d0c66..56a6e4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,6 +77,10 @@ AC_CHECK_FUNCS([getisax])
AC_C_BIGENDIAN
AC_C_INLINE
+# Check for OpenMP support (only supported by autoconf >=2.62)
+OPENMP_CFLAGS=
+m4_ifdef([AC_OPENMP], [AC_OPENMP], [AC_SUBST(OPENMP_CFLAGS)])
+
AC_CHECK_SIZEOF(long)
# Checks for Sun Studio compilers
diff --git a/test/Makefile.am b/test/Makefile.am
index 4ef6b45..d0019ef 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,3 +1,6 @@
+AM_CFLAGS = @OPENMP_CFLAGS@
+AM_LDFLAGS = @OPENMP_CFLAGS@
+
TEST_LDADD = $(top_builddir)/pixman/libpixman-1.la
INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman
diff --git a/test/utils.c b/test/utils.c
index 9cfd9fa..e9b29c8 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -286,6 +286,8 @@ fuzzer_test_main (const char *test_name,
n2 = default_number_of_iterations;
}
+ #pragma omp parallel for reduction(+:checksum) default(none) \
+ shared(n1, n2, test_function, verbose)
for (i = n1; i <= n2; i++)
{
uint32_t crc = test_function (i, 0);
diff --git a/test/utils.h b/test/utils.h
index 161635f..26a244c 100644
--- a/test/utils.h
+++ b/test/utils.h
@@ -7,6 +7,7 @@
*/
extern uint32_t lcg_seed;
+#pragma omp threadprivate(lcg_seed)
static inline uint32_t
lcg_rand (void)
--
1.6.4.4
More information about the Pixman
mailing list