Luis Vitorio Cargnini wrote:
just one additional and if I have:
vector< vector<double> > x;

How to use the MPI_Send

MPI_Send(&x[0][0], x[0].size(),MPI_DOUBLE, 2, 0, MPI_COMM_WORLD);

?



  Vitorio,

The standard provides no information on where the different parts of the data will be, relative to each other. In specific, there is no reason to believe that the data in the different internally nested doubles will be contiguous. (In fact, I know of no platform where it will be.) That means trying to send the whole structure at once is problematic.

What you wrote will provide a pointer to the first element of the first nested vector to MPI_Send, and the length of that nested vector. If that is what you intend, I expect it to work. (I have not tested it, so I may be misthinking something here.) The other nested vectors could be sent for themselves, using separate MPI_Send calls.

The only reliable way to send all of the data at once would be to serialize it off to a single vector or array for the send, then repack it in the structure after it is received.

                        John

Reply via email to