Skip to content

Conversation

@isaevil
Copy link
Contributor

@isaevil isaevil commented Oct 2, 2025

Add a page that describes helper APIs to simplify constrained arena creations. Currently it is a single function oneapi::tbb::create_numa_task_arenas from corresponding RFC.

Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
@isaevil isaevil force-pushed the add-numa-arena-helper branch from 93dbd8a to f819fc1 Compare October 2, 2025 09:32
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
@isaevil
Copy link
Contributor Author

isaevil commented Oct 2, 2025

@aleksei-fedotov @akukanov Please take a look.

@akukanov akukanov added the TBB label Oct 2, 2025
.. cpp:function:: std::vector<oneapi::tbb::task_arena> create_numa_task_arenas(oneapi::tbb::task_arena::constraints other_constraints = {}, unsigned reserved_slots = 0)

Returns a ``std::vector`` of ``task_arena`` objects, each bound to a separate NUMA node.
The number of created ``task_arena`` is equal to the number of NUMA nodes available on the system.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall it be less strict and, thus, more accurate?

Suggested change
The number of created ``task_arena`` is equal to the number of NUMA nodes available on the system.
The number of created ``task_arena`` is equal to the number of NUMA nodes detected on the system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we require that this is the same set of nodes that is returned by tbb::info::numa_nodes()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is fair to require that as well, since the intent of this API is to provide shortcut to a common usage pattern of NUMA-constrained arenas.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the description

isaevil and others added 3 commits October 20, 2025 16:37
Co-authored-by: Aleksei Fedotov <fedotov.aleksei@gmail.com>
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
@akukanov akukanov changed the title [oneTBB] Add a page with constraints helpers to the spec [oneTBB] Add a function to create a set of NUMA bound task arenas Oct 22, 2025
isaevil and others added 4 commits October 23, 2025 11:19
Co-authored-by: Alexey Kukanov <alexey.kukanov@intel.com>
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
Co-authored-by: Alexey Kukanov <alexey.kukanov@intel.com>
Comment on lines 346 to 347
the ``task_arena`` objects. The ``numa_id`` value in ``constraints`` is automatically
replaced with a separate value for each created arena.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second sentence is not 100% clear for me.
As far as I understand, the numa_id value in constraints is ignored and the corresponding numa_id` from tbb::info::numa_nodes`` is used instead.

May be something like this will be easier to understand?

Suggested change
the ``task_arena`` objects. The ``numa_id`` value in ``constraints`` is automatically
replaced with a separate value for each created arena.
the ``task_arena`` objects. The ``numa_id`` value specified in ``constraints`` is disregarded, and instead,
the corresponding ``numa_id`` from ``tbb::info::numa_nodes()`` is used during construction
of each particular ``task_arena``.

Also, should we specify this somehow if the error occurs during the system parsing as part of create_numa_task_arenas()? Will the numa_id be ignored in this case?

I understand that if the error occurs in create_numa_task_arenas, then it is hard to imagine that there is a valid numa_id in constrains, but may be it still make sense to specify the behavior explicitly somehow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using another value instead of an ignored parameter and replacing that parameter with the other value is essentially the same thing. Either wording does not mandate a specific implementation. The proposed possible implementation (https://github.com/uxlfoundation/oneTBB/blob/master/rfcs/proposed/numa_support/create-numa-arenas.md#possible-implementation) uses the replacement, I would say.

I wanted to avoid words like "ignored" - especially without saying what is used instead. But I can see how this might still be confusing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is better to say that the numa_id parameter for constraints will be automatically set to a certain value:

Suggested change
the ``task_arena`` objects. The ``numa_id`` value in ``constraints`` is automatically
replaced with a separate value for each created arena.
the ``task_arena`` objects. For each created arena, the ``numa_id`` value in ``constraints``
is automatically set to the corresponding NUMA node ID from ``tbb::info::numa_nodes()``.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied suggestions from here and in the comment above from the different discussion.

isaevil and others added 2 commits October 24, 2025 16:32
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
Co-authored-by: Alexey Kukanov <alexey.kukanov@intel.com>
…scovery

Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
Copy link
Contributor

@akukanov akukanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

}
for (int i = 0; i < numa_nodes.size(); i++) {
for (int i = 0; i < arenas.size(); i++) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern demonstrates the usage, but it would be better to execute in one task_arena after enqueuing in the others. Since none of the arenas reserve a slot for a master, the main thread might wait on a fully subscribed arena, and so cannot actively participate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember, it's the specification. The examples here are intended to illustrate usage. In the developer guide, we have a better example: https://uxlfoundation.github.io/oneTBB/main/tbb_userguide/Guiding_Task_Scheduler_Execution.html#set-numa-node

Copy link
Contributor

@aleksei-fedotov aleksei-fedotov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Content looks good to me. Although, I would also tweak a little representational aspects.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have limit on the line width? Proper alignment will help avoiding unnecessary horizontal scrollings and make the rendering neater.

Consider:

Image Image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HTML page looks like this:
image
Seems acceptable, and I am not sure if manual line break can do better in this case.

Copy link
Contributor Author

@isaevil isaevil Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, you can't make indentation when using .. cpp::function with line breaks, so at best it will end up like this:

std::vector<task_arena> create_numa_task_arenas(
task_arena::constraints constraints = {}, 
int reserved_slots = 0)

Comment on lines 74 to 75
std::vector<task_arena> create_numa_task_arenas(task_arena::constraints constraints = {},
unsigned reserved_slots = 0);
Copy link
Contributor

@akukanov akukanov Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other functions, similar parameters are named a bit different. Compare:

  • std::vector<task_arena> create_numa_task_arenas(task_arena::constraints constraints = {}, unsigned reserved_slots = 0)

  • void initialize(constraints a_constraints, unsigned reserved_for_masters = 1, priority a_priority = priority::normal)

I suggest to use reserved_slots and perhaps constraints_ (or maybe a_constraint?) consistently for all functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also change a_priority to priority_ for consistency?

Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants