Dan
Dan

Reputation: 13382

Boost.MPI on Ubuntu 12.04

Background

Hi All,

I'm trying to use Boost::MPI, at the moment I'm just trying to run the simple first example from the tutorial. I am having trouble building/running it.

I installed boost using apt-get and installed boost_mpi & boost_serialization (1.48.0) using synaptic package manager. I installed MPICH2 using apt-get.

Even though OpenMPI was never explicitly installed it appears to be on my system, I assume this is a dependency for Boost::MPI but it appears MPICH2 and OpenMPI are treading on each other's toes.

Info

If I build using

g++ test.cpp -I/usr/include/mpich2 -L/usr/lib -lboost_mpi -lboost_serialization

then run using

mpiexec -n 2 ./a.out

It throws a bunch of errors which seem to come from OpenMPI. If I try and build by linking against the OpenMPI library using

g++ test.cpp -L/usr/lib -lboost_mpi -lboost_serialization -lmpi -I/usr/include/openmpi

I get the following errors:

/usr/bin/ld: /tmp/ccJ5ezv7.o: undefined reference to symbol 'ompi_op_set_cxx_callback'
/usr/bin/ld: note: 'ompi_op_set_cxx_callback' is defined in DSO /usr/lib/libmpi.so.0 so try adding it to the linker command line
/usr/lib/libmpi.so.0: could not read symbols: Invalid operation

If I try building using mpic++ with the following command

mpic++ test.cpp -lboost_mpi -lboost_serialization

It will not link returning a bunch of errors of the form

 /usr/lib/libmpich.so: undefined reference to `MPL_trid'

so I tried linking against libmpi i.e.

mpic++ test.cpp -lboost_mpi -lboost_serialization -lmpi

This builds but on running with mpiexec yields the following errors

Fatal error in PMPI_Errhandler_set: Invalid communicator, error stack:
PMPI_Errhandler_set(118): MPI_Errhandler_set(comm=0x370500, errh=0x370be0) failed
PMPI_Errhandler_set(70).: Invalid communicator

Question

It seems to me that somehow OpenMPI and MPICH2 are getting intertwined where there really shouldn't. Does anybody know how I can build against only OpenMPI or MPICH2 then run using the correct mpiexec?

Upvotes: 3

Views: 3261

Answers (1)

Hristo Iliev
Hristo Iliev

Reputation: 74375

Mixing code compiled against different MPI libraries is not supported in general. If your Boost::MPI is linked against Open MPI, then you must use Open MPI for the rest of your application.

To get the mpic++ as well as the other compiler wrappers and all the header files you should install the -dev package for Open MPI. If the library has been installed as a dependency then only the run-time part will be there.

Upvotes: 1

Related Questions