Find a Message Passing Interface (MPI) implementation
The Message Passing Interface (MPI) is a library used to write high-performance distributed-memory parallel applications, and is typically deployed on a cluster. MPI is a standard interface (defined by the MPI forum) for which many implementations are available.
This module will set the following variables per language in your project, where <lang>
is one of C, CXX, or Fortran:
MPI_<lang>_FOUND
<lang>
were found.MPI_<lang>_COMPILER
<lang>
.MPI_<lang>_COMPILE_FLAGS
MPI_<lang>_INCLUDE_PATH
MPI_<lang>_LINK_FLAGS
MPI_<lang>_LIBRARIES
Additionally, the following IMPORTED
targets are defined:
MPI::MPI_<lang>
<lang>
.Additionally, FindMPI sets the following variables for running MPI programs from the command line:
MPIEXEC
MPIEXEC_NUMPROC_FLAG
MPIEXEC
before giving it the number of processors to run on.MPIEXEC_MAX_NUMPROCS
MPIEXEC_PREFLAGS
MPIEXEC
directly before the executable to run.MPIEXEC_POSTFLAGS
MPIEXEC
after other flags.To use this module, call find_package(MPI)
. If you are happy with the auto-detected configuration for your language, then you’re done. If not, you have two options:
MPI_<lang>_COMPILER
to the MPI wrapper (e.g. mpicc
) of your choice and reconfigure. FindMPI will attempt to determine all the necessary variables using that compiler’s compile and link flags.MPI_<lang>_LIBRARIES
and MPI_<lang>_INCLUDE_PATH
. You may also set any other variables listed above, but these two are required. This will circumvent autodetection entirely.When configuration is successful, MPI_<lang>_COMPILER
will be set to the compiler wrapper for <lang>
, if it was found. MPI_<lang>_FOUND
and other variables above will be set if any MPI implementation was found for <lang>
, regardless of whether a compiler was found.
When using MPIEXEC
to execute MPI applications, you should typically use all of the MPIEXEC
flags as follows:
${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS
where EXECUTABLE
is the MPI program, and ARGS
are the arguments to pass to the MPI program.
For backward compatibility with older versions of FindMPI, these variables are set, but deprecated:
MPI_FOUND MPI_COMPILER MPI_LIBRARY MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_EXTRA_LIBRARY MPI_LINK_FLAGS MPI_LIBRARIES
In new projects, please use the MPI_<lang>_XXX
equivalents.
© 2000–2017 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/v3.9/module/FindMPI.html