Home

MPIRecv

MPI_Recv is a blocking point-to-point receive operation in the Message Passing Interface (MPI). It receives a message that matches the specified source, tag, and communicator and stores the data in a user-provided buffer. The call blocks until a matching message is available or an error occurs.

Signature

int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status);

Parameters

- buf: pointer to the receive buffer where data will be stored.

- count: number of elements of datatype to receive.

- datatype: MPI datatype describing the data in buf.

- source: rank of the sending process or MPI_ANY_SOURCE to accept from any source.

- tag: message tag or MPI_ANY_TAG to accept any tag.

- comm: communicator containing the communicating processes.

- status: MIDI_Status object that returns information about the received message (source, tag, and count). Use MPI_STATUS_IGNORE

Behavior and semantics

MPI_Recv blocks until a message that matches the specified source, tag, and communicator arrives. The received

Related topics

Non-blocking variant: MPI_Irecv, which posts a non-blocking receive and completes later via MPI_Wait or MPI_Test. MPI_Recv

to
skip
retrieving
status.
data
is
placed
into
the
provided
buffer.
Information
about
the
actual
source
and
tag
can
be
obtained
from
status
if
MPI_ANY_SOURCE
or
MPI_ANY_TAG
were
used,
typically
via
status.MPI_SOURCE
and
status.MPI_TAG;
the
number
of
received
elements
can
be
retrieved
with
MPI_Get_count.
The
receive
must
have
a
buffer
large
enough
to
hold
the
incoming
message;
otherwise
an
error
may
occur.
The
operation
participates
in
the
standard
MPI
message
matching
rules,
which
include
buffering
and
queueing
according
to
communicator,
source,
and
tag.
is
the
counterpart
that
completes
only
after
a
message
has
been
received.