Information on TBB Scheduler and Task Stealing
Hi all,
I am trying to get some information on the details of the TBB scheduler code in task.cpp. I basically want to profile how well the random task scheduler performs by tracking each instance of a false negative -- that is, one thread tries to steal a task from another randomly selected task queue, and fails to do so despite the fact that other task queues in fact do have tasks available.
Tracking this behavior boils down to maintaing an occupancy status per taskpool which gets modified on every task insertion and deletion. Looking through the code, I think that void GenericScheduler::spawn( task& first, task*& next ) sees the insertion of a task in the relevant queue. Therefore, I have inserted a counter increment at:
if( arena_slot==&dummy_slot ) { try_enter_arena(); __TBB_ASSERT( arena_slot->steal_end&1, NULL ); } else { acquire_task_pool(); GATHER_STATISTIC(acquire_task++); }
TaskPool* tp = dummy_slot.task_pool; next = tp->array[d]; tp->array[d] = &first;
#ifdef(MY_COUNTER) counter++ #endif
Similarly, it seems that there are two points where the tasks are removed from the task pool. The first is in
task* GenericScheduler::get_task( depth_type d ) called by the main scheduler loop wait_for_all. The second point is when a task is actually stolen which is in
task* GenericScheduler::steal_task( UnpaddedArenaSlot& arena_slot, depth_type d ) {
...
TaskPool* tp = arena_slot.task_pool; depth_type i = tp->prefix().steal_begin; if( i<d ) i = d; for(; i<=steal_end>>1; ++i ) {
if( result = tp->array[i] ) {
tp->array[i] = result->prefix().next;
#ifdef(MY_COUNTER) counter-- #endif
...
}
Unfortunately, just tracking these points do not suffice as my queue occupancies become negative. It therefore seems that I have missed some points in the code where tasks are added. Does anyone know where these additional points might be and where I should look for them?
Thanks!
|