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

New in this parallel thing.

morle
Beginner
439 Views
Hi,

I'm basically a beginner in this world of parallel computing. I've reading the tutorial and I have a question concerning tasks.

Having a root task, two child tasks and a continuation task, do the root and the continuation tasks run with a single thread each or they can be executed with, for example, two threads?

Thanks.

0 Kudos
4 Replies
morle
Beginner
439 Views
I mean, do the root task, and the continuation task once the childs have finished, execute concurrently or do they run serially, while the childs are executed in parallel?
0 Kudos
RafSchietekat
Valued Contributor III
439 Views
If the root and continuation tasks are separate (not using recycle_as_continuation), they may indeed execute concurrently. What do you have in mind?
0 Kudos
morle
Beginner
439 Views
I thought that the root and continuation task would be executed with one thread each only, while the child tasks would be executed with various threads, if available.

So the root and continuation tasks can be executed with more than a thread each, can't they?

Thanks a lot!
0 Kudos
RafSchietekat
Valued Contributor III
439 Views
Concurrently means that the original parent and its continuation could be executing at the same time, each in its own thread.

Note that the continuation will follow all the child tasks, and each of them only gets executed after it was spawned, so the overlap is only partial, and you probably wouldn't do anything substantial in the original parent after spawning the children.

(Note that "one thread each" and "more than a thread each" mean something else than what I think you intend.)

P.S.: I should probably have referred to recycle_as_safe_continuation() above, instead of just recycle_as_continuation().
0 Kudos
Reply