Scientific Computing & Visualization
Help Contact
About Accounts Computation Visualization Documentation Services

Multiprocessing by Message Passing MPI

Example 1.3 Integration with MPI Nonblocking Send

Until a matching receive has signaled that it is ready to receive, a blocking send will continue to wait. In situations where work following the send is not dependent on the safe arrival of the message to proceed, it would be more efficient to use nonblocking send so that work following the send statement can start right away while the send process is pending.

In this example, the point-to-point blocking MPI_Send used in the preceding example is replaced with the nonblocking MPI_Isend subroutine to enable work to proceed while the send process is waiting for its matching receive process to respond.

Example 1.3 Fortran code

Example 1.3 C code

Discussions

  1. With the use of nonblocking MPI_Isend, the work performed by other_work proceed without having to wait for MPI_Recv to complete. This usage of nonblocking send (or receive) to avoid processor idling is referred to as "latency hiding." Latency is the elapse time for an operation, such as MPI_Isend, to complete.
  2. Another performance enhancement applied to this example is the use of MPI_ANY_SOURCE as the source from which the message is received. The do loop is used to account for all non-master processors. The messages originated from these processors will be processed in the order of their arrival rather than any imposed order (such as the loop-index order). This is allowed because integration operation (essentially summation), satisfies both the associative and commutative rules and hence the order of summation is not pertinent.
  3. Since MPI_ANY_SOURCE is used, the origin of an arrived message is not known explicitly. However, the status buffer returning from MPI_Recv contains useful information about the message. For example, status(MPI_SOURCE) returns the source (i.e., processor number) of the message in a fortran code while status.MPI_TAG returns its tag for a C code.

Example 1  | Example 1.1 | Example 1.2 | Example 1.3 | Example 1.4 | Example 1.5

Documentation
Boston University
Boston University
 
OIT | CCS | September 16, 2008  
Scientific Computing & Visualization Boston University home page Boston University home page