Reputation: 57
Quick question: Due to performance requirements I need to be able to do later calclulations while I am also sending data. So I need to use MPI_Isend.
Is this safe?
//qtasks[][] is a 2d array and Im sending one row to each task
//it has numtasks rows and different count of columns for each row
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&size);
int k;
for(t=0;t<numtasks;t++){
if(t != rank) {
_k= cqtasks[t]; //this is the number of columns (for each row)
MPI_Isend( qtasks[t],_k,MPI_DOUBLE, t, 55,MPI_COMM_WORLD, &mpireq );
MPI_Request_free( &mpireq );
}
}
Upvotes: 0
Views: 652
Reputation: 3180
No. On the one side, and as Jonathan Dursi pointed out, MPI_Request_free deallocates the request and therefore this call does not ensure that the message has actually reached its destination.
To make sure that the message has arrived, you need to use either MPI_Wait or MPI_Test calls (or any of their relatives - MPI_Waitall, MPI_Waitsome, ... MPI_Testall, MPI_Testsome, ...). So your code may look something like:
//qtasks[][] is a 2d array and Im sending one row to each task
//it has numtasks rows and different count of columns for each row
MPI_Request mpireq[N];
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&size);
int _k;
for(t=0;t<size;t++){
if(t != rank) {
_k= cqtasks[t]; //this is the number of columns (for each row)
MPI_Isend( qtasks[t],_k,MPI_DOUBLE, t, 55,MPI_COMM_WORLD, &mpireq[t] );
}
}
do_some_calculation();
for(t=0;t<size;t++){
if(t != rank) {
MPI_Wait (mpireq[t], MPI_STATUS_IGNORE);
}
}
Upvotes: 1