The cilk_sync statement indicates that the current function cannot continue in parallel with its spawned children. After the children all complete, the current function can continue.
The syntax is as follows:
cilk_sync;
cilk_sync only syncs with children spawned by this function. Children of other functions are not affected.
There is an implicit cilk_sync at the end of every function and every try block that contains a cilk_spawn. The implicit cilk_sync occurs after destructors are invoked. The semantic is defined this way for these reasons:
To ensure that program resource use does not grow out of proportion to the program's parallelism.
To ensure that a race-free parallel program has the same behavior as the corresponding serial program. An ordinary non-spawn call to a function works the same regardless of whether the called function spawns internally.
There will be no strands left running that might have side effects or fail to free resources.
The called function will have completed all operations when it returns.
Copyright © 1996-2011, Intel Corporation. All rights reserved.