1 # Manage the MPI setup, assuming that CMAKE_C_COMPILER is an MPI
5 message(STATUS "MPI is not compatible with thread-MPI. Disabling thread-MPI.")
6 set(GMX_THREAD_MPI OFF CACHE BOOL
7 "Build a thread-MPI-based multithreaded version of GROMACS (not compatible with MPI)" FORCE)
10 # Test the CMAKE_C_COMPILER for being an MPI (wrapper) compiler
11 TRY_COMPILE(MPI_FOUND ${CMAKE_BINARY_DIR}
12 "${CMAKE_SOURCE_DIR}/cmake/TestMPI.c"
15 # If CMAKE_C_COMPILER is not a MPI wrapper. Try to find MPI using cmake module as fall-back.
16 # cmake < 2.8.5 not recommended for fall-back because of unreliability (redmine #851)
18 if(CMAKE_VERSION VERSION_LESS "2.8.5")
24 if(${${MPI_PREFIX}_FOUND})
25 set(GROMACS_C_FLAGS ${GROMACS_FLAGS} ${${MPI_PREFIX}_COMPILE_FLAGS})
26 set(GROMACS_LINKER_FLAGS ${GROMACS_LINKER_FLAGS} ${${MPI_PREFIX}_LINK_FLAGS})
27 include_directories(${${MPI_PREFIX}_INCLUDE_PATH})
28 list(APPEND GMX_EXTRA_LIBRARIES ${${MPI_PREFIX}_LIBRARIES})
30 set(MPI_FOUND ${${MPI_PREFIX}_FOUND})
34 include(gmxTestMPI_IN_PLACE)
36 gmx_test_mpi_in_place(MPI_IN_PLACE_EXISTS)
39 # Find path of the mpi compilers
40 if (${${MPI_PREFIX}_FOUND})
41 get_filename_component(_mpi_c_compiler_path "${MPI_C_COMPILER}" PATH)
42 get_filename_component(_mpiexec_path "${MPIEXEC}" PATH)
44 get_filename_component(_cmake_c_compiler_path "${CMAKE_C_COMPILER}" PATH)
45 get_filename_component(_cmake_cxx_compiler_path "${CMAKE_CXX_COMPILER}" PATH)
48 # Test for and warn about unsuitable MPI versions
50 # Execute the ompi_info binary with the full path of the compiler wrapper
51 # found, otherwise we run the risk of false positives.
52 find_file(MPI_INFO_BIN ompi_info
53 HINTS ${_mpi_c_compiler_path} ${_mpiexec_path}
54 ${_cmake_c_compiler_path} ${_cmake_cxx_compiler_path}
56 NO_SYSTEM_ENVIRONMENT_PATH
59 exec_program(${MPI_INFO_BIN}
61 OUTPUT_VARIABLE OPENMPI_TYPE
62 RETURN_VALUE OPENMPI_EXEC_RETURN)
63 if(OPENMPI_EXEC_RETURN EQUAL 0)
64 string(REGEX REPLACE ".*Open MPI: \([0-9]+\\.[0-9]*\\.?[0-9]*\).*" "\\1" OPENMPI_VERSION ${OPENMPI_TYPE})
65 if(OPENMPI_VERSION VERSION_LESS "1.4.1")
67 "CMake found OpenMPI version ${OPENMPI_VERSION} on your system. "
68 "There are known problems with GROMACS and OpenMPI version < 1.4.1. "
69 "Please consider updating your OpenMPI if your MPI wrapper compilers "
70 "are using the above OpenMPI version.")
72 unset(OPENMPI_VERSION)
74 unset(OPENMPI_EXEC_RETURN)
79 # Execute the mpiname binary with the full path of the compiler wrapper
80 # found, otherwise we run the risk of false positives.
81 find_file(MPINAME_BIN mpiname
82 HINTS ${_mpi_c_compiler_path}
83 ${_cmake_c_compiler_path} ${_cmake_cxx_compiler_path}
85 NO_SYSTEM_ENVIRONMENT_PATH
88 exec_program(${MPINAME_BIN}
90 OUTPUT_VARIABLE MVAPICH2_TYPE
91 RETURN_VALUE MVAPICH2_EXEC_RETURN)
92 if(MVAPICH2_EXEC_RETURN EQUAL 0)
93 string(REGEX MATCH "MVAPICH2" MVAPICH2_NAME ${MVAPICH2_TYPE})
94 # Want to check for MVAPICH2 in case some other library supplies mpiname
95 string(REGEX REPLACE "MVAPICH2 \([0-9]+\\.[0-9]*[a-z]?\\.?[0-9]*\)" "\\1" MVAPICH2_VERSION ${MVAPICH2_TYPE})
96 if(${MVAPICH2_NAME} STREQUAL "MVAPICH2" AND MVAPICH2_VERSION VERSION_LESS "1.5")
97 # This test works correctly even with 1.5a1
99 "CMake found MVAPICH2 version ${MVAPICH2_VERSION} on your system. "
100 "There are known problems with GROMACS and MVAPICH2 version < 1.5. "
101 "Please consider updating your MVAPICH2 if your MPI wrapper compilers "
102 "are using the above MVAPICH2 version.")
104 unset(MVAPICH2_VERSION)
107 unset(MVAPICH2_EXEC_RETURN)
113 if (CMAKE_VERSION VERSION_LESS "2.8.5")
115 "MPI support requested, but no MPI compiler found. Either set the "
116 "C-compiler (CMAKE_C_COMPILER) to the MPI compiler (often called mpicc), "
117 "or use a newer cmake version (>=2.8.5) which has improved MPI detection.")
120 "MPI support requested, but no MPI compiler found. Either set the "
121 "C-compiler (CMAKE_C_COMPILER) to the MPI compiler (often called mpicc), "
122 "or set the variables reported missing for MPI_C above.")
127 include(gmxTestCatamount)
128 gmx_test_catamount(GMX_CRAY_XT3)
130 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_CRAY_XT3")
136 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_LIB_MPI")