-
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
Add documentation for parallel_phase feature #1646
Conversation
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>
with the following API: | ||
* Add enumeration class ``leave_policy`` to ``task_arena``. | ||
* Add ``leave_policy`` as the last parameter to ``task_arena`` constructors and ``task_arena::initialize`` methods. | ||
This allows to choose retention policy for worker threads in case when no more parallel work in the 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.
This allows to choose retention policy for worker threads in case when no more parallel work in the arena. | |
This allows you to define a retention policy for worker threads when no parallel work is in the 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.
I am not sure how to better state this but at the same time to not overwhelm documentation with lots of details. The idea is that the feature allows users to tell the scheduler, what policy to use when TBB's worker threads are going to leave task_arena
because they failed to find any 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.
maybe smth like: This feature allows you to inform the scheduler about the preferred policy for worker threads when they are about to leave task_arena due to a lack of available 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.
Updated.
Co-authored-by: Alexandra <alexandra.epanchinzeva@intel.com>
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.
Everything looks good just a couple of syntax errors to fix, and it will be good to go.
with the following API: | ||
* Add enumeration class ``leave_policy`` to ``task_arena``. | ||
* Add ``leave_policy`` as the last parameter to ``task_arena`` constructors and ``task_arena::initialize`` methods. | ||
This allows to choose retention policy for worker threads in case when no more parallel work in the 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 smth like: This feature allows you to inform the scheduler about the preferred policy for worker threads when they are about to leave task_arena due to a lack of available work.
Co-authored-by: Alexandra <alexandra.epanchinzeva@intel.com>
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
.. cpp:function:: scoped_parallel_phase::scoped_parallel_phatse(task_arena& ta, bool with_fast_leave = false) | ||
|
||
Constructs a ``scoped_parallel_phase`` object that starts a parallel phase in the specified ``task_arena``. | ||
If ``with_fast_leave`` is ``true``, the worker threads leave policy is temporarily set to ``fast``. |
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.
Do we need to specify the behavior if task_arena
was already initialized using fast
leave policy? It might not be clear to the reader. Although, there is this "temporarily" word which sort of indicates that the behavior returns back to the policy specified at arena's construction site.
Similar question to the description of end_parallel_phase
below.
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.
Added note about the effect of this setting with arena initialized with fast leave policy.
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.
How about referencing the corresponding RFC document from this file?
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.
Done.
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 links to the RFC and to the specification (are there other?) are not permanent and therefore will become obsolete someday. I suggest to put permanent links so that they stay relevant as long as possible.
==================================================================== | ||
|
||
.. note:: | ||
To enable this feature, set ``TBB_PREVIEW_PARALLEL_PHASE`` macro to 1. |
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 we should add, as suggested by Aleksei, a link to the RFC and request feedback on the feature. I'd suggest as part of this note. By putting the link here, we direct users to the RFC where they become aware of the exit conditions and what type of feedback we are seeking. That might drive more feedback.
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.
In the medium term, all preview features will have matching RFCs and so this can become a regular part of preview feature documentation.
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.
Added the link.
.. cpp:enum:: leave_policy::automatic | ||
|
||
When passed to a constructor or the ``initialize`` method, the initialized ``task_arena`` has | ||
default policy for worker threads. |
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.
default policy for worker threads. | |
default policy for worker thread retention. |
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.
Perhaps, "has the default (possibly system specific) policy for how quickly worker threads leave the arena when there is no more work available in the arena and when the arena is not in a parallel phase."
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.
Done.
|
||
When passed to a constructor or the ``initialize`` method, the initialized ``task_arena`` has | ||
policy to not retain worker threads in ``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.
I don't think "retention" or "retain" is defined anywhere. And I think we need to describe the effect within a phase and then between phases. For example, "to not retain worker threads" is not clear unless we say what we mean by retention. For sure, the arena retains the workers while there are active tasks to work on.
Maybe something like, "has policy that allows worker threads to more quickly leave the arena when there is no more work available in the arena and when the arena is not in a parallel phase."
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 suggested wording. I also added some notes on behavior when threads re-join the arena with no active parallel phases.
fast = /* unspecifed */, | ||
}; | ||
|
||
task_arena(int max_concurrency = automatic, unsigned reserved_for_masters = 1, |
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.
What about the copy constructor? It copies settings from the other arena, including the leave policy. I think this behavior should be stated somewhere?
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 API for the copy constructor is not changed, I think the only way to state that is to copy description from the spec and add info about the leave policy.
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.
Listed copy constructor in member functions.
Co-authored-by: Mike Voss <michaelj.voss@intel.com> Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
Signed-off-by: Isaev, Ilya <ilya.isaev@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.
Looks good to me!
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 links to the RFC and to the specification (are there other?) are not permanent and therefore will become obsolete someday. I suggest to put permanent links so that they stay relevant as long as possible.
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.
Looks go to me.
Description
Document parallel_phase and leave_policy extensions to
task_arena
in Developer Reference.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
List users with
@
to send notificationsOther information