Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

taskpool runs serial :(

Hello together,
Ive got a strange problem. My Code here spawns 100 tasks. After all tasks are finished it creates another 100 tasks. For some reason my runtime observations found out, that my tasks run not parallel but serial since the 2nd 100 tasks. So just the first initial code (the first if) create parallel tasks. the recreated tasks later on seem to run quiete serial with no speed bonus. You also can see, that the tasks finish one by one in a very constant time interval.
I create my taskpool with:

tbb::task_scheduler_init scheduler_init(2);

my first task is created with:

TaskItem& tmp = *new( tbb::task::allocate_root() ) TaskItem(NULL);

An here is my execute funtion:
Best regards
Matthias Thurau

0 Kudos
1 Reply
Valued Contributor II
My guess is that your code is just not generating enough work. The example spawns individual tasks in a for-loop and each of the tasks has little to do. So there might not be much more than serial activity going on. And limiting the thread pool to 2 means there's not much in the way of resources to get above serial performance. What happens if you actually make these tasks do a little work and have some duration?