Community
cancel
Showing results for 
Search instead for 
Did you mean: 
zweistein
Beginner
45 Views

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);
tmp.addScheduler(m_Scheduler.get());
tbb::task::spawn_root_and_wait(tmp);

An here is my execute funtion:
Best regards
Matthias Thurau


0 Kudos
1 Reply
robert-reed
Valued Contributor II
45 Views

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?
Reply