<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>
<div><br>
</div>
<div>You can't call MPI functions in there, but you can replace the abort with an exit(1).</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div> -- Pavan</div>
<div><br>
</div>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:12pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>mpi-forum on behalf of Jeff Hammond<br>
<span style="font-weight:bold">Reply-To: </span>Main MPI Forum mailing list<br>
<span style="font-weight:bold">Date: </span>Tuesday, October 20, 2015 at 11:02 AM<br>
<span style="font-weight:bold">To: </span>Main MPI Forum mailing list<br>
<span style="font-weight:bold">Subject: </span>[Mpi-forum] user-defined reductions and re-entrancy<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">
<div>Is there anything in the MPI standard preventing this sort of disgusting behavior?</div>
<div><br>
</div>
<div>/* user code increments evil once between every call to this function so that it should never fail in single-threaded execution */</div>
<div>static int evil = 0;</div>
MPI_User_function(void* invec, void* inoutvec, int *len, MPI_Datatype *datatype)
<div>{</div>
<div> evil++;</div>
<div> double * in = (double*)invec;</div>
<div> double * out = (double*)inoutvec;<br>
</div>
<div> if (*datatype == MPI_DOUBLE && (evil%2)==0) {</div>
<div> for (int i=0; i<*len; i++) out[i] = evil*in[i];</div>
<div> } else {</div>
<div> MPI_Abort(1,MPI_COMM_WORLD);</div>
<div> }</div>
<div>}<br>
<div><br class="">
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 :-)</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Thanks,</div>
<div><br>
</div>
<div>Jeff</div>
<div><br>
</div>
--<br>
Jeff Hammond<br>
<a href="mailto:jeff.science@gmail.com" target="_blank">jeff.science@gmail.com</a><br>
<a href="http://jeffhammond.github.io/" target="_blank">http://jeffhammond.github.io/</a></div>
</div>
</div>
</div>
</span>
</body>
</html>