[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: detection and support of OpenMP
From: |
Bruno Haible |
Subject: |
Re: detection and support of OpenMP |
Date: |
Sun, 27 May 2007 22:53:06 +0200 |
User-agent: |
KMail/1.5.4 |
Noah Misch wrote on Tuesday:
> If we reach the stage of testing additional compiler options, the current $CC
> $CFLAGS failed to compile the test program. If that compiler treats `-openmp'
> like `-o penmp', it will still fail to compile the test program. Do we really
> need this special care?
>
> Possible simplifying patch:
>
> diff -Nurp -X dontdiff ac-clean/lib/autoconf/c.m4
> ac-openmp_percomp/lib/autoconf/c.m4
> --- ac-clean/lib/autoconf/c.m4 2007-05-21 18:42:08.000000000 -0400
> +++ ac-openmp_percomp/lib/autoconf/c.m4 2007-05-21 18:54:19.000000000
> -0400
> @@ -1906,48 +1906,13 @@ AC_DEFUN([AC_OPENMP],
> dnl SGI C, PGI C -mp
> dnl Tru64 Compaq C -omp
> dnl IBM C (AIX, Linux) -qsmp=omp
> - for ac_brand in GCC SunPRO Intel SGI/PGI Compaq IBM; do
> - case $ac_brand in
> - GCC)
> - ac_conditional='defined __GNUC__'
> - ac_option='-fopenmp' ;;
> - SunPRO)
> - ac_conditional='defined __SUNPRO_C || defined __SUNPRO_CC'
> - ac_option='-xopenmp' ;;
> - Intel)
> - ac_conditional='defined __INTEL_COMPILER'
> - ac_option='-openmp' ;;
> - SGI/PGI)
> - ac_conditional='defined __sgi || defined __PGI || defined
> __PGIC__'
> - ac_option='-mp' ;;
> - Compaq)
> - ac_conditional='defined __DECC || defined __DECCXX'
> - ac_option='-omp' ;;
> - IBM)
> - ac_conditional='defined __xlc__ || defined __xlC__'
> - ac_option='-qsmp=omp' ;;
> - esac
> - if test $ac_brand = GCC; then
> - if test "$ac_compiler_gnu" = yes; then
> - ac_openmp_result=yes
> - else
> - ac_openmp_result=no
> - fi
> - else
> - AC_EGREP_CPP([Brand], [
> - #if $ac_conditional
> - Brand
> - #endif
> - ], [ac_openmp_result=yes], [ac_openmp_result=no])
> - fi
> - if test $ac_openmp_result = yes; then
> - ac_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
> - _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $ac_option"
> - AC_LINK_IFELSE([_AC_LANG_OPENMP],
> - [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp=$ac_option])
> - _AC_LANG_PREFIX[]FLAGS=$ac_save_[]_AC_LANG_PREFIX[]FLAGS
> - break
> - fi
> + for ac_option in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do
> + ac_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
> + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $ac_option"
> + AC_LINK_IFELSE([_AC_LANG_OPENMP],
> + [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp=$ac_option])
> + _AC_LANG_PREFIX[]FLAGS=$ac_save_[]_AC_LANG_PREFIX[]FLAGS
> + break
> done
> fi
> ])
Excellent observation. You must be a mathematician :-)
Well, your patch never got to trying the second, third, etc. possibility,
due to the unconditional 'break'. I have tested the appended modified patch:
it works with gcc (with result -fopenmp) and with Sun cc (with result -xopenmp),
therefore I believe the other compilers will work as well. Also I added
the necessary comments.
The good thing about your patch is that it gets rid of the compiler brand
tests, thus the Fortran support should work fine with this version (untested).
2007-05-27 Noah Misch <address@hidden>
Bruno Haible <address@hidden>
* lib/autoconf/c.m4 (AC_OPENMP): Use a simple loop instead of compiler
brand tests.
*** lib/autoconf/c.m4.old 2007-05-27 18:16:13.000000000 +0200
--- lib/autoconf/c.m4 2007-05-27 22:45:43.000000000 +0200
***************
*** 1903,1951 ****
dnl SGI C, PGI C -mp
dnl Tru64 Compaq C -omp
dnl IBM C (AIX, Linux) -qsmp=omp
! for ac_brand in GCC SunPRO Intel SGI/PGI Compaq IBM; do
! case $ac_brand in #(
! GCC)
! ac_conditional='defined __GNUC__'
! ac_option='-fopenmp' ;; #(
! SunPRO)
! ac_conditional='defined __SUNPRO_C || defined __SUNPRO_CC'
! ac_option='-xopenmp' ;; #(
! Intel)
! ac_conditional='defined __INTEL_COMPILER'
! ac_option='-openmp' ;; #(
! SGI/PGI)
! ac_conditional='defined __sgi || defined __PGI || defined
__PGIC__'
! ac_option='-mp' ;; #(
! Compaq)
! ac_conditional='defined __DECC || defined __DECCXX'
! ac_option='-omp' ;; #(
! IBM)
! ac_conditional='defined __xlc__ || defined __xlC__'
! ac_option='-qsmp=omp' ;;
! esac
! if test $ac_brand = GCC; then
! if test "$ac_compiler_gnu" = yes; then
! ac_openmp_result=yes
! else
! ac_openmp_result=no
! fi
! else
! AC_EGREP_CPP([Brand],
! [
! #if $ac_conditional
! Brand
! #endif
! ],
! [ac_openmp_result=yes],
! [ac_openmp_result=no])
! fi
! if test $ac_openmp_result = yes; then
! ac_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
! _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $ac_option"
! AC_LINK_IFELSE([_AC_LANG_OPENMP],
! [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp=$ac_option])
! _AC_LANG_PREFIX[]FLAGS=$ac_save_[]_AC_LANG_PREFIX[]FLAGS
break
fi
done])])
--- 1903,1920 ----
dnl SGI C, PGI C -mp
dnl Tru64 Compaq C -omp
dnl IBM C (AIX, Linux) -qsmp=omp
! dnl If in this loop a compiler is passed an option that it doesn't
! dnl understand or that it misinterprets, the AC_LINK_IFELSE test
! dnl will fail (since we know that it failed without the option),
! dnl therefore the loop will continue searching for an option, and
! dnl no output file called 'penmp' or 'mp' is created.
! for ac_option in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do
! ac_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
! _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $ac_option"
! AC_LINK_IFELSE([_AC_LANG_OPENMP],
! [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp=$ac_option])
! _AC_LANG_PREFIX[]FLAGS=$ac_save_[]_AC_LANG_PREFIX[]FLAGS
! if test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" != unsupported;
then
break
fi
done])])
- Re: detection and support of OpenMP, (continued)
- Re: detection and support of OpenMP, Ralf Wildenhues, 2007/05/17
- Re: detection and support of OpenMP, Bruno Haible, 2007/05/17
- Re: detection and support of OpenMP, Ralf Wildenhues, 2007/05/17
- Re: detection and support of OpenMP, Bruno Haible, 2007/05/17
- Re: detection and support of OpenMP, Paul Eggert, 2007/05/21
- Re: detection and support of OpenMP, Bruno Haible, 2007/05/21
- Re: detection and support of OpenMP, Paul Eggert, 2007/05/21
- Re: detection and support of OpenMP, Noah Misch, 2007/05/21
- Re: detection and support of OpenMP, Paul Eggert, 2007/05/21
- Re: detection and support of OpenMP, Noah Misch, 2007/05/21
- Re: detection and support of OpenMP,
Bruno Haible <=
Re: detection and support of OpenMP, Noah Misch, 2007/05/17
Re: detection and support of OpenMP, Paul Eggert, 2007/05/17