-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Documentation for Task Group Dynamic Dependencies #1863
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
base: master
Are you sure you want to change the base?
Conversation
FYI, you accidentally checked in the try_put_and_wait binary. |
|
||
The |full_name| implementation extends the requirements for user-provided function object from | ||
`tbb::task_group specification <https://oneapi-spec.uxlfoundation.org/specifications/oneapi/latest/elements/onetbb/source/task_scheduler/task_group/task_group_cls>`_ | ||
to allow them to return a ``task_handle`` object. |
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 seems that task_group specification is silent on the return type of the user-provided function object. So "extends the requirements" doesn't seem right.
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 far as I understand the idea of named requirement and the return type is that if the specification says nothing about the return type means that any type can be returned, but will be ignored. So "extending" the named requirement means that the implementation will react if the handle is returned.
void run(task_handle&& handle); | ||
Schedules the task object associated with ``handle`` for execution, provided its dependencies are satisfied. |
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.
Schedules the task object associated with ``handle`` for execution, provided its dependencies are satisfied. | |
Schedules the task object associated with ``handle`` for execution when its dependencies are satisfied. |
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 "when" suggests that run
will schedule the task when the dependencies are satisfies. It can be interpreted as waiting for the dependencies to be satisfied and then schedule the task.
Or you believe that together with the following note the behavior is obvious?
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 the ", provided" version could be read as though the "run" function does nothing if the task object dependencies are not satisfied at the time of the call to run. But of course calling run does have an effect. It make the task available for dependency tracking, and ultimately execution once its dependencies are satisfied.
doc/main/reference/examples/task_group_extensions_bypassing.cpp
Outdated
Show resolved
Hide resolved
doc/main/reference/examples/task_group_extensions_bypassing.cpp
Outdated
Show resolved
Hide resolved
doc/main/reference/examples/task_group_extensions_reduction.cpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Mike Voss <[email protected]>
Co-authored-by: Mike Voss <[email protected]>
Co-authored-by: Mike Voss <[email protected]>
Co-authored-by: Mike Voss <[email protected]>
Co-authored-by: Mike Voss <[email protected]>
Co-authored-by: Alexey Kukanov <[email protected]>
Co-authored-by: Alexey Kukanov <[email protected]>
Co-authored-by: Alexey Kukanov <[email protected]>
Co-authored-by: Mike Voss <[email protected]>
…neapi-src/oneTBB into dev/kboyarinov/task-group-docs
`Task Bypassing <../tbb_userguide/Task_Scheduler_Bypass.html>`_ allows developers to reduce task scheduling overhead by providing a hint about | ||
which task should be executed next. | ||
|
||
Execution of the deferred task owned by a returned ``task_handle`` is not guaranteed to occur immediately, nor to be performed by the same thread. |
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 need to say something about the returned task being effectively scheduled for execution, so it must not be explicitly submitted. This is also important because of the difference with task dependencies, where a task must be explicitly submitted (or bypassed).
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 have added a note at the end of description.
template <typename RandomAccessIterator, typename Function> | ||
void parallel_for(RandomAccessIterator begin, RandomAccessIterator end, Function f) { |
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.
template <typename RandomAccessIterator, typename Function> | |
void parallel_for(RandomAccessIterator begin, RandomAccessIterator end, Function f) { | |
template <typename RandomAccessIterator, typename Function> | |
void for_each(RandomAccessIterator begin, RandomAccessIterator end, Function f) { |
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.
Renamed to parallel_for_each
since with the name for_each
it is challenging to test the function because of the ambiguity with std::for_each
.
tbb::task_group& tg; | ||
}; // struct for_task | ||
|
||
// Function accepts std::iterator_traits<RandomAccessIterator>::reference argument |
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 do not understand this comment; it seems to be incorrect.
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 was part of the original example. Removed.
doc/main/reference/examples/task_group_extensions_bypassing.cpp
Outdated
Show resolved
Hide resolved
.. code:: cpp | ||
bool operator==(const task_completion_handle& t, std::nullptr_t) noexcept; | ||
*Returns*: ``true`` if ``t`` does not reference any task; otherwise, ``false``. |
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 combine with the other operator==
that only differs by the order of parameters?
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
.. code:: cpp | ||
bool operator!=(const task_completion_handle& t, std::nullptr_t) noexcept; | ||
Equivalent to ``!(t == nullptr)``. |
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.
Ditto.
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
.. code:: cpp | ||
~task_handle(); | ||
Destroys the ``task_handle`` object and its associated task, if any. | ||
If the associated task is involved in a predecessor-successor relationship, the behavior is undefined. |
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.
For the existing API, would it make sense to take the exact description from the spec in full, the modify and highlight the differences?
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.
Co-authored-by: Alexey Kukanov <[email protected]>
Co-authored-by: Alexey Kukanov <[email protected]>
Co-authored-by: Alexey Kukanov <[email protected]>
Co-authored-by: Alexey Kukanov <[email protected]>
Co-authored-by: Alexey Kukanov <[email protected]>
Description
Add a comprehensive description of proposed changes
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