Hi Matthias,
probably I'm doing something really stupid, but it seems the problem
is somehow related to shared_ptr. This code reproduces the "MPI
message truncated error":
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include <vector>
struct base
{
virtual void do_something() const = 0;
template <class Archive>
void serialize(Archive &ar, const unsigned int)
{
ar & values;
}
std::vector<double> values;
virtual ~base() {}
};
BOOST_SERIALIZATION_ASSUME_ABSTRACT(base);
struct derived: public base
{
void do_something() const {};
template <class Archive>
void serialize(Archive &ar, const unsigned int)
{
ar & boost::serialization::base_object<base>(*this);
}
};
BOOST_CLASS_EXPORT(derived);
struct container
{
template <class Archive>
void serialize(Archive &ar, const unsigned int)
{
ar & ptr;
}
boost::shared_ptr<base> ptr;
};
int main()
{
boost::mpi::environment env;
boost::mpi::communicator world;
if (world.rank() == 0) {
boost::shared_ptr<container> c(new container());
world.send(1,0,c);
world.recv(1,0,c);
} else {
boost::shared_ptr<container> c(new container());
world.recv(0,0,c);
world.send(0,0,c);
}
return 0;
}
The error happens when rank 1 is receiving the object:
terminate called after throwing an instance of
'boost::exception_detail::clone_implboost::mpi::exception
'
what(): MPI_Unpack: MPI_ERR_TRUNCATE: message truncated
Thanks,
Francesco.