Home

Reference

Tutorials

Applications

 

Non-Blocking Communication

Non-blocking send and receive

The previously introduced MPI_SEND and MPI_RECV use blocking communication, i.e. the code does not return from a call to these routines until the send or receive operations have been completed entirely.

Sometimes, one can take advantage of a parallel system's ability to overlap communication and computation by:

  1. initiating communication

  2. carrying out some computation

  3. checking for the communication's completion

The non-blocking variant of the send routine is invoked by:

CALL MPI_ISEND(buf, count, type, iddest, itag, MPI_COMM_WORLD, ireq,ierr)

where:

buf - a buffer holding the data to be sent

count - the number of items in the buffer

type - the type of the items in the buffer. Common predefined types include MPI_INTEGER, MPI_REAL, MPI_DOUBLE_PRECISION, MPI_COMPLEX, MPI_LOGICAL with obvious Fortran equivalents.

iddest - the ID of the destination process.

itag - an integer tag attached to the message for identification purposes

ireq - an integer request handle provided by the MPI system to track individual, non-blocking communication requests

The non-blocking MPI routine that receives a message is invoked by

CALL MPI_IRECV(buf, count, type, idsrc, itag, MPI_COMM_WORLD,ireq, ierr)

where:

buf - a buffer to hold the received data

count - the number of items in the buffer

type - the type of the items in the buffer.

idsrc - the ID of the process from which to receive the message. A special value MPI_ANY_SOURCE allows reception from any process.

itag - an integer tag attached to the message for identification purposes. A special value MPI_ANY_TAG allows reception of a message irrespective of its tag.

ireq - an integer request handle provided by the MPI system to track individual, non-blocking communication requests

Checking for the completion of a communication

There are two options in checking for a communication's completion:

  1. Wait until the communication is complete using MPI_WAIT

  2. Test if the communication is complete using MPI_TEST. If the communication is not complete this variant allows other computations to be done while awaiting completion.

CALL MPI_WAIT(ireq,istatus,ierr)

ireq - an integer request handle provided by the MPI system to track individual, non-blocking communication requests

istatus - an integer array that provides information about this particular request's status

CALL MPI_TEST(ireq,lflag,istatus,ierr)

ireq - an integer request handle provided by the MPI system to track individual, non-blocking communication requests

lflag - a logical flag; .TRUE. if communication indicated by ireq is complete, .FALSE. otherwise.

istatus - an integer array that provides information about this particular request's status

Example

To see an example of the above basic routines go to the Crank-Nicolson application.