-
Notifications
You must be signed in to change notification settings - Fork 630
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
Tasking module #5436
Tasking module #5436
Conversation
CI MESSAGE: [14339349]: BUILD STARTED |
CI MESSAGE: [14339349]: BUILD PASSED |
CI MESSAGE: [14358187]: BUILD STARTED |
CI MESSAGE: [14358187]: BUILD FAILED |
CI MESSAGE: [14358187]: BUILD PASSED |
|
||
/** An intrusive list of tasks | ||
* | ||
* This list uses tasks' built-in next and prev fields. |
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.
Can you describe a convention in this list. What is the head, tail, next and prev.
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 thought these were the most common names used in doubly-linked lists...
Saying that head_
denotes list's head doesn't improve anything - and the names in the comments can only go stale.
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.
Sometimes head can point to itself if it is empty (we have an empty root that you cannot remove), or just be empty. That is what I mean.
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Add documentation for Releasable::Release. Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Improved documentation for Task body function. Removed obsolete argument from usage examples. Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
CI MESSAGE: [14452363]: BUILD STARTED |
CI MESSAGE: [14452363]: BUILD PASSED |
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
CI MESSAGE: [14476068]: BUILD STARTED |
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
CI MESSAGE: [14478063]: BUILD STARTED |
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
CI MESSAGE: [14482229]: BUILD STARTED |
CI MESSAGE: [14482229]: BUILD PASSED |
CI MESSAGE: [14538855]: BUILD STARTED |
CI MESSAGE: [14538855]: BUILD FAILED |
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
CI MESSAGE: [14541090]: BUILD STARTED |
CI MESSAGE: [14541090]: BUILD PASSED |
Category:
New feature (non-breaking change which adds functionality)
Description:
Tasking module
dali::tasking
is a task execution engine which supports inter-task dependencies, semaphores and data passing.Main concepts of the tasking API are:
Main components
A
Task
is alsoWaitable
- that is, a task can depend on the completion of other task(s).There are two kinds of
Waitable
objects - completion events and releasable objects.A
CompletionEvent
(e.g. Task) is an object which remains acquirable after it's "completed". Performing Acquire operation on it does not alter the state of the object.A
Semaphore
can be externally released (it'sReleasable
), butAcquire
lowers the semaphore count, so the number of tasks that can acquire a semaphore before it's released is limited.Acquisition of
Waitable
objects on behalf of waiting tasks is the duty of theScheduler
. By contrast,Release
operation onReleasable
objects can be performed in any context.Data passing
Data can be passed between tasks. It's wrapped in a
TaskResult
type which stores either the value asstd::any
or the error asstd::exception_ptr
. An attempt to access the value with an exception present results in the exception being rethrown.A
Task
wraps a function taking 0 or 1 argument (in the latter case it's this-like pointer to theTask
) and returning a value of values.Upon creation of the task, the caller defines the number of return values. There are two options:
std::any
. If the task returnsstd::any
, it's stripped and the stored value is copied.tuple
.A
Task
canSubscribe
to the result of a producer task (which has to be done before the producer is submitted to the scheduler). The result can be obtained by callingtask->GetInputValue<T>(index)
Obtaining results
When a task is added to the scheduler, a
TaskFuture
object can be obtained.Scheduler::AddSilentTask
should be used if the result of the task is not needed. CallingTaskFuture::Value
will wait for the task to complete and return the value produced by the task (or rethrow the exception).Error handling
All errors thrown by the task functions are stored in the task results. An attempt to obtain results of a task that threw an exception will result in the exception being rethrown.
Additional information:
Usage with time dependencies only:
Usage with data dependencies
Affected modules and functionalities:
All new code.
Key points relevant for the review:
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: DALI-3934