Skip to content

Commit 787e955

Browse files
Ivan Kochinaleksei-fedotov
andauthored
[oneTBB] Add the Core Types preference API to the spec (#394)
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com> Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
1 parent a76f5ee commit 787e955

2 files changed

Lines changed: 76 additions & 6 deletions

File tree

source/elements/oneTBB/source/info_namespace.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ Interfaces to query information about execution environment.
1616
namespace oneapi {
1717
namespace tbb {
1818
using numa_node_id = /*implementation-defined*/;
19+
using core_type_id = /*implementation-defined*/;
20+
1921
namespace info {
2022
std::vector<numa_node_id> numa_nodes();
23+
std::vector<core_type_id> core_types();
24+
25+
int default_concurrency(task_arena::constraints c);
2126
int default_concurrency(numa_node_id id = oneapi::tbb::task_arena::automatic);
2227
}
2328
} // namespace tbb
@@ -39,6 +44,19 @@ Functions
3944
If error occurs during system topology parsing, returns vector containing single element
4045
that equals to ``task_arena::automatic``.
4146

47+
.. cpp:function:: std::vector<core_type_id> core_types()
48+
49+
Returns the vector of integral indexes that indicate available core types.
50+
The indexes are sorted from the least performant to the most performant core type.
51+
52+
.. note::
53+
If error occurs during system topology parsing, returns vector containing single element
54+
that equals to ``task_arena::automatic``.
55+
56+
.. cpp:function:: int default_concurrency(task_arena::constraints c)
57+
58+
Returns concurrency level for the given constraints.
59+
4260
.. cpp:function:: int default_concurrency(numa_node_id id = oneapi::tbb::task_arena::automatic)
4361

4462
Returns concurrency level of the given NUMA node. If argument is not specified, returns default

source/elements/oneTBB/source/task_scheduler/task_arena/task_arena_cls.rst

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,18 @@ A class that represents an explicit, user-managed task scheduler arena.
2727
};
2828
2929
struct constraints {
30-
numa_node_id numa_node;
31-
int max_concurrency;
32-
3330
constraints(numa_node_id numa_node_ = task_arena::automatic,
3431
int max_concurrency_ = task_arena::automatic);
32+
33+
constraints& set_numa_id(numa_node_id id);
34+
constraints& set_max_concurrency(int maximal_concurrency);
35+
constraints& set_core_type(core_type_id id);
36+
constraints& set_max_threads_per_core(int threads_number);
37+
38+
numa_node_id numa_id = task_arena::automatic;
39+
int max_concurrency = task_arena::automatic;
40+
core_type_id core_type = task_arena::automatic;
41+
int max_threads_per_core = task_arena::automatic;
3542
};
3643
3744
task_arena(int max_concurrency = automatic, unsigned reserved_for_masters = 1,
@@ -113,16 +120,61 @@ Member types and constants
113120

114121
Represents limitations applied to threads within ``task_arena``.
115122

116-
``numa_node`` - An integral logical index uniquely identifying a NUMA node.
117-
All threads joining the ``task_arena`` are bound to this NUMA node.
123+
Starting from C++20 this class should be an aggregate type to support the designated initialization.
124+
125+
.. cpp:member:: numa_node_id constraints::numa_id
126+
127+
An integral logical index uniquely identifying a NUMA node.
128+
If set to non-automatic value, then this NUMA node will be considered as preferred for all the
129+
threads within the arena.
118130

119131
.. note::
120132

121133
NUMA node ID is considered valid if it was obtained through tbb::info::numa_nodes().
122134

123-
``max_concurrency`` - The maximum number of threads that can participate in work processing
135+
.. cpp:member:: int constraints::max_concurrency
136+
137+
The maximum number of threads that can participate in work processing
124138
within the ``task_arena`` at the same time.
125139

140+
.. cpp:member:: core_type_id constraints::core_type
141+
142+
An integral logical index uniquely identifying a core type.
143+
If set to non-automatic value, then this core type will be considered as preferred for all the
144+
threads within the arena.
145+
146+
.. note::
147+
148+
core type ID is considered valid if it was obtained through ``tbb::info::core_types()``.
149+
150+
.. cpp:member:: int constraints::max_threads_per_core
151+
152+
The maximum number of threads that can be scheduled to one core simultaneously.
153+
154+
.. cpp:function:: constraints::constraints(numa_node_id numa_node_ = task_arena::automatic, int max_concurrency_ = task_arena::automatic)
155+
156+
Constructs the constraints object with the provided `numa_id` and `max_concurrency` settings.
157+
158+
.. note::
159+
160+
To support designated initialization this constructor is omitted starting from C++20. Aggregate initialization is supposed to be used instead.
161+
162+
.. cpp:function:: constraints& constraints::set_numa_id(numa_node_id id)
163+
164+
Sets the `numa_id` to the provided ``id``. Returns the reference to the updated constraints object.
165+
166+
.. cpp:function:: constraints& constraints::set_max_concurrency(int maximal_concurrency)
167+
168+
Sets the `max_concurrency` to the provided ``maximal_concurrency``. Returns the reference to the updated constraints object.
169+
170+
.. cpp:function:: constraints& constraints::set_core_type(core_type_id id)
171+
172+
Sets the `core_type` to the provided ``id``. Returns the reference to the updated constraints object.
173+
174+
.. cpp:function:: constraints& constraints::set_max_threads_per_core(int threads_number)
175+
176+
Sets the `max_threads_per_core` to the provided ``threads_number``. Returns the reference to the updated constraints object.
177+
126178
Member functions
127179
----------------
128180

0 commit comments

Comments
 (0)