{"id":20682276,"url":"https://github.com/dmlc/cub","last_synced_at":"2025-04-22T12:13:16.912Z","repository":{"id":66049419,"uuid":"93800992","full_name":"dmlc/cub","owner":"dmlc","description":null,"archived":false,"fork":false,"pushed_at":"2017-07-31T16:51:30.000Z","size":498,"stargazers_count":22,"open_issues_count":3,"forks_count":13,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-22T12:13:04.840Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Cuda","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmlc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGE_LOG.TXT","contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-06-08T23:50:29.000Z","updated_at":"2025-03-26T15:25:30.000Z","dependencies_parsed_at":"2024-01-23T21:17:25.350Z","dependency_job_id":"725d02d0-487a-45cb-8ff4-78f354242155","html_url":"https://github.com/dmlc/cub","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmlc%2Fcub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmlc%2Fcub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmlc%2Fcub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmlc%2Fcub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmlc","download_url":"https://codeload.github.com/dmlc/cub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250237833,"owners_count":21397401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T22:13:12.121Z","updated_at":"2025-04-22T12:13:16.893Z","avatar_url":"https://github.com/dmlc.png","language":"Cuda","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Note\n\nThis is a snapshot of https://github.com/NVlabs/cub with branch 1.7.0. We squashed all commits to\navoid the huge `.git` folder. Please submit codes changes to the original\nrepo, not this one.\n\nWe will keep this repo update to date before `NVlabs/cub` shrinked its cache size. But this repo may be deleted at any time. \n\n\u003chr\u003e\n\u003ch3\u003eAbout CUB\u003c/h3\u003e\n\nCurrent release: v1.6.4 (12/06/2016)\n\nWe recommend the [CUB Project Website](http://nvlabs.github.com/cub) and the [cub-users discussion forum](http://groups.google.com/group/cub-users) for further information and examples.\n\nCUB provides state-of-the-art, reusable software components for every layer\nof the CUDA programming model:\n- [\u003cb\u003e\u003cem\u003eDevice-wide primitives\u003c/em\u003e\u003c/b\u003e] (https://nvlabs.github.com/cub/group___device_module.html)\n  - Sort, prefix scan, reduction, histogram, etc.\n  - Compatible with CUDA dynamic parallelism\n- [\u003cb\u003e\u003cem\u003eBlock-wide \"collective\" primitives\u003c/em\u003e\u003c/b\u003e] (https://nvlabs.github.com/cub/group___block_module.html)\n  - I/O, sort, prefix scan, reduction, histogram, etc.\n  - Compatible with arbitrary thread block sizes and types\n- [\u003cb\u003e\u003cem\u003eWarp-wide \"collective\" primitives\u003c/em\u003e\u003c/b\u003e] (https://nvlabs.github.com/cub/group___warp_module.html)\n  - Warp-wide prefix scan, reduction, etc.\n  - Safe and architecture-specific\n- [\u003cb\u003e\u003cem\u003eThread and resource utilities\u003c/em\u003e\u003c/b\u003e](https://nvlabs.github.com/cub/group___thread_module.html)\n  - PTX intrinsics, device reflection, texture-caching iterators, caching memory allocators, etc.\n\n![Orientation of collective primitives within the CUDA software stack](http://nvlabs.github.com/cub/cub_overview.png)\n\n\u003cbr\u003e\u003chr\u003e\n\u003ch3\u003eA Simple Example\u003c/h3\u003e\n\n```C++\n#include \u003ccub/cub.cuh\u003e\n\n// Block-sorting CUDA kernel\n__global__ void BlockSortKernel(int *d_in, int *d_out)\n{\n     using namespace cub;\n\n     // Specialize BlockRadixSort, BlockLoad, and BlockStore for 128 threads\n     // owning 16 integer items each\n     typedef BlockRadixSort\u003cint, 128, 16\u003e                     BlockRadixSort;\n     typedef BlockLoad\u003cint, 128, 16, BLOCK_LOAD_TRANSPOSE\u003e   BlockLoad;\n     typedef BlockStore\u003cint, 128, 16, BLOCK_STORE_TRANSPOSE\u003e BlockStore;\n\n     // Allocate shared memory\n     __shared__ union {\n         typename BlockRadixSort::TempStorage  sort;\n         typename BlockLoad::TempStorage       load;\n         typename BlockStore::TempStorage      store;\n     } temp_storage;\n\n     int block_offset = blockIdx.x * (128 * 16);\t  // OffsetT for this block's ment\n\n     // Obtain a segment of 2048 consecutive keys that are blocked across threads\n     int thread_keys[16];\n     BlockLoad(temp_storage.load).Load(d_in + block_offset, thread_keys);\n     __syncthreads();\n\n     // Collectively sort the keys\n     BlockRadixSort(temp_storage.sort).Sort(thread_keys);\n     __syncthreads();\n\n     // Store the sorted segment\n     BlockStore(temp_storage.store).Store(d_out + block_offset, thread_keys);\n}\n```\n\nEach thread block uses cub::BlockRadixSort to collectively sort\nits own input segment.  The class is specialized by the\ndata type being sorted, by the number of threads per block, by the number of\nkeys per thread, and implicitly by the targeted compilation architecture.\n\nThe cub::BlockLoad and cub::BlockStore classes are similarly specialized.\nFurthermore, to provide coalesced accesses to device memory, these primitives are\nconfigured to access memory using a striped access pattern (where consecutive threads\nsimultaneously access consecutive items) and then \u003cem\u003etranspose\u003c/em\u003e the keys into\na [\u003cem\u003eblocked arrangement\u003c/em\u003e](index.html#sec4sec3) of elements across threads.\n\nOnce specialized, these classes expose opaque \\p TempStorage member types.\nThe thread block uses these storage types to statically allocate the union of\nshared memory needed by the thread block.  (Alternatively these storage types\ncould be aliased to global memory allocations).\n\n\u003cbr\u003e\u003chr\u003e\n\u003ch3\u003eStable Releases\u003c/h3\u003e\n\nCUB releases are labeled using version identifiers having three fields:\n*epoch.feature.update*.  The *epoch* field corresponds to support for\na major change in the CUDA programming model.  The *feature* field\ncorresponds to a stable set of features, functionality, and interface.  The\n*update* field corresponds to a bug-fix or performance update for that\nfeature set.  At the moment, we do not publicly provide non-stable releases\nsuch as development snapshots, beta releases or rolling releases.  (Feel free\nto contact us if you would like such things.)  See the\n[CUB Project Website](http://nvlabs.github.com/cub) for more information.\n\n\u003cbr\u003e\u003chr\u003e\n\u003ch3\u003eContributors\u003c/h3\u003e\n\nCUB is developed as an open-source project by [NVIDIA Research](http://research.nvidia.com).  The primary contributor is [Duane Merrill](http://github.com/dumerrill).\n\n\u003cbr\u003e\u003chr\u003e\n\u003ch3\u003eOpen Source License\u003c/h3\u003e\n\nCUB is available under the \"New BSD\" open-source license:\n\n```\nCopyright (c) 2010-2011, Duane Merrill.  All rights reserved.\nCopyright (c) 2011-2016, NVIDIA CORPORATION.  All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n   *  Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n   *  Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n   *  Neither the name of the NVIDIA CORPORATION nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmlc%2Fcub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmlc%2Fcub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmlc%2Fcub/lists"}