next up previous index
Next: Nonblocking Communications Up: Send Modes Previous: Send Modes

Semantics of Send Modes

order
messages are non-overtaking
   CALL mpi_comm_rank(comm, rank, ierr)
   IF (rank .EQ. 0 ) THEN
      CALL mpi_bsend(buf1, count, MPI_REAL, 1, tag, comm, ierr)
      CALL mpi_bsend(buf1, count, MPI_REAL, 1, tag, comm, ierr)
   ELSE  ! rank .EQ. 1
      CALL mpi_recv(buf1, count, MPI_REAL, 0, MPI_ANY_TAG, comm, status, ierr)
      CALL mpi_recv(buf2, count, MPI_REAL, 0, tag, comm, status, ierr)
   END IF
progress
if a pair of matching send and receives have been initiated on two processes, then at least one of these two operations will complete, independently of other actions in the system:
   CALL mpi_comm_rank(comm, rank, ierr)
   IF (rank .EQ. 0) THEN
      CALL mpi_bsend(buf1, count, MPI_REAL, 1, tag1, comm, ierr)
      CALL mpi_ssend(buf2, count, MPI_REAL, 1, tag2, comm, ierr)
   ELSE    ! rank .EQ. 1
      CALL mpi_recv(buf1, count, MPI_REAL, 0, tag2, comm, status, ierr)
      CALL mpi_recv(buf2, count, MPI_REAL, 0, tag1, comm, status, ierr)
   END IF
fairness
there is no guarantee of fairness in handling communication
resource limitations
any pending communication consumes system resources if they are limited - errors will result if resources are not available. Users can attach their own buffers with
MPI_BUFFER_ATTACH( BUFFER, SIZE, IERROR )
and detach them with
MPI_BUFFER_DETACH( BUFFER_ADDR, SIZE, IERROR )
deadlocks
$\,$
example 1
$\,$
CALL mpi_comm_rank( comm, rank, ierr )
IF ( rank .EQ. 0 ) THEN
   CALL mpi_send(sendbuf, count, MPI_REAL, 1, tag, comm, ierr)
   CALL mpi_recv(recvbuf, count, MPI_REAL, 1, tag, comm, status, ierr)
ELSE    ! rank .EQ. 1
   CALL mpi_recv(recvbuf, count, MPI_REAL, 0, tag, comm, status, ierr)
   CALL mpi_send(sendbuf, count, MPI_REAL, 0, tag, comm, ierr)
END IF
this program will succeed even if no buffer is available. Standard SENDs can be replaced with synchronous ones.
example 2
$\,$
CALL mpi_comm_rank( comm, rank, ierr )
IF ( rank .EQ. 0 ) THEN
   CALL mpi_recv(recvbuf, count, MPI_REAL, 1, tag, comm, status, ierr)
   CALL mpi_send(sendbuf, count, MPI_REAL, 1, tag, comm, ierr)
ELSE    ! rank .EQ. 1
   CALL mpi_recv(recvbuf, count, MPI_REAL, 0, tag, comm, status, ierr)
   CALL mpi_send(sendbuf, count, MPI_REAL, 0, tag, comm, ierr)
END IF
This program will always deadlock, for all SEND modes.
example 3
$\,$
CALL mpi_comm_rank( comm, rank, ierr )
IF ( rank .EQ. 0 ) THEN
   CALL mpi_send(sendbuf, count, MPI_REAL, 1, tag, comm, ierr)
   CALL mpi_recv(recvbuf, count, MPI_REAL, 1, tag, comm, status, ierr)
ELSE    ! rank .EQ. 1
   CALL mpi_send(sendbuf, count, MPI_REAL, 0, tag, comm, ierr)
   CALL mpi_recv(recvbuf, count, MPI_REAL, 0, tag, comm, status, ierr)
END IF
This program will succeed only if communication system can buffer at least count reals.



Zdzislaw Meglicki
2001-02-26