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 # Test for and warn about unsuitable MPI versions
40 exec_program(ompi_info
42 OUTPUT_VARIABLE OPENMPI_TYPE
43 RETURN_VALUE OPENMPI_EXEC_RETURN)
44 if(OPENMPI_EXEC_RETURN EQUAL 0)
45 string(REGEX REPLACE ".*Open MPI: \([0-9]+\\.[0-9]*\\.?[0-9]*\).*" "\\1" OPENMPI_VERSION ${OPENMPI_TYPE})
46 if(OPENMPI_VERSION VERSION_LESS "1.4.1")
48 "CMake found OpenMPI version ${OPENMPI_VERSION} on your system. "
49 "There are known problems with GROMACS and OpenMPI version < 1.4.1. "
50 "Please consider updating your OpenMPI if your MPI wrapper compilers "
51 "are using the above OpenMPI version.")
53 unset(OPENMPI_VERSION)
55 unset(OPENMPI_EXEC_RETURN)
59 OUTPUT_VARIABLE MVAPICH2_TYPE
60 RETURN_VALUE MVAPICH2_EXEC_RETURN)
61 if(MVAPICH2_EXEC_RETURN EQUAL 0)
62 string(REGEX MATCH "MVAPICH2" MVAPICH2_NAME ${MVAPICH2_TYPE})
63 # Want to check for MVAPICH2 in case some other library supplies mpiname
64 string(REGEX REPLACE "MVAPICH2 \([0-9]+\\.[0-9]*[a-z]?\\.?[0-9]*\)" "\\1" MVAPICH2_VERSION ${MVAPICH2_TYPE})
65 if(${MVAPICH2_NAME} STREQUAL "MVAPICH2" AND MVAPICH2_VERSION VERSION_LESS "1.5")
66 # This test works correctly even with 1.5a1
68 "CMake found MVAPICH2 version ${MVAPICH2_VERSION} on your system. "
69 "There are known problems with GROMACS and MVAPICH2 version < 1.5. "
70 "Please consider updating your MVAPICH2 if your MPI wrapper compilers "
71 "are using the above MVAPICH2 version.")
73 unset(MVAPICH2_VERSION)
76 unset(MVAPICH2_EXEC_RETURN)
80 if (CMAKE_VERSION VERSION_LESS "2.8.5")
82 "MPI support requested, but no MPI compiler found. Either set the "
83 "C-compiler (CMAKE_C_COMPILER) to the MPI compiler (often called mpicc), "
84 "or use a newer cmake version (>=2.8.5) which has improved MPI detection.")
87 "MPI support requested, but no MPI compiler found. Either set the "
88 "C-compiler (CMAKE_C_COMPILER) to the MPI compiler (often called mpicc), "
89 "or set the variables reported missing for MPI_C above.")
94 include(gmxTestCatamount)
95 gmx_test_catamount(GMX_CRAY_XT3)
97 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_CRAY_XT3")
103 set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_LIB_MPI")