The following table describes built-in functions to synchronize the work-items in a work-group.
For OpenCL C 2.0 or newer, as an alias for barrier:
For these functions, if any work-item in a work-group encounters a barrier, the barrier must be encountered by all work-items in the work-group before any are allowed to continue execution beyond the barrier.
If the barrier is inside a conditional statement, then all work-items in the work-group must enter the conditional if any work-item in the work-group enters the conditional statement and executes the barrier.
If the barrier is inside a loop, then all work-items in the work-group must execute the barrier on each iteration of the loop if any work-item executes the barrier on that iteration.
The barrier and work_group_barrier functions can specify which
memory operations become visible to the appropriate memory scope
identified by scope .
The flags argument specifies the memory address spaces.
This is a bitfield and can be set to 0 or a combination of the
following values OR’ed together.
When these flags are OR’ed together the barrier acts as a
combined barrier for all address spaces specified by the flags
ordering memory accesses both within and across the specified address
For barrier and the work_group_barrier variant that does not take a
memory scope, the scope is
The values of flags and scope must be the same for all work-items in the work-group.
For more information, see the OpenCL C Specification
This page is extracted from the OpenCL C Specification. Fixes and changes should be made to the Specification, not directly.