Boost logo

Boost Users :

Subject: Re: [Boost-users] mpi: sending/receiving different types
From: Hicham Mouline (hicham_at_[hidden])
Date: 2010-12-08 12:23:10


 
 
-----Original Message-----
From: "Riccardo Murri" [riccardo.murri_at_[hidden]]
Date: 08/12/2010 01:50 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] mpi: sending/receiving different types
>> 2. the root sends directly a reference to a base class of anything sendable,
>> then the receivers construct the derived classes on reception with
>> broadcast. The T is then the base class type.
>>
> There's a risk of slicing here, i.e., if you pass a reference to a
> base class, only the base class data will be serialized and received.

> As far as I understand, Boost.Serialization (hence Boost.MPI) will do
> the correct thing if you use *pointers* instead: i.e., you send a
> pointer to a (derived) class and you receive it through a pointer to
> the base class.
> (Beware: I have not checked!)

Does Boost.Serialization/MPI construct an object on the heap when it deserializes?

e.g.

master:

base* b = &derived;
broadcast( world, b, 0 );

slave:
base* b;
broadcast( world, b, 0 ); /// does this create the appropriate derived class on the heap, and make b point to it?

Is this what you meant?

Another question, the base struct contains a double and 2 char[8] fields, but also a virtual function.
Does this mean it shouldn't be set as being a MPI data type because of its polymorphism?

Thanks,


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