From 301ce58193ecf7be989b6f23603f151a15a737ae Mon Sep 17 00:00:00 2001 From: BalticPinguin Date: Fri, 10 Aug 2018 09:02:10 +0200 Subject: [PATCH 1/4] Added handling of MPI version. --- m4/mpi.m4 | 66 +++++++++++++++++++++++++++++++++++++++++++++++++---- m4/petsc.m4 | 2 +- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/m4/mpi.m4 b/m4/mpi.m4 index 165818f8022..ab8ddfd3a12 100644 --- a/m4/mpi.m4 +++ b/m4/mpi.m4 @@ -4,7 +4,14 @@ dnl --------------------------------------------------------------------------- AC_DEFUN([ACX_MPI], [ dnl if MPIHOME is empty, set it to /usr -AS_IF([test "x$MPIHOME" = "x"], [MPIHOME="/usr"]) +AS_IF([test "x$MPIHOME" = "x"], [ + dnl also check $MPI_HOME; it is a common name as well. + AS_IF([test "x$MPI_HOME" = "x"], + [ + MPIHOME="/usr" + ], + [MPIHOME=$MPI_HOME]) + ]) AC_ARG_WITH([mpi], AS_HELP_STRING([--with-mpi=PATH], @@ -150,7 +157,7 @@ AS_IF([test "x$MPI_IMPL" != x], AC_LANG_CPLUSPLUS CPPFLAGS="-I$MPI_INCLUDES_PATH $CPPFLAGS" AC_CHECK_HEADER([mpi.h], - [AC_DEFINE(HAVE_MPI, 1, [Flag indicating whether or not MPI is available])], + [AC_MSG_RESULT([MPI-headers are working as expected.])], [AC_MSG_RESULT([Could not compile in the MPI headers...]); enablempi=no]) MPI_INCLUDES_PATHS="-I$MPI_INCLUDES_PATH" AC_LANG_RESTORE @@ -165,7 +172,7 @@ AS_IF([test "x$MPI_IMPL" != x], AC_LANG_CPLUSPLUS CPPFLAGS="-I$MPI_INCLUDES_PATH $CPPFLAGS" AC_CHECK_HEADER([mpi.h], - [AC_DEFINE(HAVE_MPI, 1, [Flag indicating whether or not MPI is available])], + [AC_MSG_RESULT([MPI-headers are working as expected.])], [AC_MSG_RESULT([Could not compile in the MPI headers...]); enablempi=no] ) MPI_INCLUDES_PATHS="-I$MPI_INCLUDES_PATH" AC_LANG_RESTORE @@ -184,11 +191,62 @@ AS_IF([test "x$MPI_IMPL" != x], [ MPI_IMPL="built-in" AC_MSG_RESULT( [$CXX Compiler Supports MPI] ) - AC_DEFINE(HAVE_MPI, 1, [Flag indicating whether or not MPI is available]) ], [AC_MSG_RESULT([$CXX Compiler Does NOT Support MPI...]); enablempi=no]) ]) + VERSION_MPI +]) + +AC_DEFUN([VERSION_MPI], [ + + AS_IF([test "x$enablempi" != xno], + [ + CPPFLAGS="-I$MPI_INCLUDES_PATH $CPPFLAGS" + dnl check that MPI_VERSION and MPI_SUBVERSION are defined. + AC_TRY_LINK([@%:@include ], dnl better now? + [#ifndef MPI_VERSION + #error "MPI-Version undefined." + #endif + ], + [ dnl true: Check which version it is: + dnl check that MPI_VERSION is not 1; else disable MPI + AC_TRY_LINK([@%:@include ], + [ + #if MPI_VERSION == 1 + #error "Bad MPI-version" + #endif + int np; MPI_Comm_size (MPI_COMM_WORLD, &np); + ], + [ dnl it gives true if MPI_VERSION !=1... + dnl check that MPI_VERSION is not 2; else through a warning + AC_TRY_LINK([@%:@include ], + [ + #if MPI_VERSION == 2 + #error "deprecated MPI-version" + #endif + int np; MPI_Comm_size (MPI_COMM_WORLD, &np); + ], + [ + dnl MPI_VERSION >2: Be happy and configure with MPI. + AC_MSG_RESULT([ The MPI found has version >= 3.0. ]); + ], + [ + AC_MSG_WARN([MPI-version is 2.X. This feature is deprecated. ]); + ]) + dnl set necessary variables etc: Here, all enablempi-cases are in one place. + AC_DEFINE(HAVE_MPI, 1, [Flag indicating whether or not MPI is available]) + ], + [ + AC_MSG_RESULT(["ERROR: MPI-version is 1.X. Currently we support only MPI version >= 2.0. Disable MPI now..."]); enablempi=no + mpi_major=`grep "MPI_VERSION" $MPI_INCLUDES_PATH/mpi.h` + dnl AS_ECHO([" FOO: $mpi_major"]) + ]) + ], + [ dnl MPI_VERSION is not defined. + AC_MSG_ERROR(["ERROR: MPI-version seems to be too low: MPI < 1.5. Disable MPI now..."]); enablempi=no + ]) + ]) dnl Save variables... AC_SUBST(MPI) AC_SUBST(MPI_IMPL) diff --git a/m4/petsc.m4 b/m4/petsc.m4 index 3e73f9a05b0..5fae9a0c365 100644 --- a/m4/petsc.m4 +++ b/m4/petsc.m4 @@ -397,7 +397,7 @@ AC_DEFUN([CONFIGURE_PETSC], AC_SUBST(MPI_IMPL) AS_IF([test "x$PETSC_MPI" != x], - [AC_DEFINE(HAVE_MPI, 1, [Flag indicating whether or not MPI is available])]) + [VERSION_MPI]) AS_IF([test $petsc_have_hypre -gt 0], [AC_DEFINE(HAVE_PETSC_HYPRE, 1, [Flag indicating whether or not PETSc was compiled with Hypre support])]) From d537ccc006aaad9ea3e7f93d7843676055208123 Mon Sep 17 00:00:00 2001 From: BalticPinguin Date: Tue, 11 Sep 2018 10:15:50 +0200 Subject: [PATCH 2/4] Added some search-routine for other mpi-paths. --- m4/mpi.m4 | 78 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/m4/mpi.m4 b/m4/mpi.m4 index ab8ddfd3a12..16d6bc8c853 100644 --- a/m4/mpi.m4 +++ b/m4/mpi.m4 @@ -3,26 +3,44 @@ dnl check for the required MPI library dnl --------------------------------------------------------------------------- AC_DEFUN([ACX_MPI], [ -dnl if MPIHOME is empty, set it to /usr -AS_IF([test "x$MPIHOME" = "x"], [ - dnl also check $MPI_HOME; it is a common name as well. - AS_IF([test "x$MPI_HOME" = "x"], - [ - MPIHOME="/usr" - ], - [MPIHOME=$MPI_HOME]) - ]) +dnl if MPIHOME is empty, set it to an invalid directory and try to find the correct location. +AS_IF([test "x$MPIHOME" = "x"], [MPIHOME="/.."]) AC_ARG_WITH([mpi], AS_HELP_STRING([--with-mpi=PATH], [Prefix where MPI is installed (MPIHOME)]), [MPI="$withval"], [ - AS_ECHO(["note: MPI library path not given... trying prefix=$MPIHOME"]) + AS_ECHO(["note: MPI library path not given... trying to find it myself"]) MPI=$MPIHOME ]) -AS_IF([test -z "$MPI"], [MPI="/usr"]) +AS_IF([test -z "$MPI"], [MPI="/.."]) + +dnl if MPI is not set in the config, search it via the $INCLUDE and $LIBRARY_PATH variables; +dnl with this we can hope to get a configure that is consistent with the environment. +AS_IF([test "$MPI" == "/.."], + [ + for i in $(echo $LIBRARY_PATH | tr ':' '\n') + do + AS_IF([ test -e $i/libmpi.a || test -e $MPI_LIBS_PATH/libmpi.so ], + [MPI=$(dirname $i) + break]) + done + ]) +AS_IF([test "$MPI" == "/.."], + [ + AS_ECHO(["searching LIBRARY_PATH for MPI"]) + for i in $(echo $INCLUDE | tr ':' '\n') + do + AS_IF([ test -e $i/mpi.h ], + [MPI=$(dirname $i) + break ]) + done + ]) + +dnl if we don't find it, default to standard-values and proceed as before: +AS_IF([test "$MPI" = "/.."], [MPI="/usr"]) MPI_LIBS_PATH="$MPI/lib" MPI_INCLUDES_PATH="$MPI/include" @@ -173,8 +191,7 @@ AS_IF([test "x$MPI_IMPL" != x], CPPFLAGS="-I$MPI_INCLUDES_PATH $CPPFLAGS" AC_CHECK_HEADER([mpi.h], [AC_MSG_RESULT([MPI-headers are working as expected.])], - [AC_MSG_RESULT([Could not compile in the MPI headers...]); enablempi=no] ) - MPI_INCLUDES_PATHS="-I$MPI_INCLUDES_PATH" + [AC_MSG_RESULT([Could not compile in the MPI headers...]); enablempi=no] ) MPI_INCLUDES_PATHS="-I$MPI_INCLUDES_PATH" AC_LANG_RESTORE CPPFLAGS=$tmpCPPFLAGS ], @@ -194,7 +211,16 @@ AS_IF([test "x$MPI_IMPL" != x], ], [AC_MSG_RESULT([$CXX Compiler Does NOT Support MPI...]); enablempi=no]) ]) - VERSION_MPI + dnl Save variables... + AC_SUBST(MPI) + AC_SUBST(MPI_IMPL) + AC_SUBST(MPI_LIBS) + AC_SUBST(MPI_LIBS_PATH) + AC_SUBST(MPI_LIBS_PATHS) + AC_SUBST(MPI_INCLUDES_PATH) + AC_SUBST(MPI_INCLUDES_PATHS) + + VERSION_MPI ]) @@ -202,9 +228,10 @@ AC_DEFUN([VERSION_MPI], [ AS_IF([test "x$enablempi" != xno], [ - CPPFLAGS="-I$MPI_INCLUDES_PATH $CPPFLAGS" dnl check that MPI_VERSION and MPI_SUBVERSION are defined. - AC_TRY_LINK([@%:@include ], dnl better now? + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_LINK([@%:@include ], [#ifndef MPI_VERSION #error "MPI-Version undefined." #endif @@ -216,7 +243,7 @@ AC_DEFUN([VERSION_MPI], [ #if MPI_VERSION == 1 #error "Bad MPI-version" #endif - int np; MPI_Comm_size (MPI_COMM_WORLD, &np); + int np; MPI_Comm_size (MPI_COMM_WORLD, &np) ], [ dnl it gives true if MPI_VERSION !=1... dnl check that MPI_VERSION is not 2; else through a warning @@ -225,7 +252,7 @@ AC_DEFUN([VERSION_MPI], [ #if MPI_VERSION == 2 #error "deprecated MPI-version" #endif - int np; MPI_Comm_size (MPI_COMM_WORLD, &np); + int np; MPI_Comm_size (MPI_COMM_WORLD, &np) ], [ dnl MPI_VERSION >2: Be happy and configure with MPI. @@ -238,21 +265,12 @@ AC_DEFUN([VERSION_MPI], [ AC_DEFINE(HAVE_MPI, 1, [Flag indicating whether or not MPI is available]) ], [ - AC_MSG_RESULT(["ERROR: MPI-version is 1.X. Currently we support only MPI version >= 2.0. Disable MPI now..."]); enablempi=no - mpi_major=`grep "MPI_VERSION" $MPI_INCLUDES_PATH/mpi.h` - dnl AS_ECHO([" FOO: $mpi_major"]) + AC_MSG_WARN(["ERROR: MPI-version is 1.X. Currently we support only MPI version >= 2.0. Disable MPI now..."]); enablempi=no ]) ], [ dnl MPI_VERSION is not defined. - AC_MSG_ERROR(["ERROR: MPI-version seems to be too low: MPI < 1.5. Disable MPI now..."]); enablempi=no + AC_MSG_WARN(["ERROR: MPI-version seems to be too low: MPI < 1.5. Disable MPI now..."]); enablempi=no ]) + AC_LANG_RESTORE ]) -dnl Save variables... -AC_SUBST(MPI) -AC_SUBST(MPI_IMPL) -AC_SUBST(MPI_LIBS) -AC_SUBST(MPI_LIBS_PATH) -AC_SUBST(MPI_LIBS_PATHS) -AC_SUBST(MPI_INCLUDES_PATH) -AC_SUBST(MPI_INCLUDES_PATHS) ]) From 770abc09e74d7a26525e637bc3fc925d02440604 Mon Sep 17 00:00:00 2001 From: BalticPinguin Date: Thu, 13 Sep 2018 08:04:46 +0200 Subject: [PATCH 3/4] syntax corrections and eased check for unsupported versions --- m4/mpi.m4 | 68 +++++++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/m4/mpi.m4 b/m4/mpi.m4 index 16d6bc8c853..e5a7df01e4d 100644 --- a/m4/mpi.m4 +++ b/m4/mpi.m4 @@ -19,7 +19,7 @@ AS_IF([test -z "$MPI"], [MPI="/.."]) dnl if MPI is not set in the config, search it via the $INCLUDE and $LIBRARY_PATH variables; dnl with this we can hope to get a configure that is consistent with the environment. -AS_IF([test "$MPI" == "/.."], +AS_IF([test "$MPI" = "/.."], [ for i in $(echo $LIBRARY_PATH | tr ':' '\n') do @@ -28,7 +28,7 @@ AS_IF([test "$MPI" == "/.."], break]) done ]) -AS_IF([test "$MPI" == "/.."], +AS_IF([test "$MPI" = "/.."], [ AS_ECHO(["searching LIBRARY_PATH for MPI"]) for i in $(echo $INCLUDE | tr ':' '\n') @@ -226,50 +226,44 @@ AS_IF([test "x$MPI_IMPL" != x], AC_DEFUN([VERSION_MPI], [ + AC_MSG_RESULT([Checking Version of MPI now:]) AS_IF([test "x$enablempi" != xno], [ dnl check that MPI_VERSION and MPI_SUBVERSION are defined. AC_LANG_SAVE AC_LANG_CPLUSPLUS + dnl first catch undefined and unreasonably high values. AC_TRY_LINK([@%:@include ], - [#ifndef MPI_VERSION - #error "MPI-Version undefined." - #endif + [ + @%:@ifndef MPI_VERSION + @%:@error "MPI-version seems to be < 1.5." + @%:@endif + @%:@if MPI_VERSION > 3 + @%:@error "MPI-version too high. There is some error." + @%:@endif + @%:@if MPI_VERSION < 2 + @%:@error "MPI-version 1.X is not supported." + @%:@endif ], [ dnl true: Check which version it is: - dnl check that MPI_VERSION is not 1; else disable MPI - AC_TRY_LINK([@%:@include ], - [ - #if MPI_VERSION == 1 - #error "Bad MPI-version" - #endif - int np; MPI_Comm_size (MPI_COMM_WORLD, &np) - ], - [ dnl it gives true if MPI_VERSION !=1... - dnl check that MPI_VERSION is not 2; else through a warning - AC_TRY_LINK([@%:@include ], - [ - #if MPI_VERSION == 2 - #error "deprecated MPI-version" - #endif - int np; MPI_Comm_size (MPI_COMM_WORLD, &np) - ], - [ - dnl MPI_VERSION >2: Be happy and configure with MPI. - AC_MSG_RESULT([ The MPI found has version >= 3.0. ]); - ], - [ - AC_MSG_WARN([MPI-version is 2.X. This feature is deprecated. ]); - ]) - dnl set necessary variables etc: Here, all enablempi-cases are in one place. - AC_DEFINE(HAVE_MPI, 1, [Flag indicating whether or not MPI is available]) - ], - [ - AC_MSG_WARN(["ERROR: MPI-version is 1.X. Currently we support only MPI version >= 2.0. Disable MPI now..."]); enablempi=no - ]) + dnl if MPI_VERSION is 2, through a warning + AC_TRY_LINK([@%:@include ], + [@%:@if MPI_VERSION == 2 + @%:@error "deprecated MPI-version" + @%:@endif + int np; MPI_Comm_size (MPI_COMM_WORLD, &np) + ], + [ + AC_MSG_RESULT([ The MPI found has version >= 3.0. ]); + ], + [ + AC_MSG_WARN([MPI-version is 2.X. This feature is deprecated. ]); + ]) + dnl set necessary variables etc: Here, all enablempi-cases are in one place. + AC_DEFINE(HAVE_MPI, 1, [Flag indicating whether or not MPI is available]) ], - [ dnl MPI_VERSION is not defined. - AC_MSG_WARN(["ERROR: MPI-version seems to be too low: MPI < 1.5. Disable MPI now..."]); enablempi=no + [ dnl MPI_VERSION is not defined or has unexpected value. + AC_MSG_WARN(["ERROR: MPI-version seems to be too low: Need MPI 2.X or 3.X. Disable MPI now..."]); enablempi=no ]) AC_LANG_RESTORE ]) From dac231a808b160a042691c9fb9e5320fffcdbb47 Mon Sep 17 00:00:00 2001 From: BalticPinguin Date: Wed, 26 Sep 2018 23:36:38 +0200 Subject: [PATCH 4/4] Further minor corrections to the MPI-version check --- m4/mpi.m4 | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/m4/mpi.m4 b/m4/mpi.m4 index e5a7df01e4d..d05de622c1c 100644 --- a/m4/mpi.m4 +++ b/m4/mpi.m4 @@ -17,11 +17,11 @@ AC_ARG_WITH([mpi], AS_IF([test -z "$MPI"], [MPI="/.."]) -dnl if MPI is not set in the config, search it via the $INCLUDE and $LIBRARY_PATH variables; +dnl if MPI is not set in the config, search it via the $INCLUDE and $LD_LIBRARY_PATH variables; dnl with this we can hope to get a configure that is consistent with the environment. AS_IF([test "$MPI" = "/.."], [ - for i in $(echo $LIBRARY_PATH | tr ':' '\n') + for i in $(echo $LD_LIBRARY_PATH | tr ':' '\n') do AS_IF([ test -e $i/libmpi.a || test -e $MPI_LIBS_PATH/libmpi.so ], [MPI=$(dirname $i) @@ -30,7 +30,6 @@ AS_IF([test "$MPI" = "/.."], ]) AS_IF([test "$MPI" = "/.."], [ - AS_ECHO(["searching LIBRARY_PATH for MPI"]) for i in $(echo $INCLUDE | tr ':' '\n') do AS_IF([ test -e $i/mpi.h ], @@ -232,38 +231,42 @@ AC_DEFUN([VERSION_MPI], [ dnl check that MPI_VERSION and MPI_SUBVERSION are defined. AC_LANG_SAVE AC_LANG_CPLUSPLUS - dnl first catch undefined and unreasonably high values. + dnl first catch undefined (evaluated to 0) and 1.X cases AC_TRY_LINK([@%:@include ], [ - @%:@ifndef MPI_VERSION - @%:@error "MPI-version seems to be < 1.5." - @%:@endif - @%:@if MPI_VERSION > 3 - @%:@error "MPI-version too high. There is some error." - @%:@endif @%:@if MPI_VERSION < 2 @%:@error "MPI-version 1.X is not supported." @%:@endif ], [ dnl true: Check which version it is: - dnl if MPI_VERSION is 2, through a warning AC_TRY_LINK([@%:@include ], - [@%:@if MPI_VERSION == 2 - @%:@error "deprecated MPI-version" - @%:@endif - int np; MPI_Comm_size (MPI_COMM_WORLD, &np) - ], - [ - AC_MSG_RESULT([ The MPI found has version >= 3.0. ]); - ], - [ - AC_MSG_WARN([MPI-version is 2.X. This feature is deprecated. ]); - ]) - dnl set necessary variables etc: Here, all enablempi-cases are in one place. - AC_DEFINE(HAVE_MPI, 1, [Flag indicating whether or not MPI is available]) + [ @%:@if MPI_VERSION > 4 + @%:@error "MPI-version too high. There is some error." + @%:@endif + ], + [ + dnl if MPI_VERSION is 2, through a warning + AC_TRY_LINK([@%:@include ], + [@%:@if MPI_VERSION == 2 + @%:@error "deprecated MPI-version" + @%:@endif + int np; MPI_Comm_size (MPI_COMM_WORLD, &np) + ], + [ + AC_MSG_RESULT([ MPI was found with version >= 3.0. ]); + ], + [ + AC_MSG_WARN([MPI-version is 2.X. This feature is deprecated. ]); + ]) + dnl set necessary variables etc: Here, all enablempi-cases are in one place. + AC_DEFINE(HAVE_MPI, 1, [Flag indicating whether or not MPI is available]) + ], + [ + AC_MSG_WARN(["ERROR: MPI-version seems to be unreasonably high. Please check your library. Disable MPI now..."]); enablempi=no + ]) ], [ dnl MPI_VERSION is not defined or has unexpected value. - AC_MSG_WARN(["ERROR: MPI-version seems to be too low: Need MPI 2.X or 3.X. Disable MPI now..."]); enablempi=no + AC_MSG_WARN(["ERROR: MPI-version seems to be too low: Need MPI 2.X or compatible. Disable MPI now..."]); enablempi=no ]) AC_LANG_RESTORE ])