Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 44 additions & 18 deletions CMakeModules/FindMPI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ macro(clearFindMPIVariables)
unset(MPIEXEC_PREFLAGS CACHE)
unset(MPIEXEC_POSTFLAGS CACHE)
unset(MPIEXEC_MAX_NUMPROCS CACHE)
unset(MPI_LIBRARY CACHE)
unset(MPI_EXTRA_LIBRARY CACHE)
endmacro()

# include this to handle the QUIETLY and REQUIRED arguments
Expand Down Expand Up @@ -233,7 +235,7 @@ set(_MPI_EXEC_NAMES mpiexec mpirun lamexec srun)
# For 64bit environments, look in bin64 folders first!
set(_BIN_SUFFIX bin sbin)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "64")
LIST(INSERT _BIN_SUFFIX 0 bin64 sbin64)
list(INSERT _BIN_SUFFIX 0 bin64 sbin64)
endif()
if (WIN32)
if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
Expand Down Expand Up @@ -262,40 +264,42 @@ else()
set(_MPI_PREFIX_PATH )
messagev("Trying to find ${MPI}-MPI implementation")
if (MPI STREQUAL mpich)
#LIST(APPEND _MPI_PREFIX_PATH /usr/lib/mpich /usr/lib64/mpich /usr/local/lib/mpich /usr/local/lib64/mpich)
LIST(APPEND _MPI_PREFIX_PATH mpich)
#list(APPEND _MPI_PREFIX_PATH /usr/lib/mpich /usr/lib64/mpich /usr/local/lib/mpich /usr/local/lib64/mpich)
list(APPEND _MPI_PREFIX_PATH mpich)
if(WIN32)
LIST(APPEND _MPI_PREFIX_PATH "${PROGRAM_FILES_PATH}/MPICH" "${PROGRAM_FILES_PATH}/mpich")
list(APPEND _MPI_PREFIX_PATH "${PROGRAM_FILES_PATH}/MPICH" "${PROGRAM_FILES_PATH}/mpich")
endif()
elseif(MPI STREQUAL mpich2)
#LIST(APPEND _MPI_PREFIX_PATH /usr/lib/mpich2 /usr/lib64/mpich2 /usr/local/lib/mpich2 /usr/local/lib64/mpich2)
LIST(APPEND _MPI_PREFIX_PATH mpich2)
#list(APPEND _MPI_PREFIX_PATH /usr/lib/mpich2 /usr/lib64/mpich2 /usr/local/lib/mpich2 /usr/local/lib64/mpich2)
list(APPEND _MPI_PREFIX_PATH mpich2)
if(WIN32)
LIST(APPEND _MPI_PREFIX_PATH "${PROGRAM_FILES_PATH}/MPICH2" "${PROGRAM_FILES_PATH}/mpich2"
list(APPEND _MPI_PREFIX_PATH "${PROGRAM_FILES_PATH}/MPICH2" "${PROGRAM_FILES_PATH}/mpich2"
"C:/MPICH2" "C:/mpich2"
"${PROGRAM_FILES_PATH}/MPICH2" "${PROGRAM_FILES_PATH}/mpich2"
"D:/MPICH2" "D:/mpich2")
endif()
elseif(MPI STREQUAL intel)
LIST(APPEND _MPI_PREFIX_PATH /opt/intel/impi_latest /opt/intel/compilers_and_libraries/linux/mpi)
list(APPEND _MPI_PREFIX_PATH /opt/intel/impi_latest /opt/intel/compilers_and_libraries/linux/mpi)
elseif(MPI STREQUAL openmpi)
#LIST(APPEND _MPI_PREFIX_PATH /usr/lib64/compat-openmpi /usr/lib/compat-openmpi
#list(APPEND _MPI_PREFIX_PATH /usr/lib64/compat-openmpi /usr/lib/compat-openmpi
# /usr/lib64/openmpi /usr/lib/openmpi
# /usr/local/openmpi /usr/local/lib/openmpi)
LIST(APPEND _MPI_PREFIX_PATH compat-openmpi openmpi)
list(APPEND _MPI_PREFIX_PATH compat-openmpi openmpi)
elseif(MPI STREQUAL msmpi)
list(APPEND _MPI_PREFIX_PATH "${PROGRAM_FILES_PATH}/Microsoft SDKs/MPI")
elseif (MPI STREQUAL mpistub)
list(APPEND _MPI_PREFIX_PATH mpistub)
elseif(MPI STREQUAL mvapich2)
LIST(APPEND _MPI_PREFIX_PATH mvapich2 mvapich)
list(APPEND _MPI_PREFIX_PATH mvapich2 mvapich)
elseif(MPI STREQUAL poe)
LIST(APPEND _MPI_PREFIX_PATH /usr/lpp/ppe.poe)
list(APPEND _MPI_PREFIX_PATH /usr/lpp/ppe.poe)
elseif(MPI STREQUAL cray)
LIST(APPEND _MPI_PREFIX_PATH /opt/cray/mpt/4.1.1/xt/seastar/mpich2-gnu)
list(APPEND _MPI_PREFIX_PATH /opt/cray/mpt/4.1.1/xt/seastar/mpich2-gnu)
elseif(MPI STREQUAL MPI_TYPE_UNKNOWN)
message(WARNING "MPI implementation unknown. Compilation process has not been tested/verified yet")
else()
message(FATAL_ERROR "Unknown MPI value '${MPI}'. Your options:
1. Use one of 'mpich','mpich2','openmpi','intel','mvapich2' or 'msmpi'
1. Use one of 'mpich','mpich2','openmpi','intel','mvapich2', 'mpistub' or 'msmpi'
2. Do not define the MPI variable and let CMake find the system default")
endif()
else()
Expand Down Expand Up @@ -367,7 +371,10 @@ set(_MNEMONICS
openmpi
intel
mvapich2
msmpi)
msmpi
mpistub
)
list(LENGTH _MNEMONICS _MNEMONICS_COUNT)
# If the detection fails, this value is returned.
set(MPI_TYPE_UNKNOWN unknown)
# Patterns to match the include and library paths - must be in same order as _MNEMONICS
Expand All @@ -378,6 +385,7 @@ set(_PATTERNS
".*(intel|impi)[/|-].*"
".*mvapich(2)?([/|-].*|$)"
".*microsoft(.*|$)"
".*mpistub(.*|$)"
)

############################################################
Expand Down Expand Up @@ -510,7 +518,6 @@ function (interrogate_mpi_compiler lang try_libs)
set(MSMPI_ARCH_DIR x86)
set(MSMPI_ARCH_DIR2 i386)
endif()

# If MPI is set already in the cache, don't bother with interrogating the compiler.
messagev("interrogate: ${interrogate}, inc path:${MPI_${lang}_INCLUDE_PATH}")
messagev("libs: ${MPI_${lang}_LIBRARIES}")
Expand Down Expand Up @@ -913,7 +920,10 @@ function(unset_mpi lang)
set(MPI_${lang}_LIBRARIES "MPI_${lang}_LIBRARIES-NOTFOUND" CACHE STRING "Cleared" FORCE)
set(MPI_${lang}_COMPILER "MPI_${lang}_COMPILER-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
set(MPI_${lang}_LINK_FLAGS "" CACHE STRING "Cleared" FORCE)
set(MPI_EXTRA_LIBRARY "" CACHE STRING "Extra MPI libraries to link against" FORCE)
if (lang IN_LIST "C;CXX")
set(MPI_LIBRARY "" CACHE STRING "MPI library to link against" FORCE)
set(MPI_EXTRA_LIBRARY "" CACHE STRING "Extra MPI libraries to link against" FORCE)
endif ()
unset(MPIEXEC CACHE)
unset(MPI_${lang}_FOUND)
endfunction()
Expand All @@ -932,7 +942,8 @@ function(check_mpi_type lang)
return()
endif()
endif()
foreach(IDX RANGE 5)
math(EXPR _MNEMONICS_RANGE_LIMIT "${_MNEMONICS_COUNT}-1")
foreach(IDX RANGE ${_MNEMONICS_RANGE_LIMIT})
list(GET _MNEMONICS ${IDX} MNEMONIC)
list(GET _PATTERNS ${IDX} PATTERN)
messagev("Checking '${INC_PATH} MATCHES ${PATTERN} OR ${LIB_PATH} MATCHES ${PATTERN}'")
Expand All @@ -944,6 +955,8 @@ function(check_mpi_type lang)
break()
elseif (MPI STREQUAL MNEMONIC)
messagev("MPI set, Detected MPI-${lang} implementation: ${MNEMONIC}")
list(APPEND _MPI_DETECTED_MNEMONICS ${MNEMONIC})
break()
endif()
else()
messagev("Matching MPI? '${MPI}' == '${MNEMONIC}'")
Expand All @@ -952,6 +965,7 @@ function(check_mpi_type lang)
if (MNEMONIC STREQUAL mpich)
set(_PROIR_TO_TEST_VALUE ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES ${MPI_${lang}_INCLUDE_PATH})
unset(MPICH_VERSION_FOUND CACHE)
check_symbol_exists(MPICH_VERSION "mpi.h" MPICH_VERSION_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${_PROIR_TO_TEST_VALUE})
if (MPICH_VERSION_FOUND)
Expand All @@ -962,13 +976,25 @@ function(check_mpi_type lang)
elseif (MNEMONIC STREQUAL openmpi)
set(_PROIR_TO_TEST_VALUE ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES ${MPI_${lang}_INCLUDE_PATH})
unset(OMPI_MAJOR_VERSION_FOUND CACHE)
check_symbol_exists(OMPI_MAJOR_VERSION "mpi.h" OMPI_MAJOR_VERSION_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${_PROIR_TO_TEST_VALUE})
if (OMPI_MAJOR_VERSION_FOUND)
messagev("Detected MPI-${lang} implementation: ${MNEMONIC}")
list(APPEND _MPI_DETECTED_MNEMONICS ${MNEMONIC})
break()
endif ()
elseif (MNEMONIC STREQUAL mpistub)
set(_PROIR_TO_TEST_VALUE ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES ${MPI_${lang}_INCLUDE_PATH})
unset(MPISTUB_VERSION_FOUND CACHE)
check_symbol_exists(MPISTUB_VERSION "mpi.h" MPISTUB_VERSION_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${_PROIR_TO_TEST_VALUE})
if (MPISTUB_VERSION_FOUND)
messagev("Detected MPI-${lang} implementation: ${MNEMONIC}")
list(APPEND _MPI_DETECTED_MNEMONICS ${MNEMONIC})
break()
endif ()
endif ()
# Pattern does not match but we have a matching desired MPI type - set to not found!
if (MPI STREQUAL MNEMONIC)
Expand Down
34 changes: 22 additions & 12 deletions CMakeScripts/OCDetermineMPI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@

macro(clearFindMPIVariables)
unset(MPI_FOUND)
unset(MPI_EXTRA_LIBRARY CACHE)
foreach ( _lang C CXX Fortran)
unset(MPI_${_lang}_FOUND)
unset(MPI_${_lang}_COMPILER)
unset(MPI_${_lang}_COMPILER_FLAGS)
unset(MPI_${_lang}_INCLUDE_PATH)
unset(MPI_${_lang}_LINK_FLAGS)
unset(MPI_${_lang}_LIBRARIES)
unset(MPI_${_lang}_NO_INTERROGATE CACHE)
unset(MPI_${_lang}_COMPILER CACHE)
unset(MPI_${_lang}_COMPILER_FLAGS CACHE)
unset(MPI_${_lang}_INCLUDE_PATH CACHE)
unset(MPI_${_lang}_LINK_FLAGS CACHE)
unset(MPI_${_lang}_LIBRARIES CACHE)
endforeach ()
unset(MPI_Fortran_MODULE_COMPATIBLE)
unset(MPI_DETECTED)
Expand All @@ -31,23 +33,31 @@ macro(clearFindMPIVariables)
unset(MPIEXEC_PREFLAGS CACHE)
unset(MPIEXEC_POSTFLAGS CACHE)
unset(MPIEXEC_MAX_NUMPROCS CACHE)
unset(MPI_LIBRARY CACHE)
unset(MPI_EXTRA_LIBRARY CACHE)
endmacro()

# Start from fresh every time?
clearFindMPIVariables()

unset(SUGGESTED_MPI)
# MPI_HOME specified - use that and fail if there's no MPI
# We also infer the MPI mnemonic from the installation at MPI_HOME
if (DEFINED MPI_HOME AND NOT MPI_HOME STREQUAL "")
log("Using MPI implementation at MPI_HOME=${MPI_HOME}")
log("OPENCMISS_MPI: ${OPENCMISS_MPI}")
find_package(MPI QUIET)
if (NOT MPI_FOUND)
log("No MPI implementation found at MPI_HOME. Please check." ERROR)
endif()
if (NOT DEFINED OPENCMISS_MPI)
# MPI_DETECTED is set by FindMPI.cmake to one of the mnemonics or unknown (MPI_TYPE_UNKNOWN in FindMPI.cmake)
log("Detected MPI for MPI_HOME is: ${MPI_DETECTED}")
if (MPI_FOUND)
set(OPENCMISS_MPI ${MPI_DETECTED} CACHE STRING "Detected MPI implementation" FORCE)
else ()
log("No MPI implementation found at MPI_HOME. Please check." ERROR)
endif()
if (MPI_HOME_BUILD_TYPE)
set(OPENCMISS_MPI_BUILD_TYPE ${MPI_HOME_BUILD_TYPE})
endif ()
if (NOT DEFINED OPENCMISS_MPI_BUILD_TYPE)
set(OPENCMISS_MPI_BUILD_TYPE USER_MPIHOME)
set(OPENCMISS_MPI_BUILD_TYPE unknown)
log("Using MPI via MPI_HOME variable.
If you want to use different build types for the same MPI implementation, please
you have to specify OPENCMISS_MPI_BUILD_TYPE. Using '${OPENCMISS_MPI_BUILD_TYPE}'.
Expand Down Expand Up @@ -86,7 +96,7 @@ else ()
if(OPENCMISS_MPI_USE_SYSTEM)
log("Looking for default system MPI...")
find_package(MPI QUIET)
log("System MPI found: ${MPI_DETECTED}, ${MPI_FOUND}")
log("The default system MPI detected is: ${MPI_DETECTED}, is it available? ${MPI_FOUND}")
endif()

# If there's a system MPI, set MPI to the detected version
Expand Down