11# API to simplify creation of task arenas constrained to NUMA nodes
22
3- This sub-RFC proposes an API to ease creation of a one-per-NUMA-node set of task arenas.
3+ This describes describes an API to ease creation of a one-per-NUMA-node set of task arenas.
44
5- ## Introduction
5+ ## Motivation
66
7- The code example in the [ overarching RFC for NUMA support] ( README.md ) shows the likely
7+ The code example in the [ overarching RFC for NUMA support] ( ../../proposed/numa_support/ README.md) shows the likely
88pattern of using task arenas to distribute computation across all NUMA domains on a system.
99Let's take a closer look at the part where arenas are created and initialized.
1010
@@ -31,18 +31,18 @@ The default constructor of `task_arena` reserves a slot for an application threa
3131at the last line explicitly overwrites it to 0 to allow TBB worker threads taking all the slots, however
3232this nuance might be unknown and easy to miss, potentially resulting in underutilization of CPU resources.
3333
34- ## Proposal
34+ ## Implemented API
3535
36- We propose to introduce a special function to create the set of task arenas, one per NUMA node on the system.
36+ A special function is introduced to create the set of task arenas, one per NUMA node on the system.
3737The initialization code equivalent to the example above would be:
3838
3939```c++
4040 std::vector<tbb::task_arena> arenas = tbb::create_numa_task_arenas();
4141 std::vector<tbb::task_group> task_groups(arenas.size());
4242```
4343
44- The rest of the code in that example might be rewritten with the API proposed in
45- [ Waiting in a task arena] ( ../task_arena_waiting/readme.md ) :
44+ The rest of the code in that example might be rewritten with the API for
45+ [ waiting in a task arena] ( ../task_arena_waiting/readme.md ) :
4646
4747``` c++
4848 // enqueue work to all but the first arena, using the task groups to track work
@@ -71,14 +71,14 @@ The function has the following signature:
7171
7272namespace tbb {
7373 std::vector<tbb::task_arena> create_numa_task_arenas(
74- task_arena::constraints other_constraints = {},
74+ task_arena::constraints constraints_ = {},
7575 unsigned reserved_slots = 0
7676 };
7777}
7878```
7979
8080It optionally takes a ` constraints ` argument to change default arena settings such as maximal concurrency
81- (the upper limit on the number of threads), core type etc.; the ` numa_id ` value in ` other_constraints `
81+ (the upper limit on the number of threads), core type etc.; the ` numa_id ` value in ` constraints_ `
8282is ignored. The second optional argument allows to override the number of reserved slots, which by default
8383is 0 (unlike the ` task_arena ` construction default of 1) for the reasons described in the introduction.
8484
@@ -114,7 +114,7 @@ The following critics was provided in the RFC discussion:
114114
115115- It might be confusing that a single `constraints` object is used to generate multiple arenas,
116116 especially with part of it (`numa_id`) being ignored.
117- - The proposed API addresses just one, albeit important, use case for creating a set of arenas.
117+ - The API addresses just one, albeit important, use case for creating a set of arenas.
118118
119119See the "universal function" alternative below for related considerations.
120120
@@ -175,7 +175,7 @@ its downsides:
175175- It seems very specialized, capable to only address specific and quite narrow set of use cases.
176176- Arenas are pre-initialized and so could not be adjusted after creation.
177177
178- Our proposal , instead, aims at a single usability aspect with incremental improvements/extensions
178+ This API , instead, aims at a single usability aspect with incremental improvements/extensions
179179to the existing oneTBB classes and usage patterns, leaving other aspects to complementary proposals.
180180Specifically, the [Waiting in a task arena](../task_arena_waiting/readme.md) RFC improves the joint
181181use of a task arena and a task group to submit and wait for work. Combined, these extensions will
@@ -202,7 +202,7 @@ would serve as a pattern for generating a set of constraints bound to NUMA domai
202202Using a function to generate arena parameter sets seems even more flexible comparing to a description
203203language, as that function would be not limited in which parameters to alter, and how.
204204
205- Compared to the proposal, this approach would necessarily be more verbose because of the need to
205+ This approach would necessarily be more verbose because of the need to
206206describe or generate a set of constraints. That could however be mitigated for common use cases
207207with presets provided by the library allowing for a reasonably concise code. For example:
208208```c++
@@ -215,10 +215,10 @@ extra complexity. As of now, we know just a few arena set patterns with potentia
215215besides NUMA arenas, we can think of splitting CPU resources by core type and of creating a set of
216216arenas with different priorities. We do not however recall any requests to simplify these use cases.
217217
218- ## Open questions
218+ ## Future Questions
219219- Instead of a free-standing function in namespace ` tbb ` , should we consider
220220 a static member function in class ` task_arena ` ?
221- - The proposal does not consider arena priority, simply keeping the default ` priority::normal ` .
221+ - At this point arena priority parameter is not considered , simply keeping the default ` priority::normal ` .
222222 Are there use cases for pre-setting priorities? Similarly for the experimental thread leave policy.
223223- Are there more practical use cases which could justify the universal function approach?
224224- Need to consider alternatives to silently ignoring ` numa_id ` in constraints, such as an exception
0 commit comments