dimanche 3 juillet 2016

TBB thread pool unexpectedly increasing


We have a piece of code that utilises TBB to spawn tasks to perform some processing this is done using the following TBB code to initialise the TBB thread pool:

tbb::task_scheduler_init(8);

Then for each task we want to spawn we use the following code (where MainTask is derived from the tbb::task class):

task = new (tbb::task::allocate_root()) MainTask(theAction, theOutputData);
tbb::task::enqueue(*task);

When we run our code we start off with a thread pool that is the same as the number of cores (in our case 8 threads) as expected but as the program executes and spawns new TBB tasks, as described above, the number of threads at some random points suddenly increase. After 40 minutes of program execution the thread count increases from 8 to 15 between.

Why is this happening? Shouldn’t TBB keep the number of worker threads fixed to equal the number of cores?


Aucun commentaire:

Enregistrer un commentaire