IOT>> cub>> 返回
项目作者: NVIDIA

项目描述 :
Cooperative primitives for CUDA C++.
高级语言: Cuda
项目地址: git://github.com/NVIDIA/cub.git
创建时间: 2013-02-15T20:01:28Z
项目社区:https://github.com/NVIDIA/cub

开源协议:BSD 3-Clause "New" or "Revised" License

下载


:warning: The CUB repository has been archived and is now part of the unified nvidia/cccl repository. See the announcement here for more information. Please visit the new repository for the latest updates. :warning:


About CUB

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

CUB is included in the NVIDIA HPC SDK and the CUDA Toolkit.

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



A Simple Example

  1. #include <cub/cub.cuh>
  2. // Block-sorting CUDA kernel
  3. __global__ void BlockSortKernel(int *d_in, int *d_out)
  4. {
  5. using namespace cub;
  6. // Specialize BlockRadixSort, BlockLoad, and BlockStore for 128 threads
  7. // owning 16 integer items each
  8. typedef BlockRadixSort<int, 128, 16> BlockRadixSort;
  9. typedef BlockLoad<int, 128, 16, BLOCK_LOAD_TRANSPOSE> BlockLoad;
  10. typedef BlockStore<int, 128, 16, BLOCK_STORE_TRANSPOSE> BlockStore;
  11. // Allocate shared memory
  12. __shared__ union {
  13. typename BlockRadixSort::TempStorage sort;
  14. typename BlockLoad::TempStorage load;
  15. typename BlockStore::TempStorage store;
  16. } temp_storage;
  17. int block_offset = blockIdx.x * (128 * 16); // OffsetT for this block's ment
  18. // Obtain a segment of 2048 consecutive keys that are blocked across threads
  19. int thread_keys[16];
  20. BlockLoad(temp_storage.load).Load(d_in + block_offset, thread_keys);
  21. __syncthreads();
  22. // Collectively sort the keys
  23. BlockRadixSort(temp_storage.sort).Sort(thread_keys);
  24. __syncthreads();
  25. // Store the sorted segment
  26. BlockStore(temp_storage.store).Store(d_out + block_offset, thread_keys);
  27. }

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 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).



Supported Compilers

CUB is regularly tested using the specified versions of the following
compilers. Unsupported versions may emit deprecation warnings, which can be
silenced by defining CUB_IGNORE_DEPRECATED_COMPILER during compilation.

  • NVCC 11.0+
  • GCC 5+
  • Clang 7+
  • MSVC 2019+ (19.20/16.0/14.20)



Releases

CUB is distributed with the NVIDIA HPC SDK and the CUDA Toolkit in addition
to GitHub.

See the changelog for details about specific releases.

CUB Release Included In
2.0.1 CUDA Toolkit 12.0
2.0.0 TBD
1.17.2 TBD
1.17.1 TBD
1.17.0 TBD
1.16.0 TBD
1.15.0 NVIDIA HPC SDK 22.1 & CUDA Toolkit 11.6
1.14.0 NVIDIA HPC SDK 21.9
1.13.1 CUDA Toolkit 11.5
1.13.0 NVIDIA HPC SDK 21.7
1.12.1 CUDA Toolkit 11.4
1.12.0 NVIDIA HPC SDK 21.3
1.11.0 CUDA Toolkit 11.3
1.10.0 NVIDIA HPC SDK 20.9 & CUDA Toolkit 11.2
1.9.10-1 NVIDIA HPC SDK 20.7 & CUDA Toolkit 11.1
1.9.10 NVIDIA HPC SDK 20.5
1.9.9 CUDA Toolkit 11.0
1.9.8-1 NVIDIA HPC SDK 20.3
1.9.8 CUDA Toolkit 11.0 Early Access
1.9.8 CUDA 11.0 Early Access
1.8.0
1.7.5 Thrust 1.9.2
1.7.4 Thrust 1.9.1-2
1.7.3
1.7.2
1.7.1
1.7.0 Thrust 1.9.0-5
1.6.4
1.6.3
1.6.2 (previously 1.5.5)
1.6.1 (previously 1.5.4)
1.6.0 (previously 1.5.3)
1.5.2
1.5.1
1.5.0
1.4.1
1.4.0
1.3.2
1.3.1
1.3.0
1.2.3
1.2.2
1.2.0
1.1.1
1.0.2
1.0.1
0.9.4
0.9.2
0.9.1
0.9.0



Development Process

CUB and Thrust depend on each other. It is recommended to clone Thrust
and build CUB as a component of Thrust.

CUB uses the CMake build system to build unit tests,
examples, and header tests. To build CUB as a developer, the following
recipe should be followed:

  1. # Clone Thrust and CUB from Github. CUB is located in Thrust's
  2. # `dependencies/cub` submodule.
  3. git clone --recursive https://github.com/NVIDIA/thrust.git
  4. cd thrust
  5. # Create build directory:
  6. mkdir build
  7. cd build
  8. # Configure -- use one of the following:
  9. cmake -DTHRUST_INCLUDE_CUB_CMAKE=ON .. # Command line interface.
  10. ccmake -DTHRUST_INCLUDE_CUB_CMAKE=ON .. # ncurses GUI (Linux only)
  11. cmake-gui # Graphical UI, set source/build directories and options in the app
  12. # Build:
  13. cmake --build . -j <num jobs> # invokes make (or ninja, etc)
  14. # Run tests and examples:
  15. ctest

By default, the C++14 standard is targeted, but this can be changed in CMake.
More information on configuring your CUB build and creating a pull request is
found in CONTRIBUTING.md.



Open Source License

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

  1. Copyright (c) 2010-2011, Duane Merrill. All rights reserved.
  2. Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. * Redistributions of source code must retain the above copyright
  6. notice, this list of conditions and the following disclaimer.
  7. * Redistributions in binary form must reproduce the above copyright
  8. notice, this list of conditions and the following disclaimer in the
  9. documentation and/or other materials provided with the distribution.
  10. * Neither the name of the NVIDIA CORPORATION nor the
  11. names of its contributors may be used to endorse or promote products
  12. derived from this software without specific prior written permission.
  13. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  14. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
  17. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.