diff --git a/config/pac.m4 b/config/pac.m4 index 46a56b68..ecf8e475 100644 --- a/config/pac.m4 +++ b/config/pac.m4 @@ -363,6 +363,45 @@ fi ] ) +dnl @synopsis PAC_ARG_OPENMP +dnl +dnl Test for --enable-openmp +dnl +dnl +dnl +dnl Example use: +dnl +dnl +dnl @author Salvatore Filippone +dnl +AC_DEFUN([PAC_ARG_OPENMP], +[AC_MSG_CHECKING([whether we want openmp ]) +AC_ARG_ENABLE(openmp, +AC_HELP_STRING([--enable-openmp], +[Specify whether to enable openmp. ]), +[ +pac_cv_openmp="yes"; +] +dnl , +dnl [pac_cv_openmp="no";] + ) +if test x"$pac_cv_openmp" == x"yes" ; then + AC_MSG_RESULT([yes.]) + AC_LANG_PUSH([Fortran]) + AC_OPENMP() + pac_cv_openmp_fcopt="$OPENMP_FCFLAGS"; + AC_LANG_POP() + AC_LANG_PUSH([C]) + AC_OPENMP() + pac_cv_openmp_ccopt="$OPENMP_CFLAGS"; + AC_LANG_POP() +else + pac_cv_openmp="no"; + AC_MSG_RESULT([no.]) +fi +] +) + dnl @synopsis PAC_ARG_LONG_INTEGERS dnl dnl Test for --enable-long-integers diff --git a/configure b/configure index e8688547..4bd53950 100755 --- a/configure +++ b/configure @@ -663,6 +663,8 @@ BASEMODNAME CDEFINES FDEFINES LAPACK_LIBS +OPENMP_CFLAGS +OPENMP_FCFLAGS EGREP GREP CPP @@ -771,6 +773,7 @@ enable_dependency_tracking enable_silent_rules with_ipk with_lpk +enable_openmp with_blas with_blasdir with_lapack @@ -1420,6 +1423,8 @@ Optional Features: speeds up one-time build --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") + --enable-openmp Specify whether to enable openmp. + --disable-openmp do not use OpenMP Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -6890,7 +6895,187 @@ FDEFINES="$psblas_cv_define_prepend-DIPK${pac_cv_ipk_size} $FDEFINES"; FDEFINES="$psblas_cv_define_prepend-DLPK${pac_cv_lpk_size} $FDEFINES"; CDEFINES="-DIPK${pac_cv_ipk_size} -DLPK${pac_cv_lpk_size} $CDEFINES" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we want openmp " >&5 +$as_echo_n "checking whether we want openmp ... " >&6; } +# Check whether --enable-openmp was given. +if test "${enable_openmp+set}" = set; then : + enableval=$enable_openmp; +pac_cv_openmp="yes"; + +fi + +if test x"$pac_cv_openmp" == x"yes" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes." >&5 +$as_echo "yes." >&6; } + ac_ext=${ac_fc_srcext-f} +ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5' +ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_fc_compiler_gnu + + + OPENMP_FCFLAGS= + # Check whether --enable-openmp was given. +if test "${enable_openmp+set}" = set; then : + enableval=$enable_openmp; +fi + + if test "$enable_openmp" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $FC option to support OpenMP" >&5 +$as_echo_n "checking for $FC option to support OpenMP... " >&6; } +if ${ac_cv_prog_fc_openmp+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.$ac_ext <<_ACEOF + + program main + implicit none +!$ integer tid + tid = 42 + call omp_set_num_threads(2) + end + +_ACEOF +if ac_fn_fc_try_link "$LINENO"; then : + ac_cv_prog_fc_openmp='none needed' +else + ac_cv_prog_fc_openmp='unsupported' + for ac_option in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp -homp \ + -Popenmp --openmp; do + ac_save_FCFLAGS=$FCFLAGS + FCFLAGS="$FCFLAGS $ac_option" + cat > conftest.$ac_ext <<_ACEOF + + program main + implicit none +!$ integer tid + tid = 42 + call omp_set_num_threads(2) + end + +_ACEOF +if ac_fn_fc_try_link "$LINENO"; then : + ac_cv_prog_fc_openmp=$ac_option +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + FCFLAGS=$ac_save_FCFLAGS + if test "$ac_cv_prog_fc_openmp" != unsupported; then + break + fi + done +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_fc_openmp" >&5 +$as_echo "$ac_cv_prog_fc_openmp" >&6; } + case $ac_cv_prog_fc_openmp in #( + "none needed" | unsupported) + ;; #( + *) + OPENMP_FCFLAGS=$ac_cv_prog_fc_openmp ;; + esac + fi + + + pac_cv_openmp_fcopt="$OPENMP_FCFLAGS"; + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + OPENMP_CFLAGS= + # Check whether --enable-openmp was given. +if test "${enable_openmp+set}" = set; then : + enableval=$enable_openmp; +fi + + if test "$enable_openmp" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to support OpenMP" >&5 +$as_echo_n "checking for $CC option to support OpenMP... " >&6; } +if ${ac_cv_prog_c_openmp+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifndef _OPENMP + choke me +#endif +#include +int main () { return omp_get_num_threads (); } + +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_prog_c_openmp='none needed' +else + ac_cv_prog_c_openmp='unsupported' + for ac_option in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp -homp \ + -Popenmp --openmp; do + ac_save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $ac_option" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifndef _OPENMP + choke me +#endif +#include +int main () { return omp_get_num_threads (); } + +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_prog_c_openmp=$ac_option +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS=$ac_save_CFLAGS + if test "$ac_cv_prog_c_openmp" != unsupported; then + break + fi + done +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_c_openmp" >&5 +$as_echo "$ac_cv_prog_c_openmp" >&6; } + case $ac_cv_prog_c_openmp in #( + "none needed" | unsupported) + ;; #( + *) + OPENMP_CFLAGS=$ac_cv_prog_c_openmp ;; + esac + fi + + + pac_cv_openmp_ccopt="$OPENMP_CFLAGS"; + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +else + pac_cv_openmp="no"; + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no." >&5 +$as_echo "no." >&6; } +fi + + +FCOPT="$FCOPT $pac_cv_openmp_fcopt"; +CCOPT="$CCOPT $pac_cv_openmp_ccopt"; +{ $as_echo "$as_me:${as_lineno-$LINENO}: \"FLAGS: $FCOPT $OPENMP_FFLAGS\"" >&5 +$as_echo "$as_me: \"FLAGS: $FCOPT $OPENMP_FFLAGS\"" >&6;} # # Tests for support of various Fortran features; some of them are critical, # some optional diff --git a/configure.ac b/configure.ac index a2650489..27d62789 100755 --- a/configure.ac +++ b/configure.ac @@ -498,7 +498,10 @@ FDEFINES="$psblas_cv_define_prepend-DIPK${pac_cv_ipk_size} $FDEFINES"; FDEFINES="$psblas_cv_define_prepend-DLPK${pac_cv_lpk_size} $FDEFINES"; CDEFINES="-DIPK${pac_cv_ipk_size} -DLPK${pac_cv_lpk_size} $CDEFINES" - +PAC_ARG_OPENMP() +FCOPT="$FCOPT $pac_cv_openmp_fcopt"; +CCOPT="$CCOPT $pac_cv_openmp_ccopt"; +AC_MSG_NOTICE(["FLAGS: $FCOPT $OPENMP_FFLAGS"]) # # Tests for support of various Fortran features; some of them are critical, # some optional