<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi, Matthieu</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div><br>
</div>
<div>Thank you for your question.</div>
<div>> Is the ABT_unit_id associated to threads and tasks a number that necessarily increases as new threads/tasks are created?</div>
<div><br>
</div>
<div>No. Even in the current implementation, a ULT ID is determined when it is inquired about (e.g., `by ABT_thread_get_id()`), not when a ULT is created. This "inquiry" timing depends on configuration options. In the future, this ID can be replaced by a
"pointer". I do not recommend you rely on the ID to know when ULTs/tasks are created.</div>
<div><br>
</div>
<div>> I would like to implement a custom pool that prioritizes running older ULTs over newer ones when possible.</div>
<div><br>
</div>
<div>I do not know how strictly you want to control scheduling, but the following might be easy to implement and beneficial.</div>
<div><br>
</div>
<div>sched_run():</div>
<div> while (1) {</div>
<div> /* Check old_thread_pool first. */</div>
<div> if (unit = ABT_pool_pop(old_thread_pool)) {</div>
<div> /* If "unit" yields, it is pushed to old_thread_pool. </div>
<div> * If you want, you can push it to very_old_thread_pool. */</div>
<div> ABT_xstream_run_unit(unit, old_thread_pool);</div>
<div> continue;</div>
<div> }</div>
<div> /* Check new_thread_pool if old_thread_pool is empty */</div>
<div> if (unit = ABT_pool_pop(new_thread_pool))</div>
<div> /* If "unit" yields, it is pushed to old_thread_pool.</div>
<div> * Note that Argobots 1.1+ does not need ABT_unit_set_associated_pool()</div>
<div> * https://github.com/pmodels/argobots/pull/317 */</div>
<div> ABT_xstream_run_unit(unit, old_thread_pool);</div>
<div> }</div>
<div> }</div>
<div><br>
</div>
<div>The scheduling can cause a deadlock. Please check the solution in the discussion below.</div>
<div>Related discussion: https://lists.argobots.org/pipermail/discuss/2020-August/000085.html</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Shintaro</div>
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Dorier, Matthieu via discuss <discuss@lists.argobots.org><br>
<b>Sent:</b> Sunday, June 20, 2021 10:15 AM<br>
<b>To:</b> discuss@lists.argobots.org <discuss@lists.argobots.org><br>
<b>Cc:</b> Dorier, Matthieu <mdorier@anl.gov><br>
<b>Subject:</b> [argobots-discuss] Attribution of ULT ids</font>
<div> </div>
</div>
<style>
<!--
@font-face
{font-family:"Cambria Math"}
@font-face
{font-family:Calibri}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
{margin:0cm;
font-size:12.0pt;
font-family:"Calibri",sans-serif}
span.x_EmailStyle17
{font-family:"Calibri",sans-serif;
color:windowtext}
.x_MsoChpDefault
{font-size:12.0pt;
font-family:"Calibri",sans-serif}
@page WordSection1
{margin:72.0pt 72.0pt 72.0pt 72.0pt}
div.x_WordSection1
{}
-->
</style>
<div lang="EN-GB" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="x_WordSection1">
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Hi,</span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Is the ABT_unit_id associated to threads and tasks a number that necessarily increases as new threads/tasks are created?</span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:11.0pt">I’m asking because I would like to implement a custom pool that prioritizes running older ULTs over newer ones when possible, and one way of knowing which of multiple ULTs is older could be
to look at the ABT_unit_id and prioritize ULTs with the smallest id.</span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Thanks,</span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Matthieu</span></p>
</div>
</div>
</body>
</html>