Reputation: 2071
In my code I define a new MPI user-defined data type. I was wondering if the MPI_Barrier function must follow the MPI_Commit or must be placed at some point where the first use of the new data type appears so that all the processes acknowledge and agree on the defintion of the new data type.
Thanks.
Upvotes: 2
Views: 583
Reputation: 50937
No - there's no communication within the MPI_Type commands, they're completely local. In particular, processes don't necessarily have to agree on the definition of a new type.
If rank 1 sends a new data type to rank 0, all they have to agree on is the amount of data, not the layout of the type. For instance, imagine rank 1 was sending all of it's (say, 2d) local array to rank 0 - it might just choose to send an MPI_Type_contiguous of NX*NY floats. But rank 0 might be receiving this into a larger global array; it might choose to receive it into a Subarray type of the global type. Even if those data types had the same names, they can describe different final layouts in memory, as long as the total amount of data is the same.
Upvotes: 4
Reputation: 8273
MPI datatypes are the private business of the process that creates them. They do not need to match, in fact it is possible and perfectly legal for a receiving process to use a type map that differs from that of the sending process (as long as it doesn't lead to memory corruption of course). As such, there is no synchornization whatsoever when using Define
or Commit
.
Upvotes: 3