Commit 9e01bb2d authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Improve detection of MPI capability and optional feature configuration

parent d9cf8827
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
AUTOMAKE_OPTIONS=subdir-objects
LDADD=libnptm/libnptm.la -L/usr/lib64 ${USER_LDFLAGS} ${HDF5_LDFLAGS} ${LAPACKLDFLAGS} ${MAGMALDFLAGS}
lib_LTLIBRARIES=libnptm/libnptm.la
libnptm_libnptm_la_SOURCES=../src/libnptm/algebraic.cpp ../src/libnptm/clu_subs.cpp ../src/libnptm/Commons.cpp ../src/libnptm/Configuration.cpp ../src/libnptm/file_io.cpp ../src/libnptm/lapack_calls.cpp ../src/libnptm/logging.cpp ../src/libnptm/magma_calls.cpp ../src/libnptm/Parsers.cpp ../src/libnptm/sph_subs.cpp ../src/libnptm/tfrfme.cpp ../src/libnptm/TransitionMatrix.cpp ../src/libnptm/tra_subs.cpp ../src/libnptm/types.cpp
+0 −1
Original line number Diff line number Diff line
@@ -519,7 +519,6 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = subdir-objects
LDADD = libnptm/libnptm.la -L/usr/lib64 ${USER_LDFLAGS} ${HDF5_LDFLAGS} ${LAPACKLDFLAGS} ${MAGMALDFLAGS}
lib_LTLIBRARIES = libnptm/libnptm.la
libnptm_libnptm_la_SOURCES = ../src/libnptm/algebraic.cpp ../src/libnptm/clu_subs.cpp ../src/libnptm/Commons.cpp ../src/libnptm/Configuration.cpp ../src/libnptm/file_io.cpp ../src/libnptm/lapack_calls.cpp ../src/libnptm/logging.cpp ../src/libnptm/magma_calls.cpp ../src/libnptm/Parsers.cpp ../src/libnptm/sph_subs.cpp ../src/libnptm/tfrfme.cpp ../src/libnptm/TransitionMatrix.cpp ../src/libnptm/tra_subs.cpp ../src/libnptm/types.cpp
+2 −2
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@

PROGRAM=libtool
PACKAGE=libtool
VERSION="2.4.7 Debian-2.4.7-7"
VERSION="2.4.7 Debian-2.4.7-7build1"
package_revision=2.4.7


@@ -2296,7 +2296,7 @@ include the following information:
       compiler:       $LTCC
       compiler flags: $LTCFLAGS
       linker:         $LD (gnu? $with_gnu_ld)
       version:        $progname $scriptversion Debian-2.4.7-7
       version:        $progname $scriptversion Debian-2.4.7-7build1
       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`

+761 −108

File changed.

Preview size limit exceeded, changes collapsed.

+80 −31
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ m4_define(
    export -p | grep MKL
    MKL_DEF=$?
    if test "x$MKL_DEF" = "x0"; then
      export LAPACKFLAGS="-DUSE_LAPACK -DLAPACK_ILP64 -DUSE_ILP64 -I{MKLROOT}/include"
      export LAPACKFLAGS="-DUSE_LAPACK -DUSE_MKL -DLAPACK_ILP64 -DUSE_ILP64 -I{MKLROOT}/include"
      export LAPACKLDFLAGS="-L${MKLROOT}/lib -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
    else
      if test -f /usr/include/lapacke.h; then
@@ -71,6 +71,28 @@ m4_define(
    fi
  ]
)

m4_define(
  [M4_TEST_MPI],
  [
    cat > np_test_mpi.cpp <<EOF
#ifndef MPI_VERSION
#include <mpi.h>
#endif
int main(int argc, char** argv) {
  int ierr = MPI_Init(&argc, &argv);
  MPI_Finalize();
  return ierr;
}
EOF
    $CXX -c np_test_mpi.cpp > /dev/null 2>&1
    export CXX_IS_MPI=$?
    rm np_test_mpi.cpp
    if test "x$CXX_IS_MPI" = "x0"; then
      rm np_test_mpi.o
    fi
  ]
)
# END CAPABILITY TESTING MACROS

# autoconf setup initialization
@@ -78,12 +100,13 @@ AC_INIT([np_tmcode], [8.04], [giovanni.lamura@inaf.it])

# Folder structure safety check
AC_CONFIG_SRCDIR([../src/libnptm/TransitionMatrix.cpp])
AC_CONFIG_FILES([Makefile])

# Auxiliary build folder
AC_CONFIG_AUX_DIR([build_aux])

# automake initialization
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])

# Compiler detection
AM_PROG_AR
@@ -100,25 +123,38 @@ AC_ARG_ENABLE(
      AC_MSG_NOTICE([Using $CXX])
      AC_SUBST([MPIFLAGS], [""])
    elif test "x$enableval" = "xauto"; then
      AC_PROG_CXX([mpicxx mpic++ mpiCC])
      if test "x$CXX" = "x"; then
        AC_PROG_CXX([mpicxx.openmpi mpicxx.mpich mpic++.openmpi mpiCC.openmpi])
        if test "x$CXX" != "x"; then
          AC_SUBST([MPIFLAGS], [-DUSE_MPI])
        else
          AC_PROG_CXX([g++ clang++])
          AC_SUBST([MPIFLAGS], [""])
        fi
      else
        # Test if given CXX defines mpi.h
	M4_TEST_MPI
      fi
    elif test "x$enableval" = "xyes"; then
      AC_PROG_CXX([mpicxx mpic++ mpiCC])
      if test "x$CXX" = "x"; then
        AC_PROG_CXX([mpicxx.openmpi mpicxx.mpich mpic++.openmpi mpiCC.openmpi])
        if test "x$CXX" != "x"; then
          AC_SUBST([MPIFLAGS], [-DUSE_MPI])
        else
          AC_MSG_ERROR([MPI was requested, but no MPI compiler detected!])
        fi
      else
        # Test if given CXX defines mpi.h
	M4_TEST_MPI
	if test "x$CXX_IS_MPI" != "x0"; then
          AC_MSG_ERROR([MPI was requested, but $CXX is not a MPI compiler!])
	fi
      fi
    fi
  ],
  [
    if test "x$CXX" = "x"; then
      AC_PROG_CXX([mpicxx mpic++ mpiCC])
      AC_PROG_CXX([mpicxx.openmpi mpicxx.mpich mpic++.openmpi mpiCC.openmpi])
      if test "x$CXX" != "x"; then
        AC_SUBST([MPIFLAGS], [-DUSE_MPI])
      else
@@ -128,9 +164,15 @@ AC_ARG_ENABLE(
      fi
    else
      AC_PROG_CXX([$CXX])
      M4_TEST_MPI
      if test "x$CXX_IS_MPI" = "x0"; then
        AC_SUBST([MPIFLAGS], [-DUSE_MPI])
        AC_SUBST([MPIFLAGS], [""])
      fi
    fi
  ]
)
AC_PROG_CXX([$CXX])
AC_PROG_F77([gfortran f77])
# Check whether the compiler is clang++ (needs additional flags)
CXX_IS_CLANG=$($CXX --version | grep clang)
@@ -171,20 +213,6 @@ AS_IF(
)

# Configure the optional features
M4_DETECT_LAPACK
AS_IF(
  [test "x$LAPACKLDFLAGS" != "x"],
  [AC_MSG_NOTICE([LAPACK detected. Activating by default (use --without-lapack to disable).])],
  [AC_MSG_NOTICE([No LAPACK found.])]
)

M4_DETECT_MAGMA
AS_IF(
  [test "x$MAGMALDFLAGS" != "x"],
  [AC_MSG_NOTICE([MAGMA detected. Activating by default (use --without-magma to disable).])],
  [AC_MSG_NOTICE([MAGMA not found.])]
)

AC_ARG_ENABLE(
  [openmp],
  [AS_HELP_STRING([--enable-openmp], [enable OpneMP multi-threading [default=yes]])],
@@ -200,17 +228,29 @@ AC_ARG_ENABLE(

AC_ARG_WITH(
  [lapack],
  [AS_HELP_STRING([--with-lapack], [use LAPACK @<:@default=check@:>@])],
  [AS_HELP_STRING([--with-lapack], [use LAPACK @<:@default=auto@:>@])],
  [
    if test "x$withval" = "xno"; then
      AC_SUBST([LAPACKFLAGS], [""])
      AC_SUBST([LAPACKLDFLAGS], [""])
    else
      M4_DETECT_LAPACK
      AS_IF(
        [test "x$LAPACKLDFLAGS" != "x"],
        [AC_MSG_NOTICE([LAPACK detected.])],
        [AC_MSG_NOTICE([No LAPACK found.])]
      )
      AC_SUBST([LAPACKFLAGS], [${LAPACKFLAGS}])
      AC_SUBST([LAPACKLDFLAGS], [${LAPACKLDFLAGS}])
    fi
  ],
  [
    M4_DETECT_LAPACK
    AS_IF(
      [test "x$LAPACKLDFLAGS" != "x"],
      [AC_MSG_NOTICE([LAPACK detected. Activating by default (use --without-lapack to disble).])],
      [AC_MSG_NOTICE([No LAPACK found.])]
    )
    AC_SUBST([LAPACKFLAGS], [${LAPACKFLAGS}])
    AC_SUBST([LAPACKLDFLAGS], [${LAPACKLDFLAGS}])
  ]
@@ -218,17 +258,29 @@ AC_ARG_WITH(

AC_ARG_WITH(
  [magma],
  [AS_HELP_STRING([--with-magma], [use MAGMA @<:@default=check@:>@])],
  [AS_HELP_STRING([--with-magma], [use MAGMA @<:@default=auto@:>@])],
  [
    if test "x$withval" = "xno"; then
      AC_SUBST([MAGMAFLAGS], [""])
      AC_SUBST([MAGMALDFLAGS], [""])
    else
      M4_DETECT_MAGMA
      AS_IF(
        [test "x$MAGMALDFLAGS" != "x"],
        [AC_MSG_NOTICE([MAGMA detected.])],
        [AC_MSG_NOTICE([MAGMA not found.])]
      )
      AC_SUBST([MAGMAFLAGS], [${MAGMAFLAGS}])
      AC_SUBST([MAGMALDFLAGS], [${MAGMALDFLAGS}])
    fi
  ],
  [
    M4_DETECT_MAGMA
    AS_IF(
      [test "x$MAGMALDFLAGS" != "x"],
      [AC_MSG_NOTICE([MAGMA detected. Activating by default (use --without-magma to disable).])],
      [AC_MSG_NOTICE([MAGMA not found.])]
    )
    AC_SUBST([MAGMAFLAGS], [${MAGMAFLAGS}])
    AC_SUBST([MAGMALDFLAGS], [${MAGMALDFLAGS}])
  ]
@@ -291,8 +343,5 @@ AC_ARG_WITH(
CXXFLAGS="$CLANGFLAGS -O3 -ggdb $USER_INCLUDE -I$HDF5_INCLUDE $OMPFLAGS $MPIFLAGS $LAPACKFLAGS $MAGMAFLAGS $NVTXFLAGS"
SUBDIRS="cluster libnptm sphere testing trapping"

# Send output to Makefiles
AC_CONFIG_FILES([Makefile])

# Generate the output
AC_OUTPUT