Search code examples
mpiscatter-plotlatency

gatherv with automatic message size deduction


I would like to write a gatherv (so different message length on each rank) that automatically deduces the message sizes to receive from each rank. I can obviously do a preliminary message exchange of one integer for this but that will uselessly add the network latency in the total time. I have the feeling that this extra latency time could be avoided by somehow adding the message size as the very beginning of the message... but I couldn't really find how to do it.


Solution

  • It's not possible, I'm afraid, unless you can calculate how many values will be received from information you already have. Otherwise, the initial MPI_Gather of a single int shouldn't be a big overhead. This 'gather, gatherv' pair is quite common in MPI codes. There's no way around it.