Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Successor or predecessor

Nav
New Contributor I
539 Views
I'm getting really confused as to what the below paragraph means, so I'm assuming that the writer of the tutorial actually meant to write "predecessor" instead of "successor". Especially so, coz Figure 7 of the fibonacci example shows all task arrows pointing upward.

11.4 How Task Scheduling Works
The scheduler evaluates a task graph. The graph is a directed graph where each node
is a task. Each task points to its successor, which is another task that is waiting on it
to complete, or NULL. Method task::parent() gives you read-only access to the
successor pointer. Each task has a refcount that counts the number of tasks that have
it as a successor. The graph evolves over time.

So is it supposed to be "predecessor"?
0 Kudos
1 Solution
Alexey-Kukanov
Employee
539 Views
No, it's really supposed to be "successor", in the sense of a task that may start or continue execution only after the given task completes. The successortask can bethe predecessor as well, but it's less important in that context.

View solution in original post

0 Kudos
4 Replies
Alexey-Kukanov
Employee
540 Views
No, it's really supposed to be "successor", in the sense of a task that may start or continue execution only after the given task completes. The successortask can bethe predecessor as well, but it's less important in that context.
0 Kudos
Nav
New Contributor I
539 Views
Oh...got it! "successor" was to be considered in the order of execution, and not in the order of creation.
The leaf tasks get executed first.
I understand your mention of "The successortask can bethe predecessor as well" happens when a task is stolen by another thread.
0 Kudos
Alexey-Kukanov
Employee
539 Views
Quoting Nav
I understand your mention of "The successortask can bethe predecessor as well" happens when a task is stolen by another thread.


Actually stealing isorthogonal here.
I meant that the"parent" task can create "child" tasks, spawn those, and wait for their completion - in this case it's both predecessor and successor. However a parent task may as wellcreate a separate successor task that will execute after competion of children; we also call it "continuation task". In this case, the parent task is the predecessor for its children, and the continuation task is the successor. See section 11.5.2 "Continuation passing" in the Tutorial.

Also as you may guess from the above, "leaf tasks get executed first" is not totally correct as well. It's really a dynamic tree of tasks that create and spawn other tasks during the execution, and may or may not explicitly wait for completion of those.

0 Kudos
Nav
New Contributor I
539 Views
Honestly, it's quite a challenge visualising the concept even with the tutorial's examples; but your reply gave me a bit more headway into understanding how tasks work. Thanks.
0 Kudos
Reply