Kripke icon indicating copy to clipboard operation
Kripke copied to clipboard

Incorrect MPI configuration

Open mcopik opened this issue 3 years ago • 1 comments

Hi!

On my system, the build configuration could not detect MPI installation automatically:

/usr/bin/mpic++ --showme     
g++ -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -I/usr/lib/x86_64-linux-gnu/openmpi/include -pthread -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi

Thus, I inspected the provided config files and the CMakeLists.txt file to figure out the configuration:

set(CMAKE_CXX_FLAGS "-I/usr/lib/x86_64-linux-gnu/openmpi/include -pthread -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/" CACHE STRING ""
set(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi" CACHE STRING "")

However, this generates incorrect linking step:

/usr/bin/c++  -I/usr/lib/x86_64-linux-gnu/openmpi/include -pthread -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/     -Wall -Wextra  -O3 -ffast-math   -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi CMakeFiles/kripke.exe.dir/src/kripke.cpp.o  -o bin/kripke.exe  lib/libRAJA.a lib/libkripke.a lib/libRAJA.a -ldl

Since linking flags are included before static libraries, the paths are never resolved. The correct approach would be to paste additional linking options at the end of this command.

Furthermore, wouldn't it be simpler to use the default CMake module to provide MPI paths?

find_package(MPI REQUIRED)
include_directories(${MPI_C_INCLUDE_PATH})
SET(MPI_INCLUDE_PATH ${MPI_C_INCLUDE_PATH})
SET(MPI_LINK_FLAGS ${MPI_C_LIBRARIES})

mcopik avatar Jan 17 '22 13:01 mcopik