Is there anything in the MPI standard preventing this sort of disgusting behavior?
/* user code increments evil once between every call to this function so that it should never fail in single-threaded execution */
static int evil = 0;
MPI_User_function(void* invec, void* inoutvec, int *len, MPI_Datatype *datatype)
{
evil++;
double * in = (double*)invec;
double * out = (double*)inoutvec;
if (*datatype == MPI_DOUBLE && (evil%2)==0) {
for (int i=0; i<*len; i++) out[i] = evil*in[i];
} else {
MPI_Abort(1,MPI_COMM_WORLD);
}
}
My goal is to illustrate a user-defined reduction that is not reentrant. If you dislike my example, then please mentally replace it with a better one of your own creation :-)
The more general question is, are there any constraints on whether implementations may internally use multiple threads to call user-defined reductions? I do not see any, but perhaps this is an oversight on my part.
Thanks,
Jeff
--
Jeff Hammond
jeff.science@gmail.com
http://jeffhammond.github.io/