<html 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:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="FR" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="color:black">Phil, Shintaro,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black">Just in case, we have implemented it in DAOS, and it works just fine !<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black">You can find the whole code for the feature at
<a href="https://github.com/daos-stack/daos/pull/5111">https://github.com/daos-stack/daos/pull/5111</a> .<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black">Bruno.<o:p></o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="color:black"><o:p> </o:p></span></b></p>
<p class="MsoNormal"><b><span lang="EN-US" style="color:black"><o:p> </o:p></span></b></p>
<p class="MsoNormal" style="margin-left:36.0pt"><b><span lang="EN-US" style="color:black">From:<span class="apple-converted-space"> </span></span></b><span lang="EN-US" style="color:black">Shintaro Iwasaki via discuss <</span><span style="color:black"><a href="mailto:discuss@lists.argobots.org"><span lang="EN-US">discuss@lists.argobots.org</span></a></span><span lang="EN-US" style="color:black">><br>
<b>Reply-To:<span class="apple-converted-space"> </span></b>"</span><span style="color:black"><a href="mailto:discuss@lists.argobots.org"><span lang="EN-US">discuss@lists.argobots.org</span></a></span><span lang="EN-US" style="color:black">" <</span><span style="color:black"><a href="mailto:discuss@lists.argobots.org"><span lang="EN-US">discuss@lists.argobots.org</span></a></span><span lang="EN-US" style="color:black">><br>
<b>Date:<span class="apple-converted-space"> </span></b>Thursday 18 November 2021 at 02:29<br>
<b>To:<span class="apple-converted-space"> </span></b>"</span><span style="color:black"><a href="mailto:discuss@lists.argobots.org" title="mailto:discuss@lists.argobots.org"><span lang="EN-US">discuss@lists.argobots.org</span></a></span><span lang="EN-US" style="color:black">"
 <</span><span style="color:black"><a href="mailto:discuss@lists.argobots.org"><span lang="EN-US">discuss@lists.argobots.org</span></a></span><span lang="EN-US" style="color:black">><br>
<b>Cc:<span class="apple-converted-space"> </span></b>Shintaro Iwasaki <</span><span style="color:black"><a href="mailto:shintaro.iwasaki.work@gmail.com"><span lang="EN-US">shintaro.iwasaki.work@gmail.com</span></a></span><span lang="EN-US" style="color:black">><br>
<b>Subject:<span class="apple-converted-space"> </span></b>Re: [argobots-discuss] externally allocated stacks and unnamed (detached) threads<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black">Hi Phil,<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black">Thanks for your question!<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black">Calling a custom stack destructor for an unnamed ULT is possible within the current Argobots infrastructure. This is related to this issue:<span class="apple-converted-space"> </span></span><span style="color:black"><a href="https://github.com/pmodels/argobots/issues/16" target="_blank" title="https://github.com/pmodels/argobots/issues/16"><span lang="EN-US">https://github.com/pmodels/argobots/issues/16</span></a></span><span lang="EN-US" style="color:black">. <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black">For the detailed implementation, please find the complete code here (collapsed):<span class="apple-converted-space"> </span></span><span style="color:black"><a href="https://github.com/pmodels/argobots/issues/274#issuecomment-785221242" target="_blank"><span lang="EN-US">https://github.com/pmodels/argobots/issues/274#issuecomment-785221242</span></a></span><span lang="EN-US" style="color:black">.
 Though you have to call init_stack_key() and finalize_stack_key() to use this, it should be simple enough: you just basically change allocate_stack() and free_stack() for your workload.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black">I believe this is the quick path to implement your idea. But maybe a more intuitive stack-free-hook interface would be preferable (this request is not the first time). Please
 let me know if you need such a new interface (especially if your idea works well).<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black">Shintaro<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt;caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span lang="EN-US" style="color:black"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black">On Wed, Nov 17, 2021 at 2:15 PM Phil Carns via discuss <</span><span style="color:black"><a href="mailto:discuss@lists.argobots.org" target="_blank"><span lang="EN-US">discuss@lists.argobots.org</span></a></span><span lang="EN-US" style="color:black">>
 wrote:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="color:black">Hi all,<br>
<br>
We've been thinking about some memory optimizations for which it might<span class="apple-converted-space"> </span><br>
be easier if our own code provided the stack memory for newly created<span class="apple-converted-space"> </span><br>
ULTs so that we have full control over the allocation strategy.  This<span class="apple-converted-space"> </span><br>
seems pretty straightforward with the ABT_thread_attr_set_stack() function:<br>
<br>
</span><span style="color:black"><a href="https://www.argobots.org/doxygen/latest/d2/df6/group__ULT__ATTR.html#gac8f39be20d677898c45293c5ce31eea0" target="_blank"><span lang="EN-US">https://www.argobots.org/doxygen/latest/d2/df6/group__ULT__ATTR.html#gac8f39be20d677898c45293c5ce31eea0</span></a></span><span lang="EN-US" style="color:black"><br>
<br>
However, our use case often creates unnamed (detached) threads by<span class="apple-converted-space"> </span><br>
setting the ABT_thread_create() newthread argument to NULL.  I can<span class="apple-converted-space"> </span><br>
elaborate if needed, but the short story is that this is a really<span class="apple-converted-space"> </span><br>
natural fit for RPC handlers in our model:<br>
<br>
</span><span style="color:black"><a href="https://www.argobots.org/doxygen/latest/d0/d6d/group__ULT.html#ga73bd1f04ce57def336cb20cdec9b14bd" target="_blank"><span lang="EN-US">https://www.argobots.org/doxygen/latest/d0/d6d/group__ULT.html#ga73bd1f04ce57def336cb20cdec9b14bd</span></a></span><span lang="EN-US" style="color:black"><br>
<br>
Is it possible to do both (provide an externally managed stack pointer,<span class="apple-converted-space"> </span><br>
and use unnamed ULTs)?  From the documentation it looks like the answer<span class="apple-converted-space"> </span><br>
is probably no, because the caller who created the stack allocation<span class="apple-converted-space"> </span><br>
doesn't explicitly free the ULT, and thus doesn't have a way to free the<span class="apple-converted-space"> </span><br>
stack after the ULT is complete.<br>
<br>
I wanted to double check though before I start thinking about<span class="apple-converted-space"> </span><br>
alternatives, though.<br>
<br>
thanks!<br>
<br>
-Phil<br>
<br>
_______________________________________________<br>
discuss mailing list<br>
</span><span style="color:black"><a href="mailto:discuss@lists.argobots.org" target="_blank"><span lang="EN-US">discuss@lists.argobots.org</span></a></span><span lang="EN-US" style="color:black"><br>
</span><span style="color:black"><a href="https://lists.argobots.org/mailman/listinfo/discuss" target="_blank" title="https://lists.argobots.org/mailman/listinfo/discuss"><span lang="EN-US">https://lists.argobots.org/mailman/listinfo/discuss</span></a></span><span lang="EN-US" style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
<p>---------------------------------------------------------------------<br>
Intel Corporation SAS (French simplified joint stock company)<br>
Registered headquarters: "Les Montalets"- 2, rue de Paris, <br>
92196 Meudon Cedex, France<br>
Registration Number:  302 456 199 R.C.S. NANTERRE<br>
Capital: 4,572,000 Euros</p>

<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></body>
</html>