Enable parallel tests.
[hoomd-blue.git] / CMake / hoomd / HOOMDMPISetup.cmake
blob00b27f6f7d211f14ec006f4d059e54888925dfce
1 # Maintainer: jglaser
3 ##################################
4 ## Find MPI
5 if (ENABLE_MPI)
6     # the package is needed
7     find_package(MPI REQUIRED)
9     # now perform some more in-depth tests of whether the MPI library supports CUDA memory
10     if (ENABLE_CUDA AND NOT DEFINED ENABLE_MPI_CUDA)
11         if (MPI_LIBRARY MATCHES mpich)
12             # find out if this is MVAPICH2
13             get_filename_component(_mpi_library_dir ${MPI_LIBRARY} PATH)
14             find_program(MPICH2_VERSION
15                 NAMES mpichversion mpich2version
16                 HINTS ${_mpi_library_dir} ${_mpi_library_dir}/../bin
17             )
18             if (MPICH2_VERSION)
19                 execute_process(COMMAND ${MPICH2_VERSION}
20                                 OUTPUT_VARIABLE _output)
21                 if (_output MATCHES "--enable-cuda")
22                     set(MPI_CUDA TRUE)
23                     message(STATUS "Found MVAPICH2 with CUDA support.")
24                 endif()
25             endif()
26         elseif(MPI_LIBRARY MATCHES libmpi)
27             # find out if this is OpenMPI
28             get_filename_component(_mpi_library_dir ${MPI_LIBRARY} PATH)
29             find_program(OMPI_INFO
30                 NAMES ompi_info
31                 HINTS ${_mpi_library_dir} ${_mpi_library_dir}/../bin
32             )
33             if (OMPI_INFO)
34                 execute_process(COMMAND ${OMPI_INFO}
35                                 OUTPUT_VARIABLE _output)
36                 if (_output MATCHES "smcuda")
37                     set(MPI_CUDA TRUE)
38                     message(STATUS "Found OpenMPI with CUDA support.")
39                 endif()
40             endif()
41         endif()
43         if (MPI_CUDA)
44            message(STATUS "MPI<->CUDA interoperability is available, but disabled by default.")
45            option(ENABLE_MPI_CUDA "Enable MPI<->CUDA interoperability" off)
46         else(MPI_CUDA)
47            message(STATUS "MPI<->CUDA interoperability does not appear to be available.")
48            option(ENABLE_MPI_CUDA "Enable MPI<->CUDA interoperability" off)
49         endif(MPI_CUDA)
50     endif (ENABLE_CUDA AND NOT DEFINED ENABLE_MPI_CUDA)
52     if (ENABLE_MPI)
53         # add include directories
54         include_directories(${MPI_C_INCLUDE_PATH})
55     endif()
57 endif (ENABLE_MPI)