MPI_PROBE(3)
π MPI_PROBE(3) π
okay bestie, sit down, hydrate, because today we're talking about MPI_Probe β that's the page from the Open MPI manual, and she's a real one. no cap. π«Ά
β¨ NAME β¨
MPI_Probe β a blocking little test for a message. she peeks. she waits. she does NOT receive. iconique behavior honestly. π
πΈ SYNTAX πΈ
π C Syntax
#include <mpi.h>
int MPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status *status)
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_PROBE(SOURCE, TAG, COMM, STATUS, IERROR)
INTEGER SOURCE, TAG, COMM, STATUS(MPI_STATUS_SIZE), IERROR
π Fortran 2008 Syntax
USE mpi_f08
MPI_Probe(source, tag, comm, status, ierror)
INTEGER, INTENT(IN) :: source, tag
TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(MPI_Status) :: status
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
three whole flavors, because MPI said "why choose" π§β¨
π INPUT PARAMETERS π
sourceβ the source rank you're waiting on, orMPI_ANY_SOURCEif you're in your "i'll take whoever" era. it's an integer. π¦tagβ the tag value, orMPI_ANY_TAGif you're feeling unbothered about which message shows up. also an integer. πcommβ the communicator. that's a handle, bestie. π
π OUTPUT PARAMETERS π
statusβ the status object, and this is the whole point β it's where the gossip about that message lands (status). πierrorβ Fortran only: the error status, as an integer. π
π₯ DESCRIPTION π₯
so MPI_Probe and MPI_Iprobe are the duo that let you check on incoming messages without actually receiving them. like, you can look. you just can't touch yet. and then you get to decide how to receive them, based on the info the probe hands you in the status variable. for example: the user may allocate memory for the receive buffer, according to the length of the probed message. see? you peeked, you learned the size, now you go get a buffer that fits. main character planning energy. π
MPI_Probe behaves like MPI_Iprobe except that it is a blocking call that returns only after a matching message has been found. she will simply stand there. patiently. until the message shows up. π
if your application does not need to examine the status field, you can save resources by using the predefined constant MPI_STATUS_IGNORE as a special value for the status argument. yes bestie, you can just say "don't tell me, i don't wanna know" and it's free performance. β¨
the semantics of MPI_Probe and MPI_Iprobe guarantee progress: if a call to MPI_Probe has been issued by a process, and a send that matches the probe has been initiated by some process, then the call to MPI_Probe will return, unless the message is received by another concurrent receive operation (that is executed by another thread at the probing process). similarly, if a process busy waits with MPI_Iprobe and a matching message has been issued, then the call to MPI_Iprobe will eventually return flag = true unless the message is received by another concurrent receive operation. so like β unless some other thread steals your message, it's coming. fr fr. π
π¦ Example 1: use blocking probe to wait for an incoming message
CALL MPI_COMM_RANK(comm, rank, ierr)
IF (rank == 0) THEN
CALL MPI_SEND(i, 1, MPI_INTEGER, 2, 0, comm, ierr)
ELSE IF(rank == 1) THEN
CALL MPI_SEND(x, 1, MPI_REAL, 2, 0, comm, ierr)
ELSE ! rank == 2
DO i=1, 2
CALL MPI_PROBE(MPI_ANY_SOURCE, 0,
comm, status, ierr)
IF (status(MPI_SOURCE) = 0) THEN
CALL MPI_RECV(i, 1, MPI_INTEGER, 0, 0, status, ierr)
ELSE
CALL MPI_RECV(x, 1, MPI_REAL, 1, 0, status, ierr)
END IF
END DO
END IF
each message is received with the right type. look at that. flawless. she ate. π
π Example 2: a program similar to the previous example, but with a problem
CALL MPI_COMM_RANK(comm, rank, ierr)
IF (rank == 0) THEN
CALL MPI_SEND(i, 1, MPI_INTEGER, 2, 0, comm, ierr)
ELSE IF(rank == 1) THEN
CALL MPI_SEND(x, 1, MPI_REAL, 2, 0, comm, ierr)
ELSE
DO i=1, 2
CALL MPI_PROBE(MPI_ANY_SOURCE, 0,
comm, status, ierr)
IF (status(MPI_SOURCE) == 0) THEN
CALL MPI_RECV(i, 1, MPI_INTEGER, MPI_ANY_SOURCE, &
0, status, ierr)
ELSE
CALL MPI_RECV(x, 1, MPI_REAL, MPI_ANY_SOURCE, &
0, status, ierr)
END IF
END DO
END IF
we slightly modified Example 2, using MPI_ANY_SOURCE as the source argument in the two receive calls in statements labeled 100 and 200. the program is now incorrect: the receive operation may receive a message that is distinct from the message probed by the preceding call to MPI_Probe. π
so the probe tells you "hey, a message from rank 0 is here!" and then your recv goes "any source, idc" and grabs a different message. absolutely NOT the vibe. this is the trap, bestie. do not walk into it. π
π ERRORS π
almost all MPI routines return an error value; C routines as the return result of the function and Fortran routines in the last argument.
before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. if no communication object is associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. when MPI_COMM_SELF is not initialized (i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when using the Sessions Model exclusively) the error raises the initial error handler. the initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or the mpi_initial_errhandler CLI argument to mpiexec or info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. if no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions and the MPI_ERRORS_ABORT error handler is called for all other MPI functions.
Open MPI includes three predefined error handlers that can be used:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic? yes. effective? also yes. πMPI_ERRORS_ABORTβ an error handler that can be invoked on a communicator, window, file, or session. when called on a communicator, it acts as ifMPI_Abortwas called on that communicator. if called on a window or file, acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. if called on a session, aborts only the local process. πMPI_ERRORS_RETURNβ returns an error code to the application. the chill one. the "let's talk about it" one. π«Ά
MPI applications can also implement their own error handlers by calling:
MPI_Comm_create_errhandlerthenMPI_Comm_set_errhandlerMPI_File_create_errhandlerthenMPI_File_set_errhandlerMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initMPI_Win_create_errhandlerthenMPI_Win_set_errhandler
note that MPI does not guarantee that an MPI program can continue past an error. β οΈ
see the MPI man page for a full list of MPI error codes.
see the Error Handling section of the MPI-3.1 standard for more information.
note that per the βReturn Statusβ section in the βPoint-to-Point Communicationβ chapter in the MPI Standard (https://www.mpi-forum.org/docs/), MPI errors on messages queried by MPI_Probe do not set the status.MPI_ERROR field in the returned status. the error code is always passed to the back-end error handler and may be passed back to the caller through the return value of MPI_Probe if the back-end error handler returns it. the pre-defined MPI error handler MPI_ERRORS_RETURN exhibits this behavior, for example. π§
see also:
MPI_IprobeMPI_Cancel
π Copyright π
2003-2026, The Open MPI Community
okay that's the whole page bestie, no notes, every single flag and caveat intact, we did not skip a crumb π and for the lil' sign-off: this gorgeous thing ships with Open MPI, it's dated Sep 10, 2026, and you'll find it in the manual as MPI_PROBE(3). go probe something. responsibly. πβ¨πΈπ¦π
π¦ where this page comes from
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms