{"id":18711153,"url":"https://github.com/rocm/hipcub","last_synced_at":"2026-04-02T11:46:45.133Z","repository":{"id":37269735,"uuid":"180227602","full_name":"ROCm/hipCUB","owner":"ROCm","description":"Reusable software components for ROCm developers","archived":false,"fork":false,"pushed_at":"2025-03-25T17:07:01.000Z","size":3353,"stargazers_count":83,"open_issues_count":10,"forks_count":44,"subscribers_count":19,"default_branch":"develop","last_synced_at":"2025-03-28T15:04:09.687Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rocm.docs.amd.com/projects/hipCUB/en/latest/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ROCm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-08T20:28:03.000Z","updated_at":"2025-03-25T04:19:59.000Z","dependencies_parsed_at":"2023-12-10T17:22:17.667Z","dependency_job_id":"b5946142-6427-4753-bff1-979d3eab8f95","html_url":"https://github.com/ROCm/hipCUB","commit_stats":{"total_commits":310,"total_committers":32,"mean_commits":9.6875,"dds":0.7387096774193549,"last_synced_commit":"6b20c83b2011ba67d35206db318fda757375d91b"},"previous_names":["rocm/hipcub","rocmsoftwareplatform/hipcub"],"tags_count":63,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ROCm%2FhipCUB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ROCm%2FhipCUB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ROCm%2FhipCUB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ROCm%2FhipCUB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ROCm","download_url":"https://codeload.github.com/ROCm/hipCUB/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208142,"owners_count":20901570,"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-07T12:37:21.106Z","updated_at":"2026-04-02T11:46:40.081Z","avatar_url":"https://github.com/ROCm.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hipCUB\n\n\u003e [!NOTE]\n\u003e The published hipCUB documentation is available [here](https://rocm.docs.amd.com/projects/hipCUB/en/latest/) in an organized, easy-to-read format, with search and a table of contents. The documentation source files reside in the `docs` folder of this repository. As with all ROCm projects, the documentation is open source. For more information on contributing to the documentation, see [Contribute to ROCm documentation](https://rocm.docs.amd.com/en/latest/contribute/contributing.html).\n\nhipCUB is a thin wrapper library on top of\n[rocPRIM](https://github.com/ROCm/rocPRIM) or\n[CUB](https://github.com/thrust/cub). You can use it to port a CUB project into\n[HIP](https://github.com/ROCm/HIP) so you can use AMD hardware (and\n[ROCm](https://rocm.docs.amd.com/en/latest/) software).\n\nIn the [ROCm](https://rocm.docs.amd.com/en/latest/)\nenvironment, hipCUB uses the rocPRIM library as the backend. On CUDA platforms, it uses CUB as the\nbackend.\n\n## Requirements\n\n* Git\n* CMake (3.16 or later)\n* For AMD GPUs:\n  * AMD [ROCm](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/how-to/native-install/index.html) software (1.8.0 or later)\n    * The [HIP-clang](https://github.com/ROCm/HIP/blob/master/INSTALL.md#hip-clang) compiler (you\n      must, set this as the C++ compiler for ROCm)\n  * The [rocPRIM](https://github.com/ROCm/rocPRIM) library\n    * Automatically downloaded and built by the CMake script\n    * Requires CMake 3.16.9 or later\n* For NVIDIA GPUs:\n  * CUDA Toolkit\n  * CCCL library (\u003e= 2.6.0)\n    * Automatically downloaded and built by the CMake script\n    * Requires CMake 3.15.0 or later\n* Python 3.6 or higher (for HIP on Windows only; this is only required for install scripts)\n* Visual Studio 2019 with Clang support (HIP on Windows only)\n* Strawberry Perl (HIP on Windows only)\n\nOptional:\n\n* [GoogleTest](https://github.com/google/googletest)\n* [Google Benchmark](https://github.com/google/benchmark)\n\nGoogleTest and Google Benchmark are automatically downloaded and built by the CMake script.\n\n## Build and install\n\nTo build and install hipCub, run the following code:\n\n```shell\ngit clone https://github.com/ROCm/hipCUB.git\n\n# Go to hipCUB directory, create and go to the build directory.\ncd hipCUB; mkdir build; cd build\n\n# Configure hipCUB, setup options for your system.\n# Build options:\n#   BUILD_TEST - OFF by default,\n#   BUILD_BENCHMARK - OFF by default.\n#   DEPENDENCIES_FORCE_DOWNLOAD - OFF by default and at ON the dependencies will be downloaded to build folder,\n#\n# ! IMPORTANT !\n# Set C++ compiler to HIP-aware clang. You can do it by adding 'CXX=\u003cpath-to-compiler\u003e'\n# before 'cmake' or setting cmake option 'CMAKE_CXX_COMPILER' to path to the compiler.\n#\n[CXX=hipcc] cmake ../. # or cmake-gui ../.\n\n# To configure hipCUB for Nvidia platforms, 'CXX=\u003cpath-to-nvcc\u003e', `CXX=nvcc` or omitting the flag\n# entirely before 'cmake' is sufficient\n[CXX=nvcc] cmake -DBUILD_TEST=ON ../. # or cmake-gui ../.\n# or\ncmake -DBUILD_TEST=ON ../. # or cmake-gui ../.\n# or to build benchmarks\ncmake -DBUILD_BENCHMARK=ON ../.\n\n# Build\nmake -j4\n\n# Optionally, run tests if they're enabled.\nctest --output-on-failure\n\n# Package\nmake package\n\n# Install\n[sudo] make install\n```\n\n### HIP on Windows\n\nInitial support for HIP on Windows is available. You can install it using the provided `rmake.py` Python\nscript:\n\n```shell\ngit clone https://github.com/ROCm/hipCUB.git\ncd hipCUB\n\n# the -i option will install rocPRIM to C:\\hipSDK by default\npython rmake.py -i\n\n# the -c option will build all clients including unit tests\npython rmake.py -c\n```\n\n### Using hipCUB\n\nTo use hipCUB in a CMake project, we recommended using the package configuration files.\n\n```cmake\n# On ROCm hipCUB requires rocPRIM\nfind_package(rocprim REQUIRED CONFIG PATHS \"/opt/rocm/lib/cmake/rocprim\")\n\n# \"/opt/rocm\" - default install prefix\nfind_package(hipcub REQUIRED CONFIG PATHS \"/opt/rocm/lib/cmake/hipcub\")\n\n...\n# On ROCm: includes hipCUB headers and roc::rocprim_hip target\n# On CUDA: includes only hipCUB headers, user has to include CUB directory\ntarget_link_libraries(\u003cyour_target\u003e hip::hipcub)\n```\n\nInclude only the main header file:\n\n```cpp\n#include \u003chipcub/hipcub.hpp\u003e\n```\n\nDepending on your current HIP platform, hipCUB includes CUB or rocPRIM headers.\n\n## Running unit tests\n\n```shell\n# Go to hipCUB build directory\ncd hipCUB; cd build\n\n# To run all tests\nctest\n\n# To run unit tests for hipCUB\n./test/hipcub/\u003cunit-test-name\u003e\n```\n\n### Using custom seeds for the tests\n\nGo to the `hipCUB/test/hipcub/test_seed.hpp` file.\n\n```cpp\n//(1)\nstatic constexpr int random_seeds_count = 10;\n\n//(2)\nstatic constexpr unsigned int seeds [] = {0, 2, 10, 1000};\n\n//(3)\nstatic constexpr size_t seed_size = sizeof(seeds) / sizeof(seeds[0]);\n```\n\n(1) Defines a constant that sets how many passes are performed over the tests with runtime-generated\n seeds. Modify at will.\n\n(2) Defines the user-generated seeds. Each of the elements of the array are used as seeds for all tests.\n Modify at will. If no static seeds are desired, leave the array empty.\n\n  ```cpp\n  static constexpr unsigned int seeds [] = {};\n  ```\n\n(3) Never modified this line.\n\n## Running benchmarks\n\n```shell\n# Go to hipCUB build directory\ncd hipCUB; cd build\n\n# To run benchmark for warp functions:\n# Further option can be found using --help\n# [] Fields are optional\n./benchmark/benchmark_warp_\u003cfunction_name\u003e [--size \u003csize\u003e] [--trials \u003ctrials\u003e]\n\n# To run benchmark for block functions:\n# Further option can be found using --help\n# [] Fields are optional\n./benchmark/benchmark_block_\u003cfunction_name\u003e [--size \u003csize\u003e] [--trials \u003ctrials\u003e]\n\n# To run benchmark for device functions:\n# Further option can be found using --help\n# [] Fields are optional\n./benchmark/benchmark_device_\u003cfunction_name\u003e [--size \u003csize\u003e] [--trials \u003ctrials\u003e]\n```\n\n## Building the documentation locally\n\n### Requirements\n\n#### Doxygen\n\nThe build system uses Doxygen [version 1.9.4](https://github.com/doxygen/doxygen/releases/tag/Release_1_9_4). You can try using a newer version, but that might cause issues.\n\nAfter you have downloaded Doxygen version 1.9.4:\n\n```shell\n# Add doxygen to your PATH\necho 'export PATH=\u003cdoxygen 1.9.4 path\u003e/bin:$PATH' \u003e\u003e ~/.bashrc\n\n# Apply the updated .bashrc\nsource ~/.bashrc\n\n# Confirm that you are using version 1.9.4\ndoxygen --version\n```\n\n#### Python\n\nThe build system uses Python version 3.10. You can try using a newer version, but that might cause issues.\n\nYou can install Python 3.10 alongside your other Python versions using [pyenv](https://github.com/pyenv/pyenv?tab=readme-ov-file#installation):\n\n```shell\n# Install Python 3.10\npyenv install 3.10\n\n# Create a Python 3.10 virtual environment\npyenv virtualenv 3.10 venv_hipcub\n\n# Activate the virtual environment\npyenv activate venv_hipcub\n```\n\n### Building\n\nAfter cloning this repository, and `cd`ing into it:\n\n```shell\n# Install Python dependencies\npython3 -m pip install -r docs/sphinx/requirements.txt\n\n# Build the documentation\npython3 -m sphinx -T -E -b html -d docs/_build/doctrees -D language=en docs docs/_build/html\n```\n\nYou can then open `docs/_build/html/index.html` in your browser to view the documentation.\n\n## Support\n\nBugs and feature requests can be reported through the\n[GitHub issue tracker](https://github.com/ROCm/hipCUB/issues).\n\n## Contributing\n\nContributions are most welcome! Learn more at [CONTRIBUTING](./CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocm%2Fhipcub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frocm%2Fhipcub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocm%2Fhipcub/lists"}