[Boost.MPI] SendingReceiving an array "view"
I have a small class view<T> that containes a T* and a size. When I send/receive view using Boost.MPI, I want transfert the actual n data pointed by the view pointer and send the size. On receiving, i will receive the size, checks if they are compatible and receive the data into the zone pointed by the pointer of the receiving view. Of course, I may do something more complex than send/Receive, like all_2_all etc. So i was thinking to give view<T> a proper serialize function so boost.serialization may kick in. As the behavior of sending and receiving is different, I use the load/save idiom to separate the behavior. The question is then, how to serialize the n elements poitned by a raw pointer to those data in an efficient way ? Regards
Joel Falcou wrote:
I have a small class view<T> that containes a T* and a size. When I send/receive view using Boost.MPI, I want transfert the actual n data pointed by the view pointer and send the size. On receiving, i will receive the size, checks if they are compatible and receive the data into the zone pointed by the pointer of the receiving view. Of course, I may do something more complex than send/Receive, like all_2_all etc. So i was thinking to give view<T> a proper serialize function so boost.serialization may kick in. As the behavior of sending and receiving is different, I use the load/save idiom to separate the behavior. The question is then, how to serialize the n elements poitned by a raw pointer to those data in an efficient way ?
Regards
Do you have any constraints on what the underlying type for the elements will be? John
Le Mer 29 avril 2009 23:47, John Phillips a écrit :
Do you have any constraints on what the underlying type for the
elements will be? Nope. I actually reused make_array and it seems to do its bidding. Not sure it's the optimal way to do it.
Joel Falcou wrote:
I have a small class view<T> that containes a T* and a size. When I send/receive view using Boost.MPI, I want transfert the actual n data pointed by the view pointer and send the size. On receiving, i will receive the size, checks if they are compatible and receive the data into the zone pointed by the pointer of the receiving view. Of course, I may do something more complex than send/Receive, like all_2_all etc. So i was thinking to give view<T> a proper serialize function so boost.serialization may kick in. As the behavior of sending and receiving is different, I use the load/save idiom to separate the behavior. The question is then, how to serialize the n elements poitned by a raw pointer to those data in an efficient way ? Back to this issue, now here is my use case.
On my N MPI process, I have an array of float (let's say any fundamental
types if we want).
All processor build a few "view" of this array to map a small subset of
contiguous data.
float tab[]= {1,2,3,4,5,6,7,8,9,10};
view<float> v0(&tab[0],5);
view<float> v1(&tab[5],5);
Then I have an array of optional
On 11 May 2009, at 06:34, Joel Falcou wrote:
Joel Falcou wrote:
I have a small class view<T> that containes a T* and a size. When I send/receive view using Boost.MPI, I want transfert the actual n data pointed by the view pointer and send the size. On receiving, i will receive the size, checks if they are compatible and receive the data into the zone pointed by the pointer of the receiving view. Of course, I may do something more complex than send/Receive, like all_2_all etc. So i was thinking to give view<T> a proper serialize function so boost.serialization may kick in. As the behavior of sending and receiving is different, I use the load/save idiom to separate the behavior. The question is then, how to serialize the n elements poitned by a raw pointer to those data in an efficient way ? Back to this issue, now here is my use case.
On my N MPI process, I have an array of float (let's say any fundamental types if we want). All processor build a few "view" of this array to map a small subset of contiguous data.
float tab[]= {1,2,3,4,5,6,7,8,9,10}; view<float> v0(&tab[0],5); view<float> v1(&tab[5],5);
Then I have an array of optional
that will contain v0 and v1. optionall< view<float> > data[2] = {v0,v1};
What I want next is to use mpi::all_to_all to send those data across.
all_to_all(data,data);
In this example, what I want to have is that the data from v1 to be send from P0 to P1 and data from v0 to be send from P1 to P0 *without copies if possible* by hoping that the serialization will forward the data through the view pointer. view serialization is done using make_array.
If I won't use optional, it works. Once I put those in optional, the serialization of optional actually overwrite the data by calling the in-place default constructor of view, which reset the pointer to 0 and prevent proper serialization (no error but, at runtime, the data just aren't transfered).
Is there anything I missed or should I abandon the idea to use make_array and roll on my own serialization routine ?
What you should do is use the skeleton+content mechanism, or just send a contents object of your view once you have created both views. Matthias
participants (4)
-
joel falcou
-
Joel Falcou
-
John Phillips
-
Matthias Troyer