I want the for-loop to run in parallel (using TBB) over a set of blocks, where each block will be processed using a function provided by the user. I usually do this with tbb::parallel_for() . For various reasons, I want to limit the number of threads processing blocks to a given number, name it j . I usually did this with tbb::task_scheduler_init(j) .
However, I would like the user to be able to use TBB, and in particular to allow the functions provided by the user to use many cores. Therefore, I think tbb::task_scheduler_init() missing. The only solution I see is to allow the user to call tbb::task_scheduler_init() (or ignore it all together) and just include j instances of tbb::tbb_thread their own in a regular for-loop. Did I miss something? Is there a more natural way to do this in TBB? Is there any hierarchical version of tbb::task_scheduler_init() ?
source share