NVlabs/cub

Name: cub

Owner: NVIDIA Research Projects

Description: CUB is a flexible library of cooperative threadblock primitives and other utilities for CUDA kernel programming.

Created: 2013-02-15 20:01:28.0

Updated: 2018-01-09 08:43:43.0

Pushed: 2017-12-08 22:56:14.0

Homepage: nvlabs.github.com/cub/

Size: 16557

Language: Cuda

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README


About CUB

Current release: v1.7.5 (02/08/2018)

We recommend the CUB Project Website for further information and examples.

CUB provides state-of-the-art, reusable software components for every layer of the CUDA programming model:

Orientation of collective primitives within the CUDA software stack



A Simple Example

lude <cub/cub.cuh>

lock-sorting CUDA kernel
obal__ void BlockSortKernel(int *d_in, int *d_out)

 using namespace cub;

 // Specialize BlockRadixSort, BlockLoad, and BlockStore for 128 threads 
 // owning 16 integer items each
 typedef BlockRadixSort<int, 128, 16>                     BlockRadixSort;
 typedef BlockLoad<int, 128, 16, BLOCK_LOAD_TRANSPOSE>   BlockLoad;
 typedef BlockStore<int, 128, 16, BLOCK_STORE_TRANSPOSE> BlockStore;

 // Allocate shared memory
 __shared__ union {
     typename BlockRadixSort::TempStorage  sort;
     typename BlockLoad::TempStorage       load; 
     typename BlockStore::TempStorage      store; 
 } temp_storage; 

 int block_offset = blockIdx.x * (128 * 16);      // OffsetT for this block's ment

 // Obtain a segment of 2048 consecutive keys that are blocked across threads
 int thread_keys[16];
 BlockLoad(temp_storage.load).Load(d_in + block_offset, thread_keys);
 __syncthreads();

 // Collectively sort the keys
 BlockRadixSort(temp_storage.sort).Sort(thread_keys);
 __syncthreads();

 // Store the sorted segment 
 BlockStore(temp_storage.store).Store(d_out + block_offset, thread_keys);

Each thread block uses cub::BlockRadixSort to collectively sort its own input segment. The class is specialized by the data type being sorted, by the number of threads per block, by the number of keys per thread, and implicitly by the targeted compilation architecture.

The cub::BlockLoad and cub::BlockStore classes are similarly specialized.
Furthermore, to provide coalesced accesses to device memory, these primitives are configured to access memory using a striped access pattern (where consecutive threads simultaneously access consecutive items) and then transpose the keys into a blocked arrangement of elements across threads.

Once specialized, these classes expose opaque \p TempStorage member types.
The thread block uses these storage types to statically allocate the union of shared memory needed by the thread block. (Alternatively these storage types could be aliased to global memory allocations).



Stable Releases

CUB releases are labeled using version identifiers having three fields: epoch.feature.update. The epoch field corresponds to support for a major change in the CUDA programming model. The feature field corresponds to a stable set of features, functionality, and interface. The update field corresponds to a bug-fix or performance update for that feature set. At the moment, we do not publicly provide non-stable releases such as development snapshots, beta releases or rolling releases. (Feel free to contact us if you would like such things.) See the CUB Project Website for more information.



Contributors

CUB is developed as an open-source project by NVIDIA Research. The primary contributor is Duane Merrill.



Open Source License

CUB is available under the “New BSD” open-source license:

right (c) 2010-2011, Duane Merrill.  All rights reserved.
right (c) 2011-2018, NVIDIA CORPORATION.  All rights reserved.

stribution and use in source and binary forms, with or without
fication, are permitted provided that the following conditions are met:
  Redistributions of source code must retain the above copyright
  notice, this list of conditions and the following disclaimer.
  Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer in the
  documentation and/or other materials provided with the distribution.
  Neither the name of the NVIDIA CORPORATION nor the
  names of its contributors may be used to endorse or promote products
  derived from this software without specific prior written permission.

 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
ANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
LAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
CT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
LUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
NY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
LUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
WARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.