I have questions about the steps to send and receive MPI.
Suppose we have 2 MPI streams that are trying to send a message to each other. Below are three code snippets:
First (block "send" and "accept"):
... int data = ...; ... MPI_Send( &data, sizeof( int ), MPI_INT, (my_id == 0)?1:0, 0, MPI_COMM_WORLD ); MPI_Status status; MPI_Recv( &data, sizeof( int ), MPI_INT, (my_id == 0)?1:0, 0, MPI_COMM_WORLD, &status ); ...
The second (non-blocking 'send', but blocking 'receive'):
... int data = ...; ... MPI_Request request; MPI_Isend( &data, sizeof( int ), MPI_INT, (my_id == 0)?1:0, 0, MPI_COMM_WORLD, &request); MPI_Status status; MPI_Recv( &data, sizeof( int ), MPI_INT, (my_id == 0)?1:0, 0, MPI_COMM_WORLD, &status );
Third (non-blocking βacceptβ with blocking βsendβ):
... int data = ...; ... MPI_Request request; MPI_Irecv( &data, sizeof( int ), MPI_INT, (my_id == 0)?1:0, 0, MPI_COMM_WORLD, &request ); MPI_Send( &data, sizeof( int ), MPI_INT, (my_id == 0)?1:0, 0, MPI_COMM_WORLD); MPI_Status status;
I think there are potential problems with the three codes, but I want your opinion. So, I have the following questions:
What are the (potential) problems (if any) with the 3 codes above?
Which of the three codes above is valid / correct, given the MPI standard, so that it can work with all MPI implementations?
What is the best way (if not one of 3, please write) to do this?
In the third code, what if we change the order of the MPI_Irecv and MPI_Send calls?
PS: By the way, I tried to execute them using Scali MPI, and they all worked!