Reputation: 4647
I would like to send two arrays: double A
and int B
using broadcast in MPI (I'm using C++). Normally, the communicator.Bcast
blocks for readers, but not for the writer. So, if I did:
communicator.Bcast(A, a_len, ...)
communicator.Bcast(B, b_len, ...)
It could happen that some process would first retrieve the second message and things would mess up.
I wonder, what is the good, clean solution for that problem? Should I use derived datatypes/MPI_Pack? It seems ugly. Can I somehow force usage of TAGs in broadcast?
Upvotes: 1
Views: 83
Reputation: 486
MPI guarantees that collective calls on a communicator are processed in the order they are issued. So no, the readers will not retrieve the second message first - that example is save.
FYI, the MPI C++ interface has been deprecated - it's better to use the C API directly for new code.
Upvotes: 5