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

Thread Pool in TBB

csv610
Beginner
409 Views

Hello,

I wanted to know whether TBB uses thread pool. In one of my applications I am
calling parallel_for for large number of times so I wanted to know if threads are
created during initialization or when parallel_for is called ?

Thanks,
Chaman Singh Verma
Poona, India

0 Kudos
1 Reply
robert-reed
Valued Contributor II
409 Views
Yes, Intel TBB does use a thread pool. The default number of threads added for that pool is one less than the number of Processing Elements available on the system so that with the creating thread, the pool comprises one thread per PE. This pool size can be overridden when a TBB program creates its task_scheduler_init object. Threads in this pool persist until the task_scheduler_init object is destroyed. To avoid thread pool thrashing (creation, destruction and recreation of the pool), you should create the task_scheduler_init object at a place in your code where its lifetime will span any TBB parallel constructs that may be invoked during execution.
Reply