Commit ba9a188f authored by Lorenz Huedepohl's avatar Lorenz Huedepohl

Handle different OpenMP flags for Fortran and C

There was an inconsistency when the OpenMP flag was different for the
Fortran and C compiler (e.g. -openmp for ifort and -fopenmp for gcc).

This led to strange errors when linking the example program with the C
main() routine when using Intel Fortran, Intel MPI, and GCC together, a
typical error message was

  /usr/bin/ld: MPIR_Thread: TLS definition in [...]/intel64/lib/libmpi_dbg_mt.so section .tbss mismatches non-TLS definition in [...]/intel64/lib/libmpi_dbg.so section .bss
  [...]/intel64/lib/libmpi_dbg_mt.so: could not read symbols: Bad value

The reason seems to be that the various MPI wrapper shell scripts
(mpicc, mpiifort) need the correct OpenMP option to select the
thread-safe Intel MPI debug library. Previously, always OPENMP_FCFLAGS
was appended to LDFLAGS, which did not trigger this when linking a C
main program with mpicc.
parent 25004574
......@@ -52,6 +52,20 @@ fi
m4_include([fdep/fortran_dependencies.m4])
FDEP_F90_GNU_MAKE_DEPS
###
AC_MSG_CHECKING(whether --enable-openmp is specified)
AC_ARG_ENABLE([openmp],
AS_HELP_STRING([--with-openmp],
[use OpenMP threading, default no.]),
[],
[enable_openmp=no])
AC_MSG_RESULT([${enable_openmp}])
AM_CONDITIONAL([WITH_OPENMP],[test x"$enable_openmp" = x"yes"])
if test x"${enable_openmp}" = x"yes"; then
AC_DEFINE([WITH_OPENMP], [1], [use OpenMP threading])
fi
dnl check whether mpi compilers are available;
dnl if not abort since it is mandatory
......@@ -59,12 +73,15 @@ dnl if not abort since it is mandatory
AC_LANG([C])
m4_include([m4/ax_prog_cc_mpi.m4])
AX_PROG_CC_MPI([true],[],[AC_MSG_ERROR([no MPI C wrapper found])])
AC_PROG_INSTALL
: ${CFLAGS=""}
: ${CXXFLAGS=""}
#: ${FCLAGS="-O2"}
if test x"${enable_openmp}" = x"yes"; then
AX_ELPA_OPENMP
if test "$ac_cv_prog_cc_openmp" = unsupported; then
AC_MSG_ERROR([Could not compile a C program with OpenMP, adjust CFLAGS])
fi
CFLAGS="$OPENMP_CFLAGS $CFLAGS"
fi
AC_PROG_INSTALL
AM_PROG_AR
AM_PROG_AS
......@@ -74,11 +91,27 @@ AC_LANG([Fortran])
m4_include([m4/ax_prog_fc_mpi.m4])
AX_PROG_FC_MPI([],[],[AC_MSG_ERROR([no MPI Fortran wrapper found])])
if test x"${enable_openmp}" = x"yes"; then
AX_ELPA_OPENMP
if test "$ac_cv_prog_fc_openmp" = unsupported; then
AC_MSG_ERROR([Could not compile a Fortran program with OpenMP, adjust FCFLAGS])
fi
FCFLAGS="$OPENMP_FCFLAGS $FCFLAGS"
fi
# C++
AC_LANG([C++])
AC_PROG_CXX
if test x"${enable_openmp}" = x"yes"; then
AX_ELPA_OPENMP
if test "$ac_cv_prog_cxx_openmp" = unsupported; then
AC_MSG_ERROR([Could not compile a C++ program with OpenMP, adjust CXXFLAGS])
fi
CXXFLAGS="$OPENMP_CXXFLAGS $CXXFLAGS"
fi
......@@ -248,33 +281,6 @@ AC_FC_MODULE_FLAG
AC_FC_MODULE_OUTPUT_FLAG
AC_FC_LIBRARY_LDFLAGS
AC_MSG_CHECKING(whether OpenMP usage is specified)
AC_ARG_WITH([openmp],
AS_HELP_STRING([--with-openmp],
[use OpenMP threading, default no.]),
[with_openmp=yes],
[with_openmp=no])
AC_MSG_RESULT([${with_openmp}])
if test x"${enable_openmp}" = x"yes"; then
with_openmp=yes
AC_MSG_CHECKING(whether --enable-openmp is specified)
AC_MSG_RESULT([${enable_openmp}])
fi
AM_CONDITIONAL([WITH_OPENMP],[test x"$with_openmp" = x"yes"])
if test x"${with_openmp}" = x"yes"; then
AC_DEFINE([WITH_OPENMP], [1], [use OpenMP threading])
AX_ELPA_OPENMP
if test "$ac_cv_prog_fc_openmp" = unsupported; then
AC_MSG_ERROR([Could not compile a program with OpenMP, adjust FCFLAGS])
fi
# Append to flags as this influences which
# kind of MPI library has to be used (thread-safe or not)
FCFLAGS="$OPENMP_FCFLAGS $FCFLAGS"
LDFLAGS="$OPENMP_FCFLAGS $LDFLAGS"
fi
save_FCFLAGS=$FCFLAGS
save_LDFLAGS=$LDFLAGS
......@@ -764,7 +770,7 @@ mkdir modules
# into "postdeps_FC" and causes linking errors later on.
postdeps_FC=$(echo $postdeps_FC | sed 's/-l //g')
if test x"${with_openmp}" = x"yes"; then
if test x"${enable_openmp}" = x"yes"; then
SUFFIX="_openmp"
else
SUFFIX=""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment