summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiarhei Siamashka <siarhei.siamashka@nokia.com>2010-05-12 01:34:57 +0300
committerSiarhei Siamashka <siarhei.siamashka@nokia.com>2010-05-13 21:04:55 +0300
commitcfc4e38852dc244198a9bfcab07d9014bba21d53 (patch)
tree36387a99735e7f180abe5bde1bc8ece5599b2838
parentf905ebb03d8ed8a3ceb76c84a10735aa209168d3 (diff)
test: added OpenMP support for better utilization of multiple CPU cores
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.
-rw-r--r--configure.ac4
-rw-r--r--test/Makefile.am3
-rw-r--r--test/utils.c2
-rw-r--r--test/utils.h1
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)