Boost logo

Boost Users :

Subject: Re: [Boost-users] mpi/serialization: broadcast function and the value argument
From: Hicham Mouline (hicham_at_[hidden])
Date: 2010-12-13 15:31:24


>-----Original Message-----
>From: "Matthias Troyer" [troyer_at_[hidden]]
>Date: 09/12/2010 02:39 PM
>To: boost-users_at_[hidden]
>Subject: Re: [Boost-users] mpi/serialization: broadcast function and the value argument
>>On Dec 8, 2010, at 5:50 PM, Hicham Mouline wrote:
>>> Following a suggestion from another thread, I have tried broadcasting in a polymorphic way.
>>>
>>> I have a hierarchy of polymorphic struct (they have 2 virtual functions). I was wondering if it was possible/allowed to
>>>
>>> root process:
>>> base* b; /// b points to an actual derived struct but may also point the base struct (not abstract)
>>> broadcast( ..., b, ...);
>>>
>>> slave processes:
>>> base* b;
>>> broadcast( ..., b, ...); /// broadcast constructs the appropriate struct and makes b point to where it did that
>>>
>>> assuming all the conditions for pointer to class conditions are satisfied for the serialization library.
>>>
>>If serialization works on your polymorphic class then this should work as well.
>>Matthias

>It appears the implementation of mpi::broadcast(), according to this post,
>http://lists.boost.org/boost-users/2010/12/64802.php
>and I confirm that expects an already built object to call the
>(de)serialization procedure on.
>Therefore, this seems a specific issue that mpi::broadcast() may want to handle differently,
>could you confirm/correct?
>thanks,

I would very much appreciate extra opinions about this issue and the route I have taken to solve it.
Let me sum up:

mpi::broadcast() appears to be incapable of sending the argument "value" in a polymorphic way, ie:

sender-------------------
Base* base;
If I call boost::mpi::broadcast(..., base, ...)

receiver-----------------
Base* base;
boost::mpi::broadcast(..., base, ...)
This does not construct the most derived type of base on the heap and make base point there, as serialization would do.

I therefore used a variant made of all the classes of the hierarchy and broadcast it instead.

sender-------------------
variant<...> v;
boost::mpi::broadcast(..., v, ...)

receiver-----------------
variant<...> v;
boost::mpi::broadcast(..., v, ...)

This works but before I replicate it in other parts of the code, I would appreciate your opinions about this solution provided by Riccardo.

Regards,


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