Task Scheduler Interfaces

The scheduler employs task stealing. Each thread keeps a ready pool of tasks that are ready to run. The ready pool is structured as an array of lists of tasks, where the list for the ith element corresponds to tasks at level i in the tree. The lists are manipulated in last-in, first-out order. A task at level i spawns child tasks at level i+1.A thread pulls tasks from the deepest nonempty list in the array. If there are no nonempty lists, the thread randomly steals a task from the shallowest list of another thread. A thread also implicitly steals if it completes the last child, in which case it starts executing the task that was waiting on the children.

The task scheduler tends to strike a good balance between locality of reference, space efficiency, and parallelism. The scheduling technique is similar to that used by Cilk, a research project that implements efficient, unfair scheduling (http://supertech.csail.mit.edu/cilk).

Get Intel Threading Building Blocks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.