Intel® C++ Compiler 16.0 User and Reference Guide
The keyword spelling is _Cilk_sync. The header file <cilk/cilk.h> defines macros that allow an alternative spelling (in this case, cilk_sync). This document uses the alternative spelling as defined in cilk.h.
The cilk_sync statement applies to a task block, which, in most cases, is a function. It indicates that the current function cannot continue in parallel with its spawned children, and must wait. After all the children complete, the current function can continue.
An exception to this is when the cilk_sync statement occurs in the body of a cilk_for loop. In this case, the cilk_sync applies only to child tasks spawned from inside the cilk_for loop and not from the same function outside the cilk_for body.
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 sync is needed 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.
The implicit cilk_sync occurs after destructors are invoked.