Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Alexandru_I_
Beginner
22 Views

Task stealing: reasons for failure

Hi

I am trying to understand which are the reasons (all of them) why a task stealing operation could fail in TBB. From what I manage to understand so far, the receive_or_steal_task method of the custom_scheduler class is where "the magic happens". In this method, there is an infinite loop that breaks for several reasons:

  1. if completion_ref_count == 1. I was unable to understand when or why this situation occurs
  2. if the current arena is required to relinquish some threads. Because the current thread has an empty task queue, it will be relinquished by the current arena and the market will reassign it to a different arena
  3. if the stealing operations succeeds
  4. if the stealing fails but an orphan task was found and reloaded
  5. if the stealing fails many times (failure_count>=yield_threshold+100) meaning that there is no work to steal in the current arena and the current thread will be relinquished

Am I correct about all the above? Are there any other reasons why the stealing operation could fail? Can anyone give some details about the completion_ref_count == 1 situation?

Alexandru

0 Kudos
1 Reply
RafSchietekat
Black Belt
22 Views

"completion_ref_count == 1" corresponds to the extra reference you have to specify in wait_for_all() or similar.

Reply