From: Siarhei Siamashka Date: Tue, 11 May 2010 22:34:57 +0000 (+0300) Subject: test: added OpenMP support for better utilization of multiple CPU cores X-Git-Tag: pixman-0.19.2~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cfc4e38852dc244198a9bfcab07d9014bba21d53;p=platform%2Fupstream%2Fpixman.git 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. --- 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)