template<
typename T,
int BLOCK_DIM_X,
int BLOCK_DIM_Y = 1,
int BLOCK_DIM_Z = 1,
int PTX_ARCH = CUB_PTX_ARCH>
class cub::BlockShuffle< T, BLOCK_DIM_X, BLOCK_DIM_Y, BLOCK_DIM_Z, PTX_ARCH >
The BlockShuffle class provides collective methods for shuffling data partitioned across a CUDA thread block.
- Template Parameters
-
T | The data type to be exchanged. |
BLOCK_DIM_X | The thread block length in threads along the X dimension |
BLOCK_DIM_Y | [optional] The thread block length in threads along the Y dimension (default: 1) |
BLOCK_DIM_Z | [optional] The thread block length in threads along the Z dimension (default: 1) |
PTX_ARCH | [optional] The PTX compute capability for which to to specialize this collective, formatted as per the CUDA_ARCH macro (e.g., 350 for sm_35). Useful for determining the collective's storage requirements for a given device from the host. (Default: the value of CUDA_ARCH during the current compiler pass) |
- Overview
- It is commonplace for blocks of threads to rearrange data items between threads. The BlockShuffle abstraction allows threads to efficiently shift items either (a) up to their successor or (b) down to their predecessor.
|
|
__device__ __forceinline__ | BlockShuffle () |
| Collective constructor using a private static allocation of shared memory as temporary storage. More...
|
|
__device__ __forceinline__ | BlockShuffle (TempStorage &temp_storage) |
| Collective constructor using the specified memory allocation as temporary storage. More...
|
|
|
__device__ __forceinline__ void | Offset (T input, T &output, int distance=1) |
| Each threadi obtains the input provided by threadi+distance . The offset distance may be negative. More...
|
|
__device__ __forceinline__ void | Rotate (T input, T &output, unsigned int distance=1) |
| Each threadi obtains the input provided by threadi+distance . More...
|
|
template<int ITEMS_PER_THREAD> |
__device__ __forceinline__ void | Up (T(&input)[ITEMS_PER_THREAD], T(&prev)[ITEMS_PER_THREAD]) |
| The thread block rotates its blocked arrangement of input items, shifting it up by one item. More...
|
|
template<int ITEMS_PER_THREAD> |
__device__ __forceinline__ void | Up (T(&input)[ITEMS_PER_THREAD], T(&prev)[ITEMS_PER_THREAD], T &block_suffix) |
| The thread block rotates its blocked arrangement of input items, shifting it up by one item. All threads receive the input provided by threadBLOCK_THREADS-1 . More...
|
|
template<int ITEMS_PER_THREAD> |
__device__ __forceinline__ void | Down (T(&input)[ITEMS_PER_THREAD], T(&prev)[ITEMS_PER_THREAD]) |
| The thread block rotates its blocked arrangement of input items, shifting it down by one item. More...
|
|
template<int ITEMS_PER_THREAD> |
__device__ __forceinline__ void | Down (T(&input)[ITEMS_PER_THREAD], T(&prev)[ITEMS_PER_THREAD], T &block_prefix) |
| The thread block rotates its blocked arrangement of input items, shifting it down by one item. All threads receive input [0] provided by thread0 . More...
|
|
template<typename T , int BLOCK_DIM_X, int BLOCK_DIM_Y = 1, int BLOCK_DIM_Z = 1, int PTX_ARCH = CUB_PTX_ARCH>
template<int ITEMS_PER_THREAD>
__device__ __forceinline__ void cub::BlockShuffle< T, BLOCK_DIM_X, BLOCK_DIM_Y, BLOCK_DIM_Z, PTX_ARCH >::Up |
( |
T(&) |
input[ITEMS_PER_THREAD], |
|
|
T(&) |
prev[ITEMS_PER_THREAD] |
|
) |
| |
|
inline |
The thread block rotates its blocked arrangement of input
items, shifting it up by one item.
- Assumes a blocked arrangement of (block-threads*items-per-thread) items across the thread block, where threadi owns the ith range of items-per-thread contiguous items. For multi-dimensional thread blocks, a row-major thread ordering is assumed.
- Efficiency is increased with increased granularity
ITEMS_PER_THREAD
. Performance is also typically increased until the additional register pressure or shared memory allocation size causes SM occupancy to fall too low. Consider variants of cub::BlockLoad for efficiently gathering a blocked arrangement of elements across threads.
- A subsequent
__syncthreads()
threadblock barrier should be invoked after calling this method if the collective's temporary storage (e.g., temp_storage
) is to be reused or repurposed.
- Parameters
-
[in] | input | The calling thread's input items |
[out] | prev | The corresponding predecessor items (may be aliased to input ). The item prev [0] is not updated for thread0. |
template<typename T , int BLOCK_DIM_X, int BLOCK_DIM_Y = 1, int BLOCK_DIM_Z = 1, int PTX_ARCH = CUB_PTX_ARCH>
template<int ITEMS_PER_THREAD>
__device__ __forceinline__ void cub::BlockShuffle< T, BLOCK_DIM_X, BLOCK_DIM_Y, BLOCK_DIM_Z, PTX_ARCH >::Up |
( |
T(&) |
input[ITEMS_PER_THREAD], |
|
|
T(&) |
prev[ITEMS_PER_THREAD], |
|
|
T & |
block_suffix |
|
) |
| |
|
inline |
The thread block rotates its blocked arrangement of input
items, shifting it up by one item. All threads receive the input
provided by threadBLOCK_THREADS-1
.
- Assumes a blocked arrangement of (block-threads*items-per-thread) items across the thread block, where threadi owns the ith range of items-per-thread contiguous items. For multi-dimensional thread blocks, a row-major thread ordering is assumed.
- Efficiency is increased with increased granularity
ITEMS_PER_THREAD
. Performance is also typically increased until the additional register pressure or shared memory allocation size causes SM occupancy to fall too low. Consider variants of cub::BlockLoad for efficiently gathering a blocked arrangement of elements across threads.
- A subsequent
__syncthreads()
threadblock barrier should be invoked after calling this method if the collective's temporary storage (e.g., temp_storage
) is to be reused or repurposed.
- Parameters
-
[in] | input | The calling thread's input items |
[out] | prev | The corresponding predecessor items (may be aliased to input ). The item prev [0] is not updated for thread0. |
[out] | block_suffix | The item input [ITEMS_PER_THREAD-1] from threadBLOCK_THREADS-1 , provided to all threads |
template<typename T , int BLOCK_DIM_X, int BLOCK_DIM_Y = 1, int BLOCK_DIM_Z = 1, int PTX_ARCH = CUB_PTX_ARCH>
template<int ITEMS_PER_THREAD>
__device__ __forceinline__ void cub::BlockShuffle< T, BLOCK_DIM_X, BLOCK_DIM_Y, BLOCK_DIM_Z, PTX_ARCH >::Down |
( |
T(&) |
input[ITEMS_PER_THREAD], |
|
|
T(&) |
prev[ITEMS_PER_THREAD] |
|
) |
| |
|
inline |
The thread block rotates its blocked arrangement of input
items, shifting it down by one item.
- Assumes a blocked arrangement of (block-threads*items-per-thread) items across the thread block, where threadi owns the ith range of items-per-thread contiguous items. For multi-dimensional thread blocks, a row-major thread ordering is assumed.
- Efficiency is increased with increased granularity
ITEMS_PER_THREAD
. Performance is also typically increased until the additional register pressure or shared memory allocation size causes SM occupancy to fall too low. Consider variants of cub::BlockLoad for efficiently gathering a blocked arrangement of elements across threads.
- A subsequent
__syncthreads()
threadblock barrier should be invoked after calling this method if the collective's temporary storage (e.g., temp_storage
) is to be reused or repurposed.
- Parameters
-
[in] | input | The calling thread's input items |
[out] | prev | The corresponding predecessor items (may be aliased to input ). The value prev [0] is not updated for threadBLOCK_THREADS-1. |
template<typename T , int BLOCK_DIM_X, int BLOCK_DIM_Y = 1, int BLOCK_DIM_Z = 1, int PTX_ARCH = CUB_PTX_ARCH>
template<int ITEMS_PER_THREAD>
__device__ __forceinline__ void cub::BlockShuffle< T, BLOCK_DIM_X, BLOCK_DIM_Y, BLOCK_DIM_Z, PTX_ARCH >::Down |
( |
T(&) |
input[ITEMS_PER_THREAD], |
|
|
T(&) |
prev[ITEMS_PER_THREAD], |
|
|
T & |
block_prefix |
|
) |
| |
|
inline |
The thread block rotates its blocked arrangement of input items, shifting it down by one item. All threads receive input
[0] provided by thread0
.
- Assumes a blocked arrangement of (block-threads*items-per-thread) items across the thread block, where threadi owns the ith range of items-per-thread contiguous items. For multi-dimensional thread blocks, a row-major thread ordering is assumed.
- Efficiency is increased with increased granularity
ITEMS_PER_THREAD
. Performance is also typically increased until the additional register pressure or shared memory allocation size causes SM occupancy to fall too low. Consider variants of cub::BlockLoad for efficiently gathering a blocked arrangement of elements across threads.
- A subsequent
__syncthreads()
threadblock barrier should be invoked after calling this method if the collective's temporary storage (e.g., temp_storage
) is to be reused or repurposed.
- Parameters
-
[in] | input | The calling thread's input items |
[out] | prev | The corresponding predecessor items (may be aliased to input ). The value prev [0] is not updated for threadBLOCK_THREADS-1. |
[out] | block_prefix | The item input [0] from thread0 , provided to all threads |