Method MPI.Comm()->Recv()
- Method
Recv
void
Recv(MPI.Pointer
buf
,int
source
,int
|void
tag
,MPI.Status
|void
status
)
void
Recv(MPI.IntArray
buf
,int
source
,int
|void
tag
,MPI.Status
|void
status
)
void
Recv(MPI.FloatArray
buf
,int
source
,int
|void
tag
,MPI.Status
|void
status
)
void
Recv(MPI.SingleArray
buf
,int
source
,int
|void
tag
,MPI.Status
|void
status
)
void
Recv(MPI.Sentinel
buf
,int
source
,int
|void
tag
,MPI.Status
|void
status
)- Description
Receives a message from
source
with matchingtag
intobuf
, 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).