From: maier Date: Thu, 15 May 2014 18:18:46 +0000 (+0000) Subject: CMake: Check for MPI compatibility X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf76bcb09dc01e3d966e1e6a88a62f74df5ff5c5;p=dealii-svn.git CMake: Check for MPI compatibility git-svn-id: https://svn.dealii.org/trunk@32909 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/cmake/configure/configure_1_mpi.cmake b/deal.II/cmake/configure/configure_1_mpi.cmake index a73e27d962..1fd25d1bf0 100644 --- a/deal.II/cmake/configure/configure_1_mpi.cmake +++ b/deal.II/cmake/configure/configure_1_mpi.cmake @@ -143,7 +143,9 @@ MACRO(FEATURE_MPI_FIND_EXTERNAL var) # # Populate correct variables: # - SET(MPI_LIBRARIES ${MPI_CXX_LIBRARIES}) + SET(MPI_LIBRARIES + ${MPI_CXX_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${MPI_C_LIBRARIES} + ) SET(MPI_INCLUDE_DIRS ${MPI_CXX_INCLUDE_PATH}) SET(MPI_CXX_FLAGS ${MPI_CXX_COMPILE_FLAGS}) SET(MPI_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}") diff --git a/deal.II/cmake/configure/configure_2_metis.cmake b/deal.II/cmake/configure/configure_2_metis.cmake index 34a47ca1d8..72a142286d 100644 --- a/deal.II/cmake/configure/configure_2_metis.cmake +++ b/deal.II/cmake/configure/configure_2_metis.cmake @@ -14,6 +14,13 @@ ## ## --------------------------------------------------------------------- +IF(NOT FEATURE_MPI_PROCESSED) + MESSAGE(FATAL_ERROR "\n" + "Internal build system error:\n" + "configure_2_metis.cmake included before configure_1_mpi.cmake\n\n" + ) +ENDIF() + # # Configuration for the metis library: # @@ -21,16 +28,21 @@ MACRO(FEATURE_METIS_FIND_EXTERNAL var) FIND_PACKAGE(METIS) - IF(METIS_FOUND AND METIS_VERSION_MAJOR GREATER 4) + IF(METIS_FOUND) SET(${var} TRUE) - ELSE() - MESSAGE(STATUS "Insufficient metis installation found: " - "Version 5.x required!" - ) - SET(METIS_ADDITIONAL_ERROR_STRING - "Could not find a sufficient modern metis installation: " - "Version 5.x required!\n" - ) + + IF(NOT METIS_VERSION_MAJOR GREATER 4) + MESSAGE(STATUS "Insufficient metis installation found: " + "Version 5.x required!" + ) + SET(METIS_ADDITIONAL_ERROR_STRING + "Could not find a sufficient modern metis installation: " + "Version 5.x required!\n" + ) + SET(${var} FALSE) + ENDIF() + + CHECK_MPI_INTERFACE(METIS ${var}) ENDIF() ENDMACRO() diff --git a/deal.II/cmake/configure/configure_2_trilinos.cmake b/deal.II/cmake/configure/configure_2_trilinos.cmake index 2977f38846..7b680a4f5e 100644 --- a/deal.II/cmake/configure/configure_2_trilinos.cmake +++ b/deal.II/cmake/configure/configure_2_trilinos.cmake @@ -179,6 +179,8 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var) SET(${var} FALSE) ENDIF() ENDIF() + + CHECK_MPI_INTERFACE(TRILINOS ${var}) ENDIF() ENDMACRO() diff --git a/deal.II/cmake/configure/configure_3_petsc.cmake b/deal.II/cmake/configure/configure_3_petsc.cmake index 60d0f8e10b..ee95cd5a4a 100644 --- a/deal.II/cmake/configure/configure_3_petsc.cmake +++ b/deal.II/cmake/configure/configure_3_petsc.cmake @@ -93,6 +93,8 @@ MACRO(FEATURE_PETSC_FIND_EXTERNAL var) ) SET(${var} FALSE) ENDIF() + + CHECK_MPI_INTERFACE(PETSC ${var}) ENDIF() ENDMACRO() diff --git a/deal.II/cmake/configure/configure_hdf5.cmake b/deal.II/cmake/configure/configure_hdf5.cmake index c86c9612f0..abc66f4c04 100644 --- a/deal.II/cmake/configure/configure_hdf5.cmake +++ b/deal.II/cmake/configure/configure_hdf5.cmake @@ -14,6 +14,13 @@ ## ## --------------------------------------------------------------------- +IF(NOT FEATURE_MPI_PROCESSED) + MESSAGE(FATAL_ERROR "\n" + "Internal build system error:\n" + "configure_hdf5.cmake included before configure_1_mpi.cmake\n\n" + ) +ENDIF() + # # Configuration for the hdf5 library: # @@ -22,12 +29,10 @@ MACRO(FEATURE_HDF5_FIND_EXTERNAL var) FIND_PACKAGE(HDF5) IF(HDF5_FOUND) - IF( (HDF5_WITH_MPI AND DEAL_II_WITH_MPI) OR - (NOT HDF5_WITH_MPI AND NOT DEAL_II_WITH_MPI) ) - SET(${var} TRUE) - - ELSE() + SET(${var} TRUE) + IF( (HDF5_WITH_MPI AND NOT DEAL_II_WITH_MPI) OR + (NOT HDF5_WITH_MPI AND DEAL_II_WITH_MPI) ) MESSAGE(STATUS "Insufficient hdf5 installation found: " "hdf5 has to be configured with the same MPI configuration as deal.II." ) @@ -37,7 +42,10 @@ MACRO(FEATURE_HDF5_FIND_EXTERNAL var) " DEAL_II_WITH_MPI = ${DEAL_II_WITH_MPI}\n" " HDF5_WITH_MPI = ${HDF5_WITH_MPI}\n" ) + SET(${var} FALSE) ENDIF() + + CHECK_MPI_INTERFACE(HDF5 ${var}) ENDIF() ENDMACRO() diff --git a/deal.II/cmake/configure/configure_mumps.cmake b/deal.II/cmake/configure/configure_mumps.cmake index 78b4bb0b00..cfe08a2cdd 100644 --- a/deal.II/cmake/configure/configure_mumps.cmake +++ b/deal.II/cmake/configure/configure_mumps.cmake @@ -20,4 +20,14 @@ SET(FEATURE_MUMPS_DEPENDS DEAL_II_WITH_MPI DEAL_II_WITH_LAPACK) + +MACRO(FEATURE_MUMPS_FIND_EXTERNAL var) + FIND_PACKAGE(MUMPS) + + IF(MUMPS_FOUND) + SET(${var} TRUE) + CHECK_MPI_INTERFACE(MUMPS ${var}) + ENDIF() +ENDMACRO() + CONFIGURE_FEATURE(MUMPS) diff --git a/deal.II/cmake/configure/configure_p4est.cmake b/deal.II/cmake/configure/configure_p4est.cmake index 967b10b565..313b8359ef 100644 --- a/deal.II/cmake/configure/configure_p4est.cmake +++ b/deal.II/cmake/configure/configure_p4est.cmake @@ -54,6 +54,8 @@ MACRO(FEATURE_P4EST_FIND_EXTERNAL var) ) SET(${var} FALSE) ENDIF() + + CHECK_MPI_INTERFACE(P4EST ${var}) ENDIF() ENDMACRO() diff --git a/deal.II/cmake/macros/macro_check_mpi_interface.cmake b/deal.II/cmake/macros/macro_check_mpi_interface.cmake new file mode 100644 index 0000000000..0011282f69 --- /dev/null +++ b/deal.II/cmake/macros/macro_check_mpi_interface.cmake @@ -0,0 +1,59 @@ +## --------------------------------------------------------------------- +## $Id$ +## +## Copyright (C) 2014 by the deal.II authors +## +## This file is part of the deal.II library. +## +## The deal.II library is free software; you can use it, redistribute +## it, and/or modify it under the terms of the GNU Lesser General +## Public License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## The full text of the license can be found in the file LICENSE at +## the top level of the deal.II distribution. +## +## --------------------------------------------------------------------- + +# +# Check whether a feature is compiled against the same MPI library as the +# one deal.II picked up +# +# Usage: +# CHECK_MPI_INTERFACE(_feature _var), +# + +MACRO(CHECK_MPI_INTERFACE _feature _var) + IF(DEAL_II_WITH_MPI) + SET(_nope FALSE) + + FOREACH(_library ${${_feature}_LIBRARIES}) + IF(_library MATCHES "/libmpi[^/]*\\.so") + LIST(FIND MPI_LIBRARIES "${_library}" _position) + IF("${_position}" STREQUAL "-1") + SET(_nope TRUE) + SET(_mpi_library ${_library}) + BREAK() + ENDIF() + ENDIF() + ENDFOREACH() + + IF(_nope) + MESSAGE(STATUS "Could not find a sufficient ${_feature} installation: " + "${_feature} is compiled against a different MPI library than the one " + "deal.II picked up." + ) + TO_STRING(_str ${MPI_LIBRARIES}) + SET(PETSC_ADDITIONAL_ERROR_STRING + ${PETSC_ADDITIONAL_ERROR_STRING} + "Could not find a sufficient ${_feature} installation:\n" + "${_feature} has to be compiled against the same MPI library as deal.II " + "but the link line of ${_feature} contains:\n" + " ${_mpi_library}\n" + "which is not listed in MPI_LIBRARIES:\n" + " MPI_LIBRARIES = \"${_str}\"\n" + ) + SET(${_var} FALSE) + ENDIF() + ENDIF() +ENDMACRO() + diff --git a/deal.II/cmake/modules/FindPETSC.cmake b/deal.II/cmake/modules/FindPETSC.cmake index 7151fb657f..4cc4aef519 100644 --- a/deal.II/cmake/modules/FindPETSC.cmake +++ b/deal.II/cmake/modules/FindPETSC.cmake @@ -176,11 +176,6 @@ IF(NOT PETSC_PETSCVARIABLES MATCHES "-NOTFOUND") REGEX "^PETSC_WITH_EXTERNAL_LIB =.*") SEPARATE_ARGUMENTS(PETSC_EXTERNAL_LINK_LINE) - IF(NOT "${PETSC_EXTERNAL_LINK_LINE}" STREQUAL "${PETSC_EXTERNAL_LINK_LINE_SAVED}") - SET(_new_petsc_external_link_line TRUE) - ENDIF() - SET(PETSC_EXTERNAL_LINK_LINE_SAVED "${PETSC_EXTERNAL_LINK_LINE}" CACHE INTERNAL "" FORCE) - SET(_hints) SET(_petsc_libraries) SET(_cleanup_variables) @@ -193,11 +188,7 @@ IF(NOT PETSC_PETSCVARIABLES MATCHES "-NOTFOUND") # Search for every library that was specified with -l: STRING(REGEX REPLACE "^-l" "" _token "${_token}") - # TODO: LIST(APPEND _cleanup_variables PETSC_LIBRARY_${_token}) - IF(_new_petsc_external_link_line) - UNSET(PETSC_LIBRARY_${_token} CACHE) - ENDIF() IF(_token MATCHES "^(c|quadmath|gfortran|m|rt|nsl|dl|pthread)$") FIND_SYSTEM_LIBRARY(PETSC_LIBRARY_${_token} NAMES ${_token})