Question: Read the next MPI code and determine whether deadlock will occur. If not, explain; if so, explain and fix it. double other_data ; if (
Read the next MPI code and determine whether deadlock will occur. If not, explain; if so, explain and fix it. double other_data ; if ( rank==0 | | rank==2) { MPI_Ssend( &own_data , 1 , MPI_DOUBLE , 3 , tag , MPI_COMM_WORLD ) ; MPI_Recv(&other_data , 1 , MPI_DOUBLE , 1 , tag , MPI_COMM_WORLD ,&status ) ; } elseif ( rank==1 ) { MPI_Ssend(&own_data , 1 , MPI_DOUBLE , 0 , tag , MPI_COMM_WORLD ) ; MPI_Ssend(&other_data , 1 , MPI_DOUBLE , 2 , tag , MPI_COMM_WORLD ) ; } elseif ( rank==3 ) { MPI_Recv(&own_data , 1 , MPI_DOUBLE , 0 , tag , MPI_COMM_WORLD ,&status ) ; MPI_Recv(&other_data , 1 , MPI_DOUBLE , 2 , tag , MPI_COMM_WORLD ,&status ) ; } Here as usual rank is the processor id, and we assume somewhere in the program before the displayed code, the variable own data is already initialized.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
