len3d

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

* Distribute tasks in a round-robin fashion.

* Required APIs:

void task::spawn_root_and_wait(taks&);
void task::spawn(task&);
void task::spawn_and_wait_for_all(task&);

Depth-first execution:
  * Strike when the cache is hot. The deepest tasks are the most recently created tasks, and therefore are

hottest in cache.
  * Minimize space. Depth-first execution creates nodes linearly.

Breadth-first execution:
  * Maximize parallelism.

Eah thread has its own task queue. When a thread spawns a task, it pushes it onto the bottom of its queue. (top:

oldest task, bottom: youngest task)

A thread continually executes a task obtained by the first rule below that applies:
1. Pop a task from the bottom of its own queue. This rule does not apply if the queue is empty. (depth-first

execution)
2. Steal a task from the top of another randomly chosen queue. If the chosen queue is empty, the thread tries

this rule again until it succeeds. (breadth-first execution)

posted on 2012-06-22 21:33  Len3d  阅读(566)  评论(4编辑  收藏  举报