3.7.4. Semantics of Nonblocking Communications


Up: Nonblocking communication Next: Multiple Completions Previous: Communication Completion

The semantics of nonblocking communication is defined by suitably extending the definitions in Section Semantics of point-to-point communication .

Order Nonblocking communication operations are ordered according to the execution order of the calls that initiate the communication. The non-overtaking requirement of Section Semantics of point-to-point communication is extended to nonblocking communication, with this definition of order being used.


Example Message ordering for nonblocking operations.

CALL MPI_COMM_RANK(comm, rank, ierr) 
IF (RANK.EQ.0) THEN 
      CALL MPI_ISEND(a, 1, MPI_REAL, 1, 0, comm, r1, ierr) 
      CALL MPI_ISEND(b, 1, MPI_REAL, 1, 0, comm, r2, ierr) 
ELSE    ! rank.EQ.1 
      CALL MPI_IRECV(a, 1, MPI_REAL, 0, MPI_ANY_TAG, comm, r1, ierr) 
      CALL MPI_IRECV(b, 1, MPI_REAL, 0, 0, comm, r2, ierr) 
END IF 
CALL MPI_WAIT(r1,status) 
CALL MPI_WAIT(r2,status) 
The first send of process zero will match the first receive of process one, even if both messages are sent before process one executes either receive.

Progress A call to MPI_WAIT that completes a receive will eventually terminate and return if a matching send has been started, unless the send is satisfied by another receive. In particular, if the matching send is nonblocking, then the receive should complete even if no call is executed by the sender to complete the send. Similarly, a call to MPI_WAIT that completes a send will eventually return if a matching receive has been started, unless the receive is satisfied by another send, and even if no call is executed to complete the receive.


Example An illustration of progress semantics.

CALL MPI_COMM_RANK(comm, rank, ierr) 
IF (RANK.EQ.0) THEN 
      CALL MPI_SSEND(a, 1, MPI_REAL, 1, 0, comm, ierr) 
      CALL MPI_SEND(b, 1, MPI_REAL, 1, 1, comm, ierr) 
ELSE    ! rank.EQ.1 
      CALL MPI_IRECV(a, 1, MPI_REAL, 0, 0, comm, r, ierr) 
      CALL MPI_RECV(b, 1, MPI_REAL, 0, 1, comm, ierr) 
      CALL MPI_WAIT(r, status, ierr) 
END IF 
This code should not deadlock in a correct MPI implementation. The first synchronous send of process zero must complete after process one posts the matching (nonblocking) receive even if process one has not yet reached the completing wait call. Thus, process zero will continue and execute the second send, allowing process one to complete execution.

If an MPI_TEST that completes a receive is repeatedly called with the same arguments, and a matching send has been started, then the call will eventually return flag = true, unless the send is satisfied by another receive. If an MPI_TEST that completes a send is repeatedly called with the same arguments, and a matching receive has been started, then the call will eventually return flag = true, unless the receive is satisfied by another send.



Up: Nonblocking communication Next: Multiple Completions Previous: Communication Completion


Return to MPI 1.1 Standard Index
Return to MPI-2 Standard Index
Return to MPI Forum Home Page

MPI-1.1 of June 12, 1995
HTML Generated on August 6, 1997