Odd FindMPI output: Bug? Feature?


Recently on the NASA NAS supercomputer, I noticed something in my CMake output that surprised me when using HPE MPT as the MPI stack.

As an example, I whipped up a simple hello world CMakeLists.txt:

project(helloworld LANGUAGES Fortran)
cmake_minimum_required(VERSION 3.21)
find_package(MPI REQUIRED)
add_executable(helloworld.exe helloworld.F90)
target_link_libraries(helloworld.exe PRIVATE MPI::MPI_Fortran)

and it works:

$ mpiexec -np 4 ./helloworld.exe
MPI Version: 3.1
MPI Library Version: HPE MPT 2.23  11/19/20 04:21:56
Process    0 of    4 is on r901i4n27
Process    1 of    4 is on r901i4n27
Process    2 of    4 is on r901i4n27
Process    3 of    4 is on r901i4n27

But the oddity is in the CMake output:

$ cmake .. -DCMAKE_Fortran_COMPILER=ifort
-- The Fortran compiler identification is Intel 2021.2.0.20210228
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /nasa/intel/Compiler/2021.2.0/compiler/2021.2.0/linux/bin/intel64/ifort - skipped
-- Checking whether /nasa/intel/Compiler/2021.2.0/compiler/2021.2.0/linux/bin/intel64/ifort supports Fortran 90
-- Checking whether /nasa/intel/Compiler/2021.2.0/compiler/2021.2.0/linux/bin/intel64/ifort supports Fortran 90 - yes
-- Found MPI_Fortran: /lib64/libpthread.so (found version "3.1")
-- Found MPI: TRUE (found version "3.1")
-- Configuring done
-- Generating done
-- Build files have been written to: /home3/mathomp4/F90Files/HelloWorldCMake/build

It’s this:

-- Found MPI_Fortran: /lib64/libpthread.so (found version "3.1")

Obviously, the MPI library is not pthread. If I explicitly look at MPI_Fortran_LIBRARIES:

-- MPI_Fortran_LIBRARIES: /lib64/libpthread.so;/nasa/hpe/mpt/2.23_cent7/lib/libmpi.so


So it looks like find_package() just outputs the first library in the list rather than all of them? Is this expected behavior? Is there perhaps a way to have it spit out the whole list? If I got confused that the MPI library it found was libpthread, others users of the code I work on might as well.

It seems to be some oddity with FindMPI and FPHSA. Could you file an issue about this? It’s minor, but something someone can dig into if they’re wondering.

A quick look shows that FPHSA just shows the value of the first variable passed to REQUIRED_VARS. FindMPI builds this list up incrementally, so it’s probably just that this is not built up in an optimal ordering for such reporting.

Done: https://gitlab.kitware.com/cmake/cmake/-/issues/22698

Now to search the internet to see what FPHSA stands for. :slight_smile: