/* ----------------------------------------------------------------------- * Code: deadlock.c * Lab: MPI Point-to-Point Communication * Improper use of blocking calls results in deadlock. To fix the * code, replace blocking send with non-blocking send. * Usage: deadlock * Run on two nodes * You will need to stop the deadlocked program with \ * Author: Roslyn Leibensperger Last revised: 8/30/95 RYL * ------------------------------------------------------------------------ */ #include #include "mpi.h" #define MSGLEN 2048 /* length of message in elements */ #define TAG_A 100 #define TAG_B 200 main( argc, argv ) int argc; char **argv; { float message1 [MSGLEN], /* message buffers */ message2 [MSGLEN]; int rank, /* rank of task in communicator */ dest, source, /* rank in communicator of destination */ /* and source tasks */ send_tag, recv_tag, /* message tags */ i; MPI_Status status; /* status of communication */ MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); printf ( " Task %d initialized\n", rank ); /* initialize message buffers */ for ( i=0; i