Reputation: 4180
I use MPI library for C and I would like to know is it possible to call the MPI collective communication methods from different parts of code by different processes?
Pseudo Example:
MPI_Rank(&rank,MPI_COMM_WORLD);
switch(rank) {
case 0:
MPI_Bcast(buf1,count, type, 0, comm);
break;
case 1:
MPI_Bcast(buf1,count, type, 0, comm);
break;
case 2:
MPI_Bcast(buf1,count, type, 0, comm);
break;
}
or it must be called from same line of code for every process?
MPI_Bcast(buf1,count, type, 0, comm);
Sorry for trivial question but I googled it and failed to find the answer.
Thank You !
Upvotes: 0
Views: 222
Reputation: 20248
It can be called from different parts of the code, but you must make sure that all processes in the communicator actually call MPI_Bcast
to avoid deadlocking. This might be slightly more difficult to ensure if all processes follow different execution paths.
Upvotes: 3