Method MPI.Comm()->Recv()
- Method
Recv
voidRecv(MPI.Pointerbuf,intsource,int|voidtag,MPI.Status|voidstatus)
voidRecv(MPI.IntArraybuf,intsource,int|voidtag,MPI.Status|voidstatus)
voidRecv(MPI.FloatArraybuf,intsource,int|voidtag,MPI.Status|voidstatus)
voidRecv(MPI.SingleArraybuf,intsource,int|voidtag,MPI.Status|voidstatus)
voidRecv(MPI.Sentinelbuf,intsource,int|voidtag,MPI.Status|voidstatus)- Description
Receives a message from
sourcewith matchingtagintobuf, storing the sender's rank and the tag used into the optionally given MPI.Status.- Note
The type of the buffer of the receiver site has to match the type of the buffer of the sender. Exception: If a string is sent, it has to be received into a MPI.Pointer.
- Example
int main() { MPI.IntArray ia = MPI.IntArray(5);
MPI.Init();
write("This is rank %d, %d processes total.\n", MPI.world->rank, MPI.world->size);
if (MPI.world->rank) { for (int i = 0; i < sizeof(ia); i++) { ia[i] = MPI.world->rank + i; }
MPI.world->Send(ia, 0); // send to rank 0 } else { for (int i = 0; i < MPI.world->size; i++) { MPI.world->Recv(ia, i); write("Rank %d sent %O to rank 0.\n", i, (array)ia); } }
MPI.Finalize(); return 0; }
- See also
MPI.Comm->Send(),
MPI.Comm->Bcast(),MPI.ANY_SOURCE,MPI.ANY_TAG, MPI_Send(3).