<div dir="ltr">Hi Phil,<div><br></div><div>Thanks for your question!</div><div><br></div><div>Calling a custom stack destructor for an unnamed ULT is possible within the current Argobots infrastructure. This is related to this issue: <a href="https://github.com/pmodels/argobots/issues/16" target="_blank">https://github.com/pmodels/argobots/issues/16</a>. </div><div><br></div><div>For the detailed implementation, please find the complete code here (collapsed): <a href="https://github.com/pmodels/argobots/issues/274#issuecomment-785221242" target="_blank">https://github.com/pmodels/argobots/issues/274#issuecomment-785221242</a>. 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.</div><div><br></div><div>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).</div><div><br></div><div>Thanks,</div><div>Shintaro</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 17, 2021 at 2:15 PM Phil Carns via discuss <<a href="mailto:discuss@lists.argobots.org" target="_blank">discuss@lists.argobots.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
We've been thinking about some memory optimizations for which it might <br>
be easier if our own code provided the stack memory for newly created <br>
ULTs so that we have full control over the allocation strategy. This <br>
seems pretty straightforward with the ABT_thread_attr_set_stack() function:<br>
<br>
<a href="https://www.argobots.org/doxygen/latest/d2/df6/group__ULT__ATTR.html#gac8f39be20d677898c45293c5ce31eea0" rel="noreferrer" target="_blank">https://www.argobots.org/doxygen/latest/d2/df6/group__ULT__ATTR.html#gac8f39be20d677898c45293c5ce31eea0</a><br>
<br>
However, our use case often creates unnamed (detached) threads by <br>
setting the ABT_thread_create() newthread argument to NULL. I can <br>
elaborate if needed, but the short story is that this is a really <br>
natural fit for RPC handlers in our model:<br>
<br>
<a href="https://www.argobots.org/doxygen/latest/d0/d6d/group__ULT.html#ga73bd1f04ce57def336cb20cdec9b14bd" rel="noreferrer" target="_blank">https://www.argobots.org/doxygen/latest/d0/d6d/group__ULT.html#ga73bd1f04ce57def336cb20cdec9b14bd</a><br>
<br>
Is it possible to do both (provide an externally managed stack pointer, <br>
and use unnamed ULTs)? From the documentation it looks like the answer <br>
is probably no, because the caller who created the stack allocation <br>
doesn't explicitly free the ULT, and thus doesn't have a way to free the <br>
stack after the ULT is complete.<br>
<br>
I wanted to double check though before I start thinking about <br>
alternatives, though.<br>
<br>
thanks!<br>
<br>
-Phil<br>
<br>
_______________________________________________<br>
discuss mailing list<br>
<a href="mailto:discuss@lists.argobots.org" target="_blank">discuss@lists.argobots.org</a><br>
<a href="https://lists.argobots.org/mailman/listinfo/discuss" rel="noreferrer" target="_blank">https://lists.argobots.org/mailman/listinfo/discuss</a><br>
</blockquote></div>