what the advantages and disadvantages of Continuation-passing Style and Blocking Style in fork/join parallelism in Intel TBB?
1 Answers
The continuation-passing style guarantees certain theoretical space and time bounds that the blocking style does not.
In the blocking style, if a parent task creates some child tasks, the parent task is blocked until all its child tasks complete AND the thread bound to the stack is available. If the thread executing the parent is waiting on child tasks, at best it can go help some some other thread, but then the thread it is helping may get stuck in a similar waiting game. Space bounds are hurt because these stuck tasks eat up stack space.
The continuation style decouples threads from stacks, so that after the children complete, the parent task can immediately continue executing. Since it's not bound to a stack, the thread that completes the last child takes up execution of the continuation of the parent task.
Some references:
http://open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3872.pdf . Continuation-passing in TBB allows the "greedy continuation stealing" described there.
https://www.cse.wustl.edu/~angelee/home_page/papers/stacks.pdf . Continuation-passing is essentially "Strategy 1: Recompile everything", except it's the programmer who has to do for TBB what the Cilk compiler would do for Cilk.

- 3,829
- 2
- 16
- 26