<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle22
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle24
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">+1 for the first-call semantics – init/finalize on the first-call and then no-op after that.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">-Naveen N Ravi.<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Bob Cernohous
<br>
<b>Sent:</b> Tuesday, March 21, 2017 11:09 AM<br>
<b>To:</b> Kuehn, Jeff <jakuehn@lanl.gov>; Naveen Ravichandrasekaran <nravi@cray.com>; Jeff Hammond <jeff.science@gmail.com><br>
<b>Cc:</b> openshmem-list@openshmem.org<br>
<b>Subject:</b> RE: [Openshmem-list] Effects of removing implicit finalize from the specification<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">I would vote for first-call semantics. The email example wasn’t particularly interesting for atexit. The only reason to want atexit(shmem_finalize) is that there might be
a code path that doesn’t explicitly shmem_finalize. I think you want atexit to finalize, not decrement a reference count. So init/finalize on first-call and no-op after that?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Openshmem-list [<a href="mailto:openshmem-list-bounces@openshmem.org">mailto:openshmem-list-bounces@openshmem.org</a>]
<b>On Behalf Of </b>Kuehn, Jeff<br>
<b>Sent:</b> Tuesday, March 21, 2017 10:48 AM<br>
<b>To:</b> Naveen Ravichandrasekaran <<a href="mailto:nravi@cray.com">nravi@cray.com</a>>; Jeff Hammond <<a href="mailto:jeff.science@gmail.com">jeff.science@gmail.com</a>><br>
<b>Cc:</b> <a href="mailto:openshmem-list@openshmem.org">openshmem-list@openshmem.org</a><br>
<b>Subject:</b> Re: [Openshmem-list] Effects of removing implicit finalize from the specification<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">I have a very small concern with nested semantics vs first call semantics in the case of init and finalize. If one considers the cases of an extra init or finalize and a missing
init or finalize, it seems that the observable side effects of those bugs, are more local to the problem code, and thus easier to debug in the case of first-call semantics, and more non-local in the case of nested semantics. It’s a small concern, but what
do the rest of you think?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Jeff<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">On 3/20/17, 19:51, "Openshmem-list on behalf of Naveen Ravichandrasekaran" <<a href="mailto:openshmem-list-bounces@openshmem.org">openshmem-list-bounces@openshmem.org</a> on behalf of
<a href="mailto:nravi@cray.com">nravi@cray.com</a>> wrote:<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Hi Jeff,</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">> We either need to allow multiple calls to initialize/finalize or we
<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">> need to have is_initialized/is_finalized queries. MPI does the latter
<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">> but since it is utterly trivial to ref count in this case, we should just
<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">> do better than MPI and do the former.<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">My requirement is not to support multiple shmem_finalize calls. I was just</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">merely stating the fact that the side-effect of implicit finalize in the current
</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">specification allows the usage of shmem_finalize multiple times.
</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">What we really need is a semantics which successfully performs finalize or
</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">do no-op when the user uses atexit(shmem_finalize) in their application.
</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">shmem_init(); /* ref_count++ -> actual initialization */</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">shmem_init(); /* ref_count++ -> no-op */</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">shmem_finalize(); /* ref_count-- -> no-op */</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">shmem_finalize(); /* ref_count-- -> actual finalization */</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">FWIU, the reference counter method would be useful for handling</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">multiple shmem_init and shmem_finalize calls, but it won’t probably
</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">work for handling atexit(shmem_finalize).
</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">In this example, it is unclear how the reference counter works.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">int main(void) {</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> shmem_init(); /* ref_count++ -> actual initialization */</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> atexit(shmem_finalize);</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> shmem_finalize(); /* ref_count-- -> actual finalization */
</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> return 0; /* unclear what should happen here */</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">}</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Irrespective of the number of times shmem_init is used, we need to
</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">successfully handle atexit(shmem_finalize). So, I would prefer adding
</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">new APIs in SHMEM to query is_initialized/is_finalized and let the</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">users handle atexit(shmem_finalize) scenario correctly.
</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">-Naveen N Ravi.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> </span><o:p></o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Jeff Hammond [<a href="mailto:jeff.science@gmail.com">mailto:jeff.science@gmail.com</a>]
<br>
<b>Sent:</b> Monday, March 20, 2017 4:01 PM<br>
<b>To:</b> Naveen Ravichandrasekaran <<a href="mailto:nravi@cray.com">nravi@cray.com</a>><br>
<b>Cc:</b> <a href="mailto:openshmem-list@openshmem.org">openshmem-list@openshmem.org</a><br>
<b>Subject:</b> Re: [Openshmem-list] Effects of removing implicit finalize from the specification</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">If we permit multiple calls to finalize then we should also permit multiple calls to initialize. This makes it easy on applications that use libraries and the libraries do not know whether they should call initialize
or not.<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">We either need to allow multiple calls to initialize/finalize or we need to have is_initialized/is_finalized queries. MPI does the latter but since it is utterly trivial to ref count in this case, we should just
do better than MPI and do the former.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">We could add return codes on initialize/finalize to allow users to know whether the calls were no-ops or not. This does not break any existing code because users do not have to assign return codes to variables.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Jeff<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">On Mon, Mar 20, 2017 at 1:37 PM, Naveen Ravichandrasekaran <<a href="mailto:nravi@cray.com" target="_blank">nravi@cray.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-left:.5in">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>
_______________________________________________<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" target="_blank">http://www.openshmem.org/mailman/listinfo/openshmem-list</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal" style="margin-left:.5in"><br>
<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"> <o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-left:.5in">-- <o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">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><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>