Hi,
Could anyone point me to an example of mixing boost serialization with C
MPI functions?
I guess I need to use boost::mpi::oarchive. But how should I initialize the
buffer parameter, and what should I pass to MPI_Send after that? More
specifically, I am trying to do the following:
typedef vector <int> ParticleList_t;
#define MSG_LEN 100000
ParticleList_t sendbuf(MSG_LEN, 1), recvbuf(MSG_LEN);
mpi::packed_oarchive::buffer_type
buffer(sizeof(sendbuf[0])*sendbuf.size());
mpi::packed_oarchive oa(world, buffer, boost::archive::no_header);
oa & sendbuf;
if(world.rank()==0)
MPI_Send(oa, 1, MPI_PACKED, 1, 0, MPI_COMM_WORLD);
Do I have to make sure buffer is big enough or the oarchive will handle the
memory automatically? If the former, what is the correct memory size to
hold a vector? I guess it should hold not just vec.data(), but also
vec.size().
And lastly, oa does not appear to be the correct variable to pass to
MPI_Send. Then what should I pass to MPI_Send after creating the archive?
I am asking because the boost mpi installation on our server appears to
have a limitation on the message size. For example, the attached code
reports an error as:
terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::mpi::exception>
>'
what(): MPI_Alloc_mem: MPI_Alloc_mem: Out of "special" (shared) memory
MPI Application rank 0 killed before MPI_Finalize() with signal 6
This appears to be a problem only with the boost installation on the
server. The code runs correctly on my local machine.
Many Thanks!
Jiaxin
using namespace std;
#include <iostream>
#include <string>
#include "mpi.h"
#include <boost/mpi.hpp>
#include <boost/serialization/string.hpp>
namespace mpi = boost::mpi;
int main(int argc, char **argv)
{
mpi::environment env;
mpi::communicator world;
#define MSG_LEN 100000
vector <int> sendbuf(MSG_LEN, 1), recvbuf(MSG_LEN);
#define USE_BOOST
#ifndef USE_BOOST
if(world.rank()==0)
MPI_Send(sendbuf.data(), MSG_LEN, MPI_INT, 1, 0, MPI_COMM_WORLD);
else if(world.rank()==1)
MPI_Recv(recvbuf.data(), MSG_LEN, MPI_INT, 0, 0, MPI_COMM_WORLD, NULL);
#else
if(world.rank()==0)
world.send(1, 0, sendbuf);
else if(world.rank()==1)
world.recv(0, 0, recvbuf);
#endif
if(world.rank()==1)
cout<<"Data received: "<<recvbuf[0]<<","<<recvbuf[1]<<"...\n";
return 0;
}_______________________________________________
Boost-mpi mailing list
[email protected]
http://lists.boost.org/mailman/listinfo.cgi/boost-mpi