FindMPI
: Message Passing Interface (MPI) module.The Message Passing Interface (MPI) is a library used to write high-performance parallel applications that use message passing, and is typically deployed on a cluster. MPI is a standard interface (defined by the MPI forum) for which many implementations are available. All of these implementations have somewhat different compilation approaches (different include paths, libraries to link against, etc.), and this module tries to smooth out those differences.
This module will set the following variables:
MPI_FOUND TRUE if we have found MPI
MPI_COMPILE_FLAGS Compilation flags for MPI programs
MPI_INCLUDE_PATH Include path(s) for MPI header
MPI_LINK_FLAGS Linking flags for MPI programs
MPI_LIBRARY First MPI library to link against (cached)
MPI_EXTRA_LIBRARY Extra MPI libraries to link against (cached)
MPI_LIBRARIES All libraries to link MPI programs against
MPIEXEC Executable for running MPI programs
MPIEXEC_NUMPROC_FLAG Flag to pass to MPIEXEC before giving it the
number of processors to run on
MPIEXEC_PREFLAGS Flags to pass to MPIEXEC directly before the
executable to run.
MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after all other flags.
This module will attempt to auto-detect these settings, first by looking for a MPI compiler, which many MPI implementations provide as a pass-through to the native compiler to simplify the compilation of MPI programs. The MPI compiler is stored in the cache variable MPI_COMPILER, and will attempt to look for commonly-named drivers mpic++, mpicxx, mpiCC, or mpicc. If the compiler driver is found and recognized, it will be used to set all of the module variables. To skip this auto-detection, set MPI_LIBRARY and MPI_INCLUDE_PATH in the CMake cache.
If no compiler driver is found or the compiler driver is not recognized, this module will then search for common include paths and library names to try to detect MPI.
If CMake initially finds a different MPI than was intended, and you want to use the MPI compiler auto-detection for a different MPI implementation, set MPI_COMPILER to the MPI compiler driver you want to use (e.g., mpicxx) and then set MPI_LIBRARY to the string MPI_LIBRARY-NOTFOUND. When you re-configure, auto-detection of MPI will run again with the newly-specified MPI_COMPILER.
When using MPIEXEC to execute MPI applications, you should typically use all of the MPIEXEC flags as follows:
${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} PROCS ${MPIEXEC_PREFLAGS} EXECUTABLE
${MPIEXEC_POSTFLAGS} ARGS
where PROCS is the number of processors on which to execute the program, EXECUTABLE is the MPI program, and ARGS are the arguments to pass to the MPI program.