<div dir="ltr"><div><div><div></div>As I understand this PR, the intent is to define a valid OpenSHMEM program to the following two cases (for now, pending discussion on multiple init/finalize):<br><br></div><div>// Legacy (deprecated) behavior<br></div><div>int main(void) {<br></div> start_pes(0);<br></div> return 0; // includes "implicit finalize"<br><div>}<br><br></div><div>// Desired behavior<br></div><div>int main(void) {<br></div><div> shmem_init();<br></div><div> shmem_finalize();<br></div><div> return 0;<br></div><div>}<br><br></div><div>The specification currently says:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">After the first call to shmem_init, a subsequent call to shmem_init in the same program results in undefined behavior.<br></blockquote><div>and this PR does not change that.<br><br></div><div>The specification does not identify multiple calls to shmem_finalize() as erroneous, but also does not guarantee that shmem_finalize() may be called more than once. Given its behavioral description, I would expect that multiple calls to shmem_finalize() are erroneous.<br><br></div><div class="gmail_extra">The one exception is in the interpretation of implicit finalize that I understand this PR intends to correct. That is, as of 1.3, I think some implementations support your Example #3 because the specification was under-specified.<br><br></div><div class="gmail_extra">Nick<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 20, 2017 at 4:37 PM, Naveen Ravichandrasekaran <span dir="ltr"><<a href="mailto:nravi@cray.com" target="_blank">nravi@cray.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">At present, the specification allows the multiple usage of shmem_finalize.<br>
This seems to be a defined behavior and multiple subsequent calls to finalize<br>
are no-ops.<br>
<br>
The following example should pass as per the current specification;<br>
<br>
Example:1<br>
int main(void) {<br>
shmem_init();<br>
shmem_finalize();<br>
shmem_finalize();<br>
return 0;<br>
}<br>
<br>
In Example:1, we have three finalize (2 explicit + 1 implicit) operations.<br>
Even any common SHMEM usage, will have two finalize operations<br>
(1 explicit + 1 implicit). Even though the specification is not clear about the<br>
above usage, this is the side-effect of having implicit finalize at exit() or at<br>
return from main.<br>
<br>
Example:2<br>
int main(void) {<br>
shmem_init();<br>
atexit(shmem_finalize);<br>
return 0;<br>
}<br>
<br>
During F2F meeting, we decided to drop implicit finalize in the specification.<br>
The argument was that the users can explicitly call "atexit" in the application<br>
to achieve the above behavior as shown in Example:2.<br>
<br>
Example:3<br>
int main(void) {<br>
shmem_init();<br>
atexit(shmem_finalize);<br>
shmem_finalize();<br>
return 0;<br>
}<br>
<br>
FWIU, if we remove implicit finalize from the specification - Example:2 is<br>
guaranteed to work but the behavior on Example:3 is undefined.<br>
<br>
To allow the explicit atexit usage, we either<br>
1. Need to specify that multiple calls to finalize are no-ops or<br>
2. We need to have a new API - "shmem_finalized()" so that the users can<br>
have a wrapper from atexit which checks shmem_finalized() before calling<br>
shmem_finalize().<br>
<br>
Please let me know, if this analysis looks valid.<br>
<br>
-Naveen N Ravi<br>
Cray Inc.<br>
<br>
______________________________<wbr>_________________<br>
Openshmem-list mailing list<br>
<a href="mailto:Openshmem-list@openshmem.org">Openshmem-list@openshmem.org</a><br>
<a href="http://www.openshmem.org/mailman/listinfo/openshmem-list" rel="noreferrer" target="_blank">http://www.openshmem.org/<wbr>mailman/listinfo/openshmem-<wbr>list</a><br>
</blockquote></div><br><br><div dir="ltr"><div><div dir="ltr"><br></div></div></div>
</div></div></div>