Boost logo

Boost Users :

Subject: Re: [Boost-users] [mpi/serialization] Potential bug or just library misunderstanding?
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-10-20 10:36:14


on Wed Oct 19 2011, Matthias Troyer <troyer-AT-phys.ethz.ch> wrote:

> On Sep 30, 2011, at 5:18 PM, Tim Jacobs wrote:
>
>> I'm not sure why the following test-class produces this error:
>> "MPI_Recv: MPI_ERR_TRUNCATE: message truncated"
>>
>> If the std::map has only a single element (ie I remove one of the
>> test[].push_back() lines) the error does not occur. Can someone
>> verify that this is indeed a bug and not just novice misuse of the
>> library?
>>
>> Thanks,
>> Tim
>>
>> #include <boost/mpi.hpp>
>> #include <boost/serialization/string.hpp>
>> #include <boost/serialization/vector.hpp>
>> #include <boost/serialization/map.hpp>
>>
>> int
>> main( int argc, char * argv [] )
>> {
>> boost::mpi::environment env(argc, argv);
>> boost::mpi::communicator world;
>>
>> if(world.rank()==0){
>> std::map<int, std::vector<std::string> > test;
>> test[1].push_back("FOO");
>> test[50].push_back("BAR");
>> world.send(1, 1, boost::mpi::skeleton(test));
>> world.send(1, 1, boost::mpi::get_content(test));
>> std::cout << "sent" << std::endl;
>> }
>> else{
>> std::map<int, std::vector<std::string> > test;
>> world.recv(0,1,boost::mpi::skeleton(test));
>> world.recv(0,1,boost::mpi::get_content(test));
>> }
>> }
>
> The problem is that a std::map cannot be sent using the
> skeleton&content approach, since the keys need to be known to build a
> map.

I think, at least in principle, it should be possible to send a map that
way *if* the keys never change... right?

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net