0

This is the skelton of our program. The MPI_Send function is not working,the printf statement before MPI_Send is working correctly but the control is not going to the printf statement after MPI_Send. And also it is not going to the if(rank>0) condition.

#define MASTER_TO_SLAVE_TAG 1 
#define SLAVE_TO_MASTER_TAG 4

void MPI_Init(int argc,char ***argv);
int MPI_Comm_rank( MPI_Comm comm, int *rank);
int MPI_Comm_size(MPI_Comm comm, int *totalProcess);
if(rank==0)
{
   printf("before send “);
   double  tArray[1];
   tArray[0]=t;
   for(rank=1;rank<totalProcess;rank++)
      MPI_Send(&tArray, 1, MPI_DOUBLE, rank, MASTER_TO_SLAVE_TAG,MPI_COMM_WORLD);
   printf("after send “);
}
if(rank>0)
{
  printf(“inside slave”);
  MPI_Recv(&tArray, 1, MPI_DOUBLE, 0, SLAVE_TO_MASTER_TAG,MPI_COMM_WORLD, &status);
}

1 Answer 1

1

You're trying to receive from a different tag than you're using to send. The MPI_SEND and MPI_RECV calls match by MPI_Comm, tag, and rank. If you don't match all three, the messages will never be received.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.