cuda-kat
CUDA kernel author's tools
Macros | Functions
shuffle.cuh File Reference

Templated warp-shuffle operation variants. More...

#include <kat/on_device/common.cuh>
#include "detail/shuffle.cuh"

Functions

template<typename T >
KAT_FD T kat::shuffle_arbitrary (const T &t, int source_lane)
 Have each lane in a warp get a value from an (arbitrary) other lane. More...
 
template<typename T >
KAT_FD T kat::shuffle_down (const T &t, unsigned int delta)
 
template<typename T >
KAT_FD T kat::shuffle_up (const T &t, unsigned int delta)
 
template<typename T >
KAT_FD T kat::shuffle_xor (const T &t, int mask)
 Have pairs of lanes exchange a value, with the pairing performed by XORing bits of the lane index. More...
 

Detailed Description

Templated warp-shuffle operation variants.

Function Documentation

§ shuffle_arbitrary()

template<typename T >
KAT_FD T kat::shuffle_arbitrary ( const T &  t,
int  source_lane 
)

Have each lane in a warp get a value from an (arbitrary) other lane.

Template Parameters
Tthe type of datum to be shared with other lane(s); may be of arbitrary size, but (at least for now) must be plain-old-data.
Parameters
tEach lane shares own value, which other lanes can choose to receive.
source_laneThe lane whose value the current lane wants to get
Returns
the t value of source_lane

§ shuffle_down()

template<typename T >
KAT_FD T kat::shuffle_down ( const T &  t,
unsigned int  delta 
)
Parameters
tEach lane shares own value, which a lane with a higher index will get.
deltaThe difference in lane index to the source lane of the new value, i.e. a lane with index i gets the new value from lane i + delta.
Returns
The t value of the lane with index delta less than the calling lane's; a lane with a high index, above warp_size - delta, has its own t returned unchanged.

§ shuffle_up()

template<typename T >
KAT_FD T kat::shuffle_up ( const T &  t,
unsigned int  delta 
)
Template Parameters
Tthe type of datum to be shared with other lane(s); may be of arbitrary size, but (at least for now) must be plain-old-data.
Parameters
tEach lane shares own value, which a lane with a lower index will get.
deltaThe difference in lane index to the source lane of the new value, i.e. a lane with index i gets the new value from the lane of index i - delta.
Returns
The t value of the lane with index delta less than the calling lane's; a lane with a low index, under delta, has its own t returned unchanged.

§ shuffle_xor()

template<typename T >
KAT_FD T kat::shuffle_xor ( const T &  t,
int  mask 
)

Have pairs of lanes exchange a value, with the pairing performed by XORing bits of the lane index.

Template Parameters
Tthe type of datum to be shared with other lane(s); may be of arbitrary size, but (at least for now) must be plain-old-data.
Parameters
tThe value to exchange with a counterpart lane
maskDetermines how lanes will be paired: The lane with index i is paired with the lane with index i ^ mask.
Returns
The t value of the paired lane