-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document a way to flow graph can be attached to arbitrary task_arena #785
Conversation
Signed-off-by: Serov, Vladimir <vladimir.serov@intel.com>
@@ -0,0 +1,62 @@ | |||
.. _attach_flow_graph_to_arena: | |||
|
|||
Attach Flow Graph to arbitrary Task Arena |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attach Flow Graph to arbitrary Task Arena | |
Attach Flow Graph to an Arbitrary Task Arena |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is worth adding in which cases a user may need to attach flow graph to task arena
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes has been applied.
====================== | ||
|
||
|
||
During construction a ``graph`` object captures a reference to the arena of the thread that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During construction a ``graph`` object captures a reference to the arena of the thread that | |
During construction, a ``graph`` object captures a reference to the arena of the thread that |
|
||
|
||
During construction a ``graph`` object captures a reference to the arena of the thread that | ||
constructed the object. Whenever a task is spawned to execute work in the graph, the tasks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructed the object. Whenever a task is spawned to execute work in the graph, the tasks | |
constructed the object. When a task is spawned to execute work in a graph, the tasks |
|
||
During construction a ``graph`` object captures a reference to the arena of the thread that | ||
constructed the object. Whenever a task is spawned to execute work in the graph, the tasks | ||
are spawned in this arena, not in the arena of the that caused the task to be spawned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are spawned in this arena, not in the arena of the that caused the task to be spawned. | |
are spawned in that arena, not in the arena that caused the task to be spawned. |
During construction a ``graph`` object captures a reference to the arena of the thread that | ||
constructed the object. Whenever a task is spawned to execute work in the graph, the tasks | ||
are spawned in this arena, not in the arena of the that caused the task to be spawned. | ||
All tasks are spawned into a single arena, the arena of the thread that constructed the graph |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All tasks are spawned into a single arena, the arena of the thread that constructed the graph | |
All tasks are spawned into a single arena that constructed a graph |
} ); | ||
|
||
|
||
Since the main thread constructs the ``graph`` object, the ``graph`` will use the default arena, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the main thread constructs the ``graph`` object, the ``graph`` will use the default arena, | |
Since the main thread constructs the ``graph`` object, the ``graph`` uses the default arena. |
|
||
|
||
Since the main thread constructs the ``graph`` object, the ``graph`` will use the default arena, | ||
which we initialize with eight slots. After calling ``reset`` function to reinitialize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which we initialize with eight slots. After calling ``reset`` function to reinitialize | |
Such an arena is initialized with eight slots. After calling the ``reset`` function to reinitialize |
|
||
Since the main thread constructs the ``graph`` object, the ``graph`` will use the default arena, | ||
which we initialize with eight slots. After calling ``reset`` function to reinitialize | ||
the graph and nodes executes in arena ``arena``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not clear what is this sentence for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed as not necessary.
the graph and nodes executes in arena ``arena``. | ||
|
||
|
||
So performance tuning optimizations which is described in sections below can be applied for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So performance tuning optimizations which is described in sections below can be applied for | |
A performance tuning optimization can be applied for |
|
||
|
||
So performance tuning optimizations which is described in sections below can be applied for | ||
flow graphs as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flow graphs as well. | |
flow graphs as well. See the following topics to learn more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments below.
Also, let's move source code into separate files so that they are automatically tested when the automation task for testing of samples from the docs is ready.
Signed-off-by: Serov, Vladimir <vladimir.serov@intel.com> Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com> Co-authored-by: Alexandra Epanchinzeva <alexandra.epanchinzeva@intel.com>
thread occupies a slot. Whenever a task is spawned on behalf of the graph, it is spawned | ||
in the arena of the graph it is attached to, disregarding the arena of the thread | ||
which is caused a task to be spawned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the second sentence in this paragraph better be moved closer to the second example as the example now shows this explicitly and so may raise questions of readers.
Perhaps, the best place for it is right after the example introduction words, i.e. line #41.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with suggested changes.
graph g; | ||
function_node< int > f( g, unlimited, []( int i ) { | ||
/*the most performant core type is defined as preferred.*/ | ||
} ); | ||
std::vector<tbb::core_type_id> core_types = tbb::info::core_types(); | ||
tbb::task_arena arena( | ||
tbb::task_arena::constraints{}.set_core_type(core_types.back()) | ||
); | ||
arena.execute( [&]() { | ||
g.reset(); | ||
} ); | ||
f.try_put(1); | ||
g.wait_for_all(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also asked a question about moving the code into separate source file for further simpler testing.
I found this approach that can work for us. Can we use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aleksei-fedotov We definitely can make it work :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to separate source file
During its construction a ``graph`` object attaches to the arena, in which the constructing | ||
thread occupies a slot. Whenever a task is spawned on behalf of the graph, it is spawned | ||
in the arena of the graph it is attached to, disregarding the arena of the thread | ||
which is caused a task to be spawned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which is caused a task to be spawned. | |
that the task is spawned from. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with suggested changes.
thread occupies a slot. Whenever a task is spawned on behalf of the graph, it is spawned | ||
in the arena of the graph it is attached to, disregarding the arena of the thread | ||
which is caused a task to be spawned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree here
in the arena of the graph it is attached to, disregarding the arena of the thread | ||
which is caused a task to be spawned. | ||
|
||
The example shows how to set the most performant core type as preferable for graph execution: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example shows how to set the most performant core type as preferable for graph execution: | |
This example shows how to set the most performant core type as the preferred one for a graph execution: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with suggested changes.
|
||
A ``graph`` object can be reattached to a different ``task_arena`` by calling | ||
the ``graph::reset()`` function. This reinitializes the ``graph`` and reattaches | ||
it to the task arena instance, inside which the ``graph::reset()`` method is executed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it to the task arena instance, inside which the ``graph::reset()`` method is executed. | |
the ``graph`` to the task arena instance, inside which the ``graph::reset()`` method is executed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with suggested changes.
the ``graph::reset()`` function. This reinitializes the ``graph`` and reattaches | ||
it to the task arena instance, inside which the ``graph::reset()`` method is executed. | ||
|
||
The example shows how reattach existing graph to an arena with the most performant core type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example shows how reattach existing graph to an arena with the most performant core type | |
This example shows how to reattach existing graph to an arena with the most performant core type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with suggested changes.
it to the task arena instance, inside which the ``graph::reset()`` method is executed. | ||
|
||
The example shows how reattach existing graph to an arena with the most performant core type | ||
as preferable for work execution: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as preferable for work execution: | |
as the preferred one for a work execution: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with suggested changes.
graph g; | ||
function_node< int > f( g, unlimited, []( int i ) { | ||
/*the most performant core type is defined as preferred.*/ | ||
} ); | ||
std::vector<tbb::core_type_id> core_types = tbb::info::core_types(); | ||
tbb::task_arena arena( | ||
tbb::task_arena::constraints{}.set_core_type(core_types.back()) | ||
); | ||
arena.execute( [&]() { | ||
g.reset(); | ||
} ); | ||
f.try_put(1); | ||
g.wait_for_all(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aleksei-fedotov We definitely can make it work :)
f.try_put(1); | ||
g.wait_for_all(); | ||
|
||
See the following topics to learn more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the following topics to learn more. | |
See the following topics to learn more: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with suggested changes.
Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
Co-authored-by: Alexandra <alexandra.epanchinzeva@intel.com>
Moving examples to separate source file. Signed-off-by: Serov, Vladimir <vladimir.serov@intel.com> Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com> Co-authored-by: Alexandra Epanchinzeva <alexandra.epanchinzeva@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the rest looks good!
Co-authored-by: Alexandra <alexandra.epanchinzeva@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now looks much better to me! There is a couple of questions left, though.
Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Vladimir!
Hope readers won't be nit-picking regarding the other details necessary to make the example fully compilable.
…xlfoundation#785) * Document a way to flow graph can be attached to arbitrary task_arena task_arena interface provides mechanisms to guide tasks execution within the arena by setting the preferred computation units or restricting part of computation units. In some cases, you may want to use mechanisms within a flow graph. Signed-off-by: Serov, Vladimir <vladimir.serov@intel.com> Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com> Co-authored-by: Alexandra Epanchinzeva <alexandra.epanchinzeva@intel.com> (cherry picked from commit a938322)
* Update pull_request_template.md (#751) Signed-off-by: Alexandra Epanchinzeva alexandra.epanchinzeva@intel.com (cherry picked from commit 4eda0f9) * Update CONTRIBUTING.md (#765) (cherry picked from commit e274a9e) * Documentation update for unpreview `task_handle` and related stuff (#755) * Unpreview task_handle and related stuff Signed-off-by: Anton Potapov <anton.potapov@intel.com> Co-authored-by: Alexandra <alexandra.epanchinzeva@intel.com> (cherry picked from commit fd76f45) * Update conf.py (#774) (cherry picked from commit 6666292) * Actualize documentation about proportional splitting constructor in Range (#728) Actualize documentation about proportional splitting Signed-off-by: Fedotov, Aleksei <aleksei.fedotov@intel.com> (cherry picked from commit e5cbe50) * Update doc structure and add new files (#791) (cherry picked from commit ce0d258) * Instruction for building the docs locally (#778) (cherry picked from commit e386960) * Document a way to flow graph can be attached to arbitrary task_arena (#785) * Document a way to flow graph can be attached to arbitrary task_arena task_arena interface provides mechanisms to guide tasks execution within the arena by setting the preferred computation units or restricting part of computation units. In some cases, you may want to use mechanisms within a flow graph. Signed-off-by: Serov, Vladimir <vladimir.serov@intel.com> Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com> Co-authored-by: Alexandra Epanchinzeva <alexandra.epanchinzeva@intel.com> (cherry picked from commit a938322) * Add topic about "Lazy Initiliazation" pattern to Design patterns (#790) New topic about Lazy initialization pattern and how it can be implemented using oneapi::tbb::collaborative_call_once has been added. Signed-off-by: Ilya Isaev <ilya.isaev@intel.com> (cherry picked from commit 1da8f0d) * Update Get Started Guide (#803) (cherry picked from commit 0502372) * Update intro_gsg.rst (#808) (cherry picked from commit 2c4f282) * Update conf.py (#810) (cherry picked from commit 0a0a592) * TBB DOC : Dev Guide: Task Scheduler Bypass and How Does Task Scheduler Works (#521) * TBB DOC : Dev Guide: Task Scheduler Bypass and How Task Scheduler Works Signed-off-by: Anton Potapov <anton.potapov@intel.com> Co-authored-by: Alexandra <alexandra.epanchinzeva@intel.com> (cherry picked from commit ed9d4b5) * Update intro_gsg.rst (#811) (cherry picked from commit efea993) * Update conf.py (#812) (cherry picked from commit 3859d11) * Update examples.rst (#816) (cherry picked from commit 4aa0b0b) * Update layout.html (#815) (cherry picked from commit 3e352b4) * Update RELEASE_NOTES.md for oneTBB 2021.6 (#835) (cherry picked from commit faaf43c) Co-authored-by: Alexandra <alexandra.epanchinzeva@intel.com> Co-authored-by: Anton Potapov <potapov.slash.co@gmail.com> Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com> Co-authored-by: Vladimir Serov <vladimir.serov@intel.com> Co-authored-by: Ilya Isaev <ilya.isaev@intel.com> Co-authored-by: Anton Potapov <anton.potapov@intel.com>
Description
Adding documentation to describes a way to
flow::graph
can be attached to arbitrarytask_arena
Fixes # - issue number(s) if exists
Type of change
Choose one or multiple, leave empty if none of the other choices apply
Add a respective label(s) to PR if you have permissions
Tests
Documentation
Breaks backward compatibility
Notify the following users
@aleksei-fedotov @alexandraepan
Other information