I'm new to boost and openmpi. I'm on a Mac installed the newest version of openmpi through "port" and compiled boost by myself. There is also an openmpi version coming with my Mac in version 1.2.8. I tried to compile and run a small sample but ran into different problems. So the following example won't work for me with openmpi 1.4.2 (through port) but with openmpi 1.2.8:
#include <boost/mpi.hpp>
#include <iostream>
#include <string>
#include <boost/serialization/string.hpp>
namespace mpi = boost::mpi;
int main(int argc, char* argv[])
{
mpi::environment env(argc, argv);
mpi::communicator world;
if (world.rank() == 0) {
world.send(1, 0, std::string("Hello"));
std::string msg;
world.recv(1, 1, msg);
std::cout << msg << "!" << std::endl;
} else {
std::string msg;
world.recv(0, 0, msg);
std::cout << msg << ", ";
std::cout.flush();
world.send(0, 1, std::string("world"));
}
return 0;
}
openmpic++ boost_mpi_test.cpp -lboost_mpi -lboost_serialization -o boost_mpi_test
Running that test says:
openmpirun -np 2 boost_mpi_test
*** The MPI_Pack_size() function was called before MPI_INIT was invoked.
*** This is disallowed by the MPI standard.
*** Your MPI job will now abort.
[pillepalleben:54081] Abort before MPI_INIT completed successfully; not able to guarantee that all other processes were killed!
*** The MPI_Pack_size() function was called before MPI_INIT was invoked.
*** This is disallowed by the MPI standard.
*** Your MPI job will now abort.
[pillepalleben:54082] Abort before MPI_INIT completed successfully; not able to guarantee that all other processes were killed!
Compiling with (1.2.8):
mpic++ boost_mpi_test.cpp -lboost_mpi -lboost_serialization -o boost_mpi_test
While the test runs fine:
mpirun -np 2 boost_mpi_test
Hello, world!
So shall I use 1.2.8? Why I'm running in those issues?
Thanks in advance, ben