2

I am using cmake 3.10.2. I have both openmpi and mpich installed. However I need to load only mpich. So I found from the documentation the following

MPI_EXECUTABLE_SUFFIX

A suffix which is appended to all names that are being looked for. For instance you may set this to .mpich or .openmpi to prefer the one or the other on Debian and its derivatives.

My CMake file goes like this

set(MPI_EXECUTABLE_SUFFIX ".mpich")
FIND_PACKAGE(MPI REQUIRED)
INCLUDE_DIRECTORIES(${MPI_INCLUDE_DIRS})
LINK_DIRECTORIES(${MPI_LIBRARY_DIRS})
message(${MPI_INCLUDE_PATH})

However this shows

/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/usr/lib/x86_64-linux-gnu/openmpi/include...

Where am I going wrong. Could you please help me with this

Also

mpicc -show
gcc -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent/include -I/usr/lib/x86_64-linux-gnu/openmpi/include -pthread -L/usr//lib -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi

mpicc.mpich -show
gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -I/usr/include/mpich -L/usr/lib/x86_64-linux-gnu -lmpich
5
  • Update your PATH so which mpicc shows mpich is used. And the run again cmake and make. If I understand correctly, suffix is for the binaries built by make, and not for choosing a given MPI library. Commented Aug 26, 2018 at 5:07
  • Oh... I tried setting mpich by using update-alternatives. That works fine... However other progs need openmpi as default... Is there any other way to point to mpich directory by giving a kind of flag perhaps Commented Aug 26, 2018 at 16:58
  • 2
    update-alternatives is local to your system. If you manually update $PATH, it will be local to your session (e.g. terminal) and will not affect other programs ran from other terminals. An other option is point cmake to the full mpich mpicc : cmake -DMPI_CC_COMPILER=/.../mpicc Commented Aug 26, 2018 at 23:43
  • @GillesGouaillardet The second option works great. Thanks Commented Aug 27, 2018 at 4:01
  • note you cannot use MPICH mpirun with your Open MPI app, so at some point in time, you will have to update your $PATH or use the full path to Open MPI mpirun Commented Aug 27, 2018 at 4:02

2 Answers 2

3

the best is to use modules for switch between openmpi and mpich:

$ module load mpich
$ module unload mpich  
$ module load openmpi

http://modules.sourceforge.net/

Sign up to request clarification or add additional context in comments.

Comments

1

The default mpicc is not your choice. You can specify it manually in the cmake file, or update the $PATH variable with your mpicc included before the default one. Personally, I installed the mpich in the /usr/local/ directory. Regards

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.