Reputation: 199
What I'm trying to do is to broadcast a value (my pivot) to a sub domain of my hypercube communicator. So that for example process 0 sends to process 1,2 & 3 when process 4 sends to 4,5 & 6. Does it require that I create communicators before hand or is there a way to do a broadcast/send to selected processes?
int broadcaster = 0;
if(isBroadcaster)
{
cout << "rank " << mpiRank << " currentd:" << currentd << " selecting pivot: " << pivot << endl;
pivot = currentValues[0];
broadcaster = mpiRank;
}
//TODO: Broadcast to processes 0 to 4 only.
//here, MPI_COMM_HYPERCUBE contains process 0 to 8
MPI_Bcast(&pivot, 1, MPI_INT, broadcaster, MPI_COMM_HYPERCUBE);
Upvotes: 1
Views: 417
Reputation: 9072
The best solution probably is to use MPI_COMM_SPLIT
to break up your processes into sub-communicators. That is the way of describing communication domains.
The MPI_GROUP
object is used for describing groups, but for the most part can't be used to perform communication.
Another option would be to use MPI_ALLTOALLV
. That's pretty nasty though, and lots of overkill.
Upvotes: 1
Reputation: 5590
You can use mpi_comm_split but if the group members change too often you have to repeat this.
Another solution (dirty but effective in my opinion) would be broadcasting something like a process mask before issuing a compute command. So process 0 will broadcast an array of 8 bool like values with true being set only for mask1, mask[2], mask[3] ...
Upvotes: 0