Re: [Mpi-forum] user-defined reductions and re-entrancy
You can't call MPI functions in there, but you can replace the abort with an exit(1). Each user function is called once per process, so "evil" will always be 1, isn't it? I'm not sure why reentrance is an issue here. -- Pavan From: mpi-forum on behalf of Jeff Hammond Reply-To: Main MPI Forum mailing list Date: Tuesday, October 20, 2015 at 11:02 AM To: Main MPI Forum mailing list Subject: [Mpi-forum] user-defined reductions and re-entrancy 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 [email protected]<mailto:[email protected]> http://jeffhammond.github.io/
participants (1)
-
Balaji, Pavan