• 9.1 Update 2
  • 11/11/2015
  • Public Content

Resolving the Deadlock

To avoid deadlock situations, you can use the following approaches:
  • Reorder MPI communication calls between processes.
  • Implement non-blocking calls.
  • Use
  • Use the buffered mode.
The following code section leads to a deadlock in your original application:
... 52 /* waiting for a message that has not been sent */ 53 MPI_Recv( &recv, 1, MPI_CHAR, peer, 100, MPI_COMM_WORLD, &status ); 54 55 /* 56 * Too late, this code is not going to be reached. 57 * Beware, simply moving this code up would rely on 58 * buffering in the MPI. The correct solution is to 59 * use MPI_Isend() before the receive and MPI_Wait() 60 * afterwards. 61 */ 62 send = 0; 63 MPI_Send( &send, 1, MPI_CHAR, peer, 100, MPI_COMM_WORLD ); ...
To resolve the deadlock for the given example, you need to replace the
calls with
. Do the following:
  1. Remove all lines from 52 to 61.
  2. Replace the
    function call (line 63) with the following
    MPI_Sendrecv( &send, 1, MPI_CHAR, peer, 100, &recv, 1, MPI_CHAR, peer, 100, MPI_COMM_WORLD, &status );
  3. Save this information into the file:
  4. Compile and run the modified application with the same parameters. The resulting output should look as follows:
    [0] INFO: Writing tracefile MPI_Sendrecv.stf in /checking/global/deadlock/hard [0] INFO: Error checking completed without finding any problems.
  5. View the newly generated trace file with Intel® Trace Analyzer to make sure that the deadlock issue has been resolved:
As shown in the figure above, the deadlock problem no longer occurs, and both ranks successfully exchanged the messages.

Product and Performance Information


Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804