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

Creating tasks from native threads

Thomas_W_Intel
Employee
348 Views
Hello,

We want to use the TBB task scheduler in conjuction with native threads, for a sub-problem in an application that is already threaded otherwise. In particular, we will have several native threads that create tasks. These tasks should be processed by a global task scheduler.

From reading the TBB documentation, it is unclear to me, if for optimal performance, there should be a init object in each of the native threads that create tasks, or if we should use a global init object.

Kind regards
Thomas
0 Kudos
1 Reply
elhefe38
Beginner
348 Views
We want to use the TBB task scheduler in conjuction with native threads, for a sub-problem in an application that is already threaded otherwise. In particular, we will have several native threads that create tasks. These tasks should be processed by a global task scheduler.

From reading the TBB documentation, it is unclear to me, if for optimal performance, there should be a init object in each of the native threads that create tasks, or if we should use a global init object.



I recently ran into the same issue. You might want to have a look here
The short answer is that you need a task_scheduler_init object for each thread that uses tbb tasks (or "upper" classes such as parallel_for)
The good news is that the overhead introduced is very low (sub usecond on my test platform), provided you already created a task_scheduler_init at program start/dll load for instance.

regards
0 Kudos
Reply