Querring for number of threads in TBB

Querring for number of threads in TBB


In my application, I am specifying grainsize for parallel_for:blocked_range, which depends upon number of available/working threads. I specify number of threads by

task_scheduler_init initTBB(nthreads);

But during program execution, I want to confirm there are "nthreads" running, so is there any function/API that returns number of threads TBB has created?

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Akhal,

TBB always creates nthreads passed to task_scheduler_init. So there is no need to ensure how many worker threads are created if you specified it explicitly.
In run time TBB scheduler manages tasks executed by the worker threads. If there is no enough job for some threads they will wait inactively. So the number of created threads is constant, but number of active worker threads at the moment is variable. Intention is to leave TBB runtime tobalance loadbetweenthe worker threads and manage number of worker threads at the moment.


Leave a Comment

Please sign in to add a comment. Not a member? Join today