I know that dead lock occurs in general when:
one thing is waiting for another thing to complete it's work, while the other thing is waiting the first thing to complete.
and this is my code:
MPI_Comm_rank(MPI_COMM_WORLD, &myrank); /* Get rank */
if( myrank == 0 ) {
MPI_Recv( b, 100, MPI_DOUBLE, 1, 19, MPI_COMM_WORLD, &status );
MPI_Send( a, 100, MPI_DOUBLE, 1, 17, MPI_COMM_WORLD );
}
else if( myrank == 1 ) {
MPI_Recv( b, 100, MPI_DOUBLE, 0, 17, MPI_COMM_WORLD, &status );
MPI_Send( a, 100, MPI_DOUBLE, 0, 19, MPI_COMM_WORLD );
}
In the article Deadlock with MPI , He was asking if the code makes a deadlock situation.
This is his code:
MPI_Comm_rank (comm, &my_rank);
if (my_rank == 0) {
MPI_Send (sendbuf, count, MPI_INT, 1, tag, comm);
MPI_Recv (recvbuf, count, MPI_INT, 1, tag, comm, &status);
} else if (my_rank == 1) {
MPI_Send (sendbuf, count, MPI_INT, 0, tag, comm);
MPI_Recv (recvbuf, count, MPI_INT, 0, tag, comm, &status);
}
Well, the program might freeze, but its situation isn't considered a deadlock situation. If we consider it a deadlock situation, what about the following case:
MPI_Recv (recvbuf, count, MPI_INT, 1, tag, comm, &status);
The program will also freeze. I'm writing an article about deadlock situations, and I'm confused.