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
Some_Guy
  • 169
  • 11
  • 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. – Gilles Gouaillardet Aug 26 '18 at 05: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 – Some_Guy Aug 26 '18 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` – Gilles Gouaillardet Aug 26 '18 at 23:43
  • @GillesGouaillardet The second option works great. Thanks – Some_Guy Aug 27 '18 at 04: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` – Gilles Gouaillardet Aug 27 '18 at 04:02

2 Answers2

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/

WaitingForGuacamole
  • 3,744
  • 1
  • 8
  • 22
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

ztdep
  • 343
  • 1
  • 4
  • 17