Home > Mobile >  What are usecases of MPI_Pack/MPI_Unpack?
What are usecases of MPI_Pack/MPI_Unpack?

Time:01-16

What is the purpose of using MPI_Pack/MPI_Unpack? Is it better than working with mpi structure types or derived types?

CodePudding user response:

Packing & unpacking is great as a serialization tool: if you can turn an object (in an informal sense) into a sequence of "1 int, 3 chars, 2 doubles, 5 chars, 2 shorts" (or whatever) you can pack this into a "self-documenting message". The receiving side can unpack this with very little knowledge of what is in your message.

The only caveat is that the receiving side may not know the size of the buffer that is incoming, so you may need to do a Probe first.

  • Related