[CMake] FindMPI

Alain Miniussi alain.miniussi at oca.eu
Fri Sep 11 05:32:17 EDT 2015


On 11/09/2015 10:53, Nico Schlömer wrote:
> Hi everyone,
>
> I see from the CMake docs [1] that the recommended way for using MPI is to call `find_package(MPI)` and set the linker and include flags appropriately. On the other hand, I see from the OpenMPI specs [2] that
>
>  >
>
> The Open MPI team *strongly* recommends that you simply use Open MPI's
>
>  > "wrapper" compilers to compile your MPI applications.
>
>
> Is there a way to reconcile these two approaches?

I'm still not sure why those wrappers are provided, except that MPI is mostly used in HPC, where code is often written by people with little engineering background who can't always be trusted for setting compilation and link flags.
I guess it saves them a lot of support ?

The two approaches have theirs draw back, including:
Using the wrappers:
  -Not all MPI implementations have wrappers.
  - Some implementations do not call the underlying compiler you would expect, meaning you might have to set a sub standard env var to select it. (Intel's mpicc calls gcc by default, not icc, you need to use mpiicc (not a standard name) or set some var or ..)
  - You might need to mix with another tool which also provides its own "helpful" wrapper.
Using CMake to detect the MPI stuff:
  - depending on the cmake version and implementations, can be a PITA. MPI relies on the presence of some flags in the (sometime non-existing) wrapper (-show...) which are not always present, or are present but won't behave as expected, or maybe are not present but won't dare reporting it properly in order not to hurt the feeling of pre-existing build system too harshly (provided I understood Intel's explanation).

Most of the time, I use FindMPI which I feed explicitly with compile and link flags... which feel weird.

Cheers

Alain

>
> Cheers,
> Nico
>
>
> [1] http://www.cmake.org/cmake/help/v3.0/module/FindMPI.html
> [2] https://www.open-mpi.org/faq/?category=mpi-apps#general-build
>
>




More information about the CMake mailing list