diff options
author | Gilles Espinasse <g.esp@free.fr> | 2011-03-05 13:37:10 +0100 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-03-08 08:31:08 -0500 |
commit | 1f9ebd7f1951147333747aa3b36a393c13566fa5 (patch) | |
tree | f1589489a1727cf7a2256c30510026be2edfcb46 | |
parent | 1819196b903b3ed7b7f889052d149730d84b9148 (diff) |
Fix OpenMP not supported caseopenmp-configure
USE_OPENMP should not be defined in that case
Suppress unneded m4_ifdef([AC_OPENMP], [AC_OPENMP]) and use simply AC_OPENMP
No need to preset OPENMP_CFLAGS empty, AC_OPENMP will set the correct value in all case
Warn when --enable-openmp is requested but no support is found
PIXMAN_LINK_WITH_ENV did not fail unless we add -Wall -Werror.
So even when the compiler did not support OpenMP, USE_OPENMP was defined.
Fix that by running the second OpenMP test only when first AC_OPENMP find supported
Tested configure in the cases :
gcc without libgomp support, no openmp option, --enable-openmp and --disable-openmp
gcc with libgomp support, no openmp option, --enable-openmp and --disable-openmp
Not compiled, there is some libtool issue on autoreconf
autoconf-2.68 trigger too numerous
warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
Signed-off-by: Gilles Espinasse <g.esp@free.fr>
Cc: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
-rw-r--r-- | configure.ac | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/configure.ac b/configure.ac index 70ded321..260bc716 100644 --- a/configure.ac +++ b/configure.ac @@ -193,34 +193,42 @@ dnl OpenMP for the test suite? dnl # Check for OpenMP support (only supported by autoconf >=2.62) -OPENMP_CFLAGS= -m4_ifdef([AC_OPENMP], [AC_OPENMP]) -m4_define([openmp_test_program],[dnl -#include <stdio.h> +AC_OPENMP(C) -extern unsigned int lcg_seed; -#pragma omp threadprivate(lcg_seed) -unsigned int lcg_seed; +if test "x$enable_openmp" = "xyes" && test "x$ac_cv_prog_c_openmp" = "xunsupported" ; then + AC_MSG_WARN([OpenMP support requested but found unsupported]) +fi -unsigned function(unsigned a, unsigned b) -{ +dnl May not fail to link without -Wall -Werror added +dnl So run only when case openmp is supported +dnl ac_cv_prog_c_openmp is not defined when --disable-openmp is used +if test "x$ac_cv_prog_c_openmp" != "xunsupported" && test "x$ac_cv_prog_c_openmp" != "x"; then + m4_define([openmp_test_program],[dnl + #include <stdio.h> + + extern unsigned int lcg_seed; + #pragma omp threadprivate(lcg_seed) + unsigned int lcg_seed; + + unsigned function(unsigned a, unsigned b) + { lcg_seed ^= b; return ((a + b) ^ a ) + lcg_seed; -} + } -int main(int argc, char **argv) -{ + int main(int argc, char **argv) + { int i; int n1 = 0, n2 = argc; unsigned checksum = 0; int verbose = argv != NULL; unsigned (*test_function)(unsigned, unsigned); test_function = function; - #pragma omp parallel for reduction(+:checksum) default(none) \ + #pragma omp parallel for reduction(+:checksum) default(none) \ shared(n1, n2, test_function, verbose) for (i = n1; i < n2; i++) - { + { unsigned crc = test_function (i, 0); if (verbose) printf ("%d: %08X\n", i, crc); @@ -228,18 +236,17 @@ int main(int argc, char **argv) } printf("%u\n", checksum); return 0; -} -]) + } + ]) -PIXMAN_LINK_WITH_ENV( + PIXMAN_LINK_WITH_ENV( [CFLAGS="$OPENMP_CFLAGS" LDFLAGS="$OPENMP_CFLAGS"], [openmp_test_program], [have_openmp=yes], [have_openmp=no]) -if test "x$have_openmp" = "xyes"; then - AC_DEFINE(USE_OPENMP, 1, [use OpenMP in the test suite]) -else - OPENMP_CFLAGS="" + if test "x$have_openmp" = "xyes" ; then + AC_DEFINE(USE_OPENMP, 1, [use OpenMP in the test suite]) + fi fi AC_SUBST(OPENMP_CFLAGS) |