Emma
Emma

Reputation: 2022

Variable sized message in MPI

Is there a library call that would allow for sending/receiving of variable sized messages using MPI?

A work around would be to send the data size in the first message and follow it with the actual payload, but I was wondering if there was a convention for combining these two separate messages.

Upvotes: 3

Views: 952

Answers (2)

Dave Goodell
Dave Goodell

Reputation: 2153

You could also use MPI_Probe or MPI_Iprobe instead of posting a receive with MPI_Recv or MPI_Irecv. Probe/Iprobe can have performance disadvantages if used incorrectly, but they are one common approach to dealing with variable-sized messages. Also, be careful in a multithreaded environment because Probe/Iprobe are not safe in some multithreaded contexts. See Hoefler et al. for a thorough discussion of these problems and a sketch of the fix (Mprobe) likely to be included in MPI-3.

Upvotes: 2

Emma
Emma

Reputation: 2022

The count provided to MPI_Recv is only an upper bound. MPI_Get_count can be used to find the exact number of items received.

Kind of like sockets I guess.

Upvotes: 2

Related Questions