Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/main/tbb_userguide/Flow_Graph_resource_tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ in a flow graph.

../tbb_userguide/use_limiter_node
../tbb_userguide/use_concurrency_limits
../tbb_userguide/create_token_based_system
../tbb_userguide/create_token_based_system
../tbb_userguide/attach_flow_graph_to_arena
68 changes: 68 additions & 0 deletions doc/main/tbb_userguide/attach_flow_graph_to_arena.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.. _attach_flow_graph_to_arena:

Attach Flow Graph to an Arbitrary Task Arena
======================


|short_name| ``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 case, you may want to use mechanisms within a flow graph.

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.
Copy link
Contributor

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.

Copy link

Choose a reason for hiding this comment

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

Agree here

Copy link
Author

Choose a reason for hiding this comment

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

Updated with suggested changes.

Copy link

Choose a reason for hiding this comment

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

Suggested change
which is caused a task to be spawned.
that the task is spawned from.

Copy link
Author

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 example shows how to set the most performant core type as preferable for graph execution:
Copy link

Choose a reason for hiding this comment

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

Suggested change
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:

Copy link
Author

Choose a reason for hiding this comment

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

Updated with suggested changes.



::


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( [&]() {
graph g;
function_node< int > f( g, unlimited, []( int i ) {
/*the most performant core type is defined as preferred.*/
} );
f.try_put(1);
g.wait_for_all();
} );


A ``graph`` object can be reattached to a different ``task_arena`` by calling
the ``graph::reset()`` function. This reinitializes the ``graph`` and reattaches
Copy link

Choose a reason for hiding this comment

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

Suggested change
the ``graph::reset()`` function. This reinitializes the ``graph`` and reattaches
the ``graph::reset()`` function. It reinitializes and reattaches

it to the task arena instance, inside which the ``graph::reset()`` method is executed.
Copy link

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Author

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 example shows how reattach existing graph to an arena with the most performant core type
Copy link

Choose a reason for hiding this comment

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

Suggested change
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

Copy link
Author

Choose a reason for hiding this comment

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

Updated with suggested changes.

as preferable for work execution:
Copy link

Choose a reason for hiding this comment

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

Suggested change
as preferable for work execution:
as the preferred one for a work execution:

Copy link
Author

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();
Copy link
Contributor

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?

Copy link

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 :)

Copy link
Author

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


See the following topics to learn more.
Copy link

Choose a reason for hiding this comment

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

Suggested change
See the following topics to learn more.
See the following topics to learn more:

Copy link
Author

Choose a reason for hiding this comment

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

Updated with suggested changes.


.. toctree::
:maxdepth: 4

../tbb_userguide/Guiding_Task_Scheduler_Execution
../tbb_userguide/work_isolation