Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

question on task::spawn

andreyryabov
Beginner
120 Views
When I call task::spawn does It mean that some other thread can execute this just spawned task before I spawn any other sibling task? If not when tasks become eligible for execution?
0 Kudos
3 Replies
andreyryabov
Beginner
120 Views
I'm confused by an advice given on page 168 of Thread Building Blocks book. It says "Allocate all siblings before of them starat to run, unless you are using allocate_additional_child_of". How shold I understend it? And how to acheive it. tbb does not allow to control when tasks starts running.
Alexey_K_Intel3
Employee
120 Views
Quoting - andreyryabov
I'm confused by an advice given on page 168 of Thread Building Blocks book. It says "Allocate all siblings before of them starat to run, unless you are using allocate_additional_child_of". How shold I understend it? And how to acheive it. tbb does not allow to control when tasks starts running.

As soon as you spawn a task you have no control over when it starts running, so you might just assume it already runs, or even finished.

That advice in the book, however, is too strong. Actually you can mix task allocation and spawns, as long as you appropriately set the reference counter before spawning any sibling task. Read the TBB Reference document, chapter 8.8 "Catalog of Recommended Task Patterns" for more detailed information of how the TBBtasks are supposed to use.
andreyryabov
Beginner
120 Views

As soon as you spawn a task you have no control over when it starts running, so you might just assume it already runs, or even finished.

That advice in the book, however, is too strong. Actually you can mix task allocation and spawns, as long as you appropriately set the reference counter before spawning any sibling task. Read the TBB Reference document, chapter 8.8 "Catalog of Recommended Task Patterns" for more detailed information of how the TBBtasks are supposed to use.

Great!
Thank you!
Reply