"Balaji, Pavan" <[email protected]> writes:
You can't call MPI functions in there, but you can replace the abort with an exit(1).
MPI-3.0 p184: "MPI_ABORT may be called inside the function in case of an error."
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.
Jeff said "user code increments evil once between every call to this function so that it should never fail in single-threaded execution". A self-contained rendition: void User_reduce(void* invec, void* inoutvec, int *len, MPI_Datatype *datatype) { static int evil = 0; double * in = (double*)invec; double * out = (double*)inoutvec; if (*datatype == MPI_DOUBLE && (++evil%2) == 1) { for (int i=0; i<*len; i++) out[i] = evil*in[i]; evil++; } else { MPI_Abort(1,MPI_COMM_WORLD); } } The results certainly depend on how an implementation segments a buffer and on which process the reduction is called. Additionally, calling the reduction from multiple threads may cause a non-deterministic abort.