Building and installing hipCUB with CMake#
You can build and install hipCUB with CMake on Windows or Linux.
Before you begin, set CXX to amdclang++ or hipcc, and set CMAKE_CXX_COMPILER to the compiler’s absolute path. For example:
CXX=amdclang++
CMAKE_CXX_COMPILER=/opt/rocm/bin/amdclang++
After cloning the project, create the build directory under the hipcub root directory, then change directory to the build directory:
mkdir build
cd build
Generate the makefile using the cmake command:
cmake ../. [-D<OPTION1=VALUE1> [-D<OPTION2=VALUE2>] ...]
The available build options are:
BUILD_BENCHMARK. Set this toONto build benchmark tests. Off by default.BUILD_TEST. Set this toONto build tests. Off by default.BUILD_EXAMPLE. Set this toONto build the hipCUB examples. Default isOFF.USE_SYSTEM_LIB: Set toONto use the installedhipCUBfrom the system when building the tests. Off by default. For this option to take effect,BUILD_TESTmust beONand thehipCUBinstall (with its dependencies) must be compatible with the version of the tests.BUILD_ADDRESS_SANITIZER. Set this toONto build with the Clang address sanitizer enabled. Default isOFF.`` EXTERNAL_DEPS_FORCE_DOWNLOAD``. Set this to
ONto download the non-ROCm dependencies such as Google Test even if they’re already installed. Default isOFF.BUILD_OFFLOAD_COMPRESS. Set this toOFFto prevent the--offload-compressswitch from being passed to the compiler and compressing the binary. On by default.USE_HIPCXX. Set this toONto build with CMake HIP language support. Setting this toONeliminates the need to useCXX=hipcc. Default isOFF.ROCPRIM_FETCH_METHOD. Set this to the method to use to download rocPRIM. Can be set toPACKAGE,DOWNLOAD, orMONOREPO. Set toMONOREPOif rocPRIM isn’t already installed and you’re building hipCUB from within a clone of the rocm-libraries repository that also includes rocPRIM. Set toDOWNLOADif rocPRIM isn’t installed and you aren’t in a clone of therocm-librariesrepository that includes rocPRIM.DOWNLOADwill clone the repository using sparse checkout so that only the necessary files are downloaded. Set toPACKAGEif rocPRIM is already installed. If you specifyPACKAGEbut rocPRIM isn’t installed, the files will be downloaded using the same method as theDOWNLOADoption. The default method isPACKAGE.
Note
If you’re using a version of git earlier than 2.25, -DROCPRIM_FETCH_METHOD=DOWNLOAD will download the entire rocm-libraries repository.
Build hipCUB using the generated make file:
make -j4
After you’ve built hipCUB, you can optionally generate tar, zip, and deb packages:
make package
Finally, install hipCUB:
make install