Hi, Is the ABT_unit_id associated to threads and tasks a number that necessarily increases as new threads/tasks are created? 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. Thanks, Matthieu
Hi, Matthieu Thank you for your question.
Is the ABT_unit_id associated to threads and tasks a number that necessarily increases as new threads/tasks are created?
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.
I would like to implement a custom pool that prioritizes running older ULTs over newer ones when possible.
I do not know how strictly you want to control scheduling, but the following might be easy to implement and beneficial. sched_run(): while (1) { /* Check old_thread_pool first. */ if (unit = ABT_pool_pop(old_thread_pool)) { /* If "unit" yields, it is pushed to old_thread_pool. * If you want, you can push it to very_old_thread_pool. */ ABT_xstream_run_unit(unit, old_thread_pool); continue; } /* Check new_thread_pool if old_thread_pool is empty */ if (unit = ABT_pool_pop(new_thread_pool)) /* If "unit" yields, it is pushed to old_thread_pool. * Note that Argobots 1.1+ does not need ABT_unit_set_associated_pool() * https://github.com/pmodels/argobots/pull/317 */ ABT_xstream_run_unit(unit, old_thread_pool); } } The scheduling can cause a deadlock. Please check the solution in the discussion below. Related discussion: https://lists.argobots.org/pipermail/discuss/2020-August/000085.html Thanks, Shintaro ________________________________ From: Dorier, Matthieu via discuss <[email protected]> Sent: Sunday, June 20, 2021 10:15 AM To: [email protected] <[email protected]> Cc: Dorier, Matthieu <[email protected]> Subject: [argobots-discuss] Attribution of ULT ids Hi, Is the ABT_unit_id associated to threads and tasks a number that necessarily increases as new threads/tasks are created? 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. Thanks, Matthieu
Hi Shintaro, Thanks for your response. I already have an implementation similar to what you propose, I was just wondering if there was a way to implement it using those unit ids. Apparently not. Thanks! Matthieu From: "Iwasaki, Shintaro" <[email protected]> Date: Monday, 21 June 2021 at 02:58 To: "[email protected]" <[email protected]> Cc: "Dorier, Matthieu" <[email protected]> Subject: Re: Attribution of ULT ids Hi, Matthieu Thank you for your question.
Is the ABT_unit_id associated to threads and tasks a number that necessarily increases as new threads/tasks are created?
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.
I would like to implement a custom pool that prioritizes running older ULTs over newer ones when possible.
I do not know how strictly you want to control scheduling, but the following might be easy to implement and beneficial. sched_run(): while (1) { /* Check old_thread_pool first. */ if (unit = ABT_pool_pop(old_thread_pool)) { /* If "unit" yields, it is pushed to old_thread_pool. * If you want, you can push it to very_old_thread_pool. */ ABT_xstream_run_unit(unit, old_thread_pool); continue; } /* Check new_thread_pool if old_thread_pool is empty */ if (unit = ABT_pool_pop(new_thread_pool)) /* If "unit" yields, it is pushed to old_thread_pool. * Note that Argobots 1.1+ does not need ABT_unit_set_associated_pool() * https://github.com/pmodels/argobots/pull/317 */ ABT_xstream_run_unit(unit, old_thread_pool); } } The scheduling can cause a deadlock. Please check the solution in the discussion below. Related discussion: https://lists.argobots.org/pipermail/discuss/2020-August/000085.html Thanks, Shintaro ________________________________ From: Dorier, Matthieu via discuss <[email protected]> Sent: Sunday, June 20, 2021 10:15 AM To: [email protected] <[email protected]> Cc: Dorier, Matthieu <[email protected]> Subject: [argobots-discuss] Attribution of ULT ids Hi, Is the ABT_unit_id associated to threads and tasks a number that necessarily increases as new threads/tasks are created? 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. Thanks, Matthieu
participants (2)
-
Dorier, Matthieu -
Iwasaki, Shintaro