Dimension 1 of nd - range ——> | dimension 0 of| nd-range | |
Divided into four work groups each work group has work-items work-items in same workgroup have additional scheduling guarantees
Synchronization via Barriers
Two main purposes
- Syncs execution of work-items in a work group.
- Syncs how each work item vies memory.
Enforcing memory consistency/ fencing memory.
Notes
- Isn’t on by default because expensive to implement.
- All work-items in the group have barriers or none else others would be waiting.
- Collective Function is the one executed by all work-ites in a group.
Work Group Local Memory
Same concept as global and local memory if you think about it the local memory can be ram and global can be ssd if we go a bit down it can be l1 l2 cache. Ends when work group ends.
Some devices have it only as a software abstraction so it’s just convenience whereas other devices implement it hardware level we have to take care of that.
Local Memory in ND Range
Local Accessors
-> declared within command group handler should always be read_write because as it’s short term and kernel needs a way to assign
Synchronization Functions
group_barrier explicit scope isn’t required default scope is mostly good as determined by the function to make sure all work items have finished a phase.
Sub Groups
Example of sub group similar barriers as work itenms for groups.
NOTES
subgroups don’t have specific local memory like groups they work with collective functions
[=](nd_item<1> item){}
auto sg = item.get_sub_group();
}
group_barrier(sg);
Examples of collective functions for subgroup Communication
BroadCast Votes Shuffle
- group_broadcast() -> One work-item to all
- any_of_group(), all_of_group(), none_of_group() (Votes)
- joint_any_of(), joint_all_of(), joint_none_of() (Over a range)
- select_from_group(), shift_group_left(), shift_group_right() (shuffle)
- permute_group_by_xor() -> work item’s subgroups local id and a constant
Shuffle ability to communicate directly within subgroup since they are very specialized they are only available for subgroups.