I am a beginner in MPI and I am following the examples of an MPI tutorial.
However I cannot execute the examples. Please help.
The following example was supposed to execute to completion everytime. It was not supposed to deadlock. However it deadlocks. Can you please tell me what am I doing wrong.
#include <stdio.h>
#include <mpi.h>
int main (int argc, char **argv){
int err, myrank;
MPI_Request request;
MPI_Status status;
double a[100], b[100];
err=MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if(myrank == 0){ /*receive a message, then send*/
MPI_Irecv(b, 100, MPI_DOUBLE, 1, 19, MPI_COMM_WORLD, &request);
MPI_Send(a, 100, MPI_DOUBLE, 1, 17, MPI_COMM_WORLD);
MPI_Wait(&request, &status);
}
if(myrank == 1){ /*send a message, then receive*/
MPI_Irecv(b, 100, MPI_DOUBLE, 1, 17, MPI_COMM_WORLD, &request);
MPI_Send(a, 100, MPI_DOUBLE, 1, 19, MPI_COMM_WORLD);
MPI_Wait(&request, &status);
}
err=MPI_Finalize();
}
thank you for your time and help
|