views:

50

answers:

1

I have a std::vector (let's call it "data_vector") that I want to synchronize parts of across processors. I.e., I want to send the values from arbitrary indexes in that vector to other processors.

I can easily do this with Boost's send() functions if I want to send the whole vector, but I really only need to send a small portion of it. Right now I have a separate vector (let's call it "idx_vector") containing the indexes of data_vector that I want to send, but I can change the format if necessary.

What's the best way to do this? I don't want to iterate through and sync each index separately. I could copy all the values into one contiguous vector and sync that, then rebuild it, but I wonder if Boost has a better way. Would Boost.serialization with idx_vector containing pointers to data_vector locations work? How would I do that?

A: 

Serialization should work, since under the hood the MPI implementation will be sending a array of bytes. The MPI method of doing this is to define an MPI datatype that picks out the indices you want to send, in this case probably MPI_Type_indexed would be the right option.

Lawrence Mitchell