Is it valid MPI-3 to nest non-blocking collectives?

Is the following a standards-conformant MPI-3 C program?

#include <mpi.h>
int main(int argc, char** argv)
{
int dlocalouter=1, dglobalouter=0, dlocalinner=1, dglobalinner=0;
MPI_Request router, rinner;
MPI_Init(&argc,&argv);
MPI_Iallreduce(&dlocalouter,&dglobalouter,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD,&router);
MPI_Iallreduce(&dlocalinner,&dglobalinner,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD,&rinner);
MPI_Wait(&rinner,MPI_STATUS_IGNORE);
MPI_Wait(&router,MPI_STATUS_IGNORE);
MPI_Finalize();
return 0;
}

• Without having tried it myself, that should work. What problem are you having? – Bill Barth Apr 21 '15 at 14:54
• The second MPI_Wait does not return using one MPI implementation, yet the code runs as expected with a different implementation, so I was curious whether the of code above might not be guaranteed to work by the standard, or if I should start looking for other reasons for the difference. – Patrick Sanan Apr 21 '15 at 16:07
• Sounds like you might have found a bug. MPI-3 is relatively new, and I suspect all the bugs haven't been worked out in all the libraries. I say contact the developers of the one that doesn't return. – Bill Barth Apr 21 '15 at 16:12
• You should probably initialize the accumulators dglobalouter and dglobalinner. It probably doesn't affect the ability of the code to run to completion, but it will affect the answer. Also, you should grab ierr and check it from each MPI call. Most stacks abort on error by default, but who knows what you've got there. – Bill Barth Apr 21 '15 at 16:14
• I will try with the initialization. I actually had checks on ierr in there but took them out to make this post more concise! – Patrick Sanan Apr 21 '15 at 16:17

The reason I asked was that with a particular implementation (cray-mpich 7.0.4), in a particular environment on a particular system, the second MPI_Wait call would not return. This was likely due to a bug somewhere in the MPI library or a dependent communication library, and was remedied by upgrading to a newer version of the MPI implementation (cray-mpich 7.1.1).