The shuffle functions perform arbitrary communication between pairs of work-items in a sub-group. Common patterns, such as shifting all values in a sub-group by a fixed number of work-items, are exposed as specialized shuffles that may be accelerated in hardware.
Member function | Description |
---|---|
template <typename T> T shuffle(T x, id<1> local_id) const |
Exchanges values of x between work-items in the sub-group in an arbitrary pattern. Returns the value of x from the work-item with the specified id. The value of local_id must be between 0 and the sub-group size. |
template <typename T> T shuffle_down(T x, uint32_t delta) const |
Exchanges values of x between work-items in the sub-group via a shift. Returns the value of x from the work-item whose id is delta larger than the calling work-item. The value returned when the result of id + delta is greater than or equal to the sub-group size is undefined. |
template <typename T> T shuffle_up(T x, uint32_t delta) const |
Exchanges values of x between work-items in the sub-group via a shift. Returns the value of x from the work-item whose id is delta smaller than the calling work-item. The value returned when the result of id − delta is less than zero is undefined. |
template <typename T> T shuffle_xor(T x, id<1> mask) const |
Exchanges pairs of values of x between work-items in the sub-group. Returns the value of x from the work-item whose id is equal to the exclusive-or of the calling work-item's id and mask. mask must be a compile-time constant value that is the same for all work-items in the sub-group. |