[Mpi-forum] user-defined reductions and re-entrancy

Jeff Hammond jeff.science at gmail.com
Tue Oct 20 11:02:40 CDT 2015

Is there anything in the MPI standard preventing this sort of disgusting

/* 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
  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 {

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.



Jeff Hammond
jeff.science at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpi-forum.org/pipermail/mpi-forum/attachments/20151020/84001c01/attachment.html>

More information about the mpi-forum mailing list