Work-groups have several properties, limitations and work-items:
- Properties of work-groups
- Work-groups are independent of each other.
- The OpenCL driver can issue multiple work-groups for execution in parallel.
- The work-items in a work-group can communicate with each other using shared data buffers. You must synchronize access to these buffers.
- Limitations between work-groups
Work-groups typically do not directly share data. They can share data using global memory.
The following are not supported across different work-groups:
Global atomics are available but these can be slower than local atomics.
- Work-items in a work-group
The work-items in a work-group can:
- Access shared memory.
- Use local atomic operations.
Perform barrier operations to synchronize execution points.
barrier(CLK_LOCAL_MEM_FENCE); // Wait for all work-items in // this work-group to catch up
After the synchronization is complete, all writes to shared buffers are guaranteed to have been completed. It is then safe for work-items to read data written by different work-items within the same work-group.