Build rocThrust from source#
To build rocThrust as part of the ROCm Core SDK, see TheRock build instructions. TheRock is the recommended way to build ROCm components from source.
Alternatively, you can build rocThrust standalone using the following instructions.
Prerequisites#
On Linux, ROCm must be installed before rocThrust is installed.
rocThrust has the following prerequisites on Linux and Microsoft Windows:
rocPRIM can be automatically downloaded and installed when rocThrust is built.
rocThrust has these additional prerequisites on Windows:
Get the rocThrust source code#
The rocThrust source code is available from the ROCm libraries GitHub repository. Use sparse checkout when cloning the rocThrust project:
git clone --no-checkout --filter=blob:none https://github.com/ROCm/rocm-libraries.git
cd rocm-libraries
git sparse-checkout init --cone
git sparse-checkout set projects/rocthrust
Then use git checkout to check out the branch you need.
The develop branch is intended for users who want to preview new features or contribute to the rocThrust code base.
If you don’t intend to contribute to the rocThrust code base and won’t be previewing features, use a branch that matches the version of ROCm installed on your system.
For build instructions, see ./build.
Build on Linux#
You can use the install script to build and install rocThrust on Linux. You can also use CMake if you want more build and installation options.
The install script is located in the rocthrust root directory.
To build and install rocThrust, run:
./install --install
This command also downloads and installs rocPRIM.
To build rocThrust and generate tar, zip, and debian packages, run:
./install --package
To see a complete list of options, run:
./install --help
Build on Windows#
You can use rmake.py to build and install rocThrust on Windows. You can also use CMake if you want more build and installation options.
rmake.py is located in the rocthrust root directory.
To build and install rocThrust, run:
python rmake.py -i
This command also downloads rocPRIM and installs it in C:\hipSDK.
The -c option builds all clients, including the unit tests:
python rmake.py -c
CMake build options can be passed to the rmake.py script using the --cmake-darg option:
python rmake.py -ci --cmake-darg THRUST_HOST_SYSTEM=OMP --cmake-darg THRUST_DEVICE_SYSTEM=OMP
To see a complete list of rmake.py options, run:
python rmake.py --help
Build with CMake#
You can build and install rocThrust with CMake on either Windows or Linux.
Set CXX to hipcc and set CMAKE_CXX_COMPILER to hipcc’s absolute path. For example:
CXX=hipcc
CMAKE_CXX_COMPILER=/usr/bin/hipcc
Create the build directory under the rocthrust root directory, then change directory to the build directory:
mkdir build
cd build
Generate the rocThrust makefile using the cmake command:
cmake ../. [-D<OPTION1=VALUE1> [-D<OPTION2=VALUE2>] ...]
The build options are:
DISABLE_WERROR: Set this toOFFto pass-Werrorto the compiler. Default isON.BUILD_TEST: Set this toONto enable rocThrust tests. Default isOFF.BUILD_HIPSTDPAR_TEST: Set this toONto enable HIPSTDPAR tests. Default isOFF.BUILD_BENCHMARK: Set this toONto build rocThrust benchmarks. Default isOFF.BUILD_EXAMPLE: Set this toONto build the rocThrust examples. 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_SYSTEM_LIB: Set this toONto use the installedROCmlibraries when building the tests. For this option to take effect,BUILD_TESTmust be set toON. Default isOFF.RNG_SEED_COUNT: Set this to the non-repeatable random dataset count. Default is 0.PRNG_SEEDS: Set this to the RNG seeds. The seeds must be passed as a semicolon-delimited array of 32-bit unsigned integers. To avoid command line parsing errors, enclose the entire option in quotation marks. For example,cmake "-DPRNG_SEEDS=1;2;3;4".-DPRNG_SEEDS=1is used by default.BUILD_ADDRESS_SANITIZER: Set this toONto build with the Clang address sanitizer enabled. Default isOFF.EXTERNAL_DEPS_FORCE_DOWNLOAD: Set this toONto download the non-ROCm dependencies such as Google Test even if they’re already installed. Default isOFF.USE_HIPCXX: Set this toONto build with CMake HIP language support. Setting this toONeliminates the need to useCXX=hipcc. Default isOFF.ROCPRIM_FETCH_METHODandROCRAND_FETCH_METHOD: Set these to the method to use to download the rocPRIM and rocRAND components, respectively. Can be set toPACKAGE,DOWNLOAD, orMONOREPO. Set toMONOREPOif the component isn’t already installed and you’re building rocThrust from within a clone of the rocm-libraries repository that includes the component. Set toDOWNLOADif the component isn’t installed and you aren’t in a clone of therocm-librariesrepository that includes the component.DOWNLOADwill clone the repository using sparse checkout so that only the necessary files are downloaded. Set toPACKAGEif the component is already installed. If the component isn’t installed, it’ll be downloaded from the repository in the same way as using theDOWNLOADoption. The default method isPACKAGE.LINK_HIP_DEVICE_LIBS: Set toOFFto prevent linking against device dependencies, including rocPRIM, and the build can only be used for host-side computation. Default isON.THRUST_DEVICE_SYSTEM: Sets the device backend that will be used. If unspecified, this option will be inferred from the name of the device compiler. Valid values includeHIP(for AMD GPU acceleration),CPP(C++, for sequential host-side compute),TBB(Thread Building Blocks, for parallel host-side compute), andOMP(OpenMP, for parallel host-side compute). Note that when this is set to a value other thanHIP, you must setLINK_HIP_DEVICE_LIBS=OFF.THRUST_HOST_SYSTEM: Sets the host backend that will be used. If unspecified, this option defaults toCPP. Valid values includeCPP(C++),OMP(OpenMP), andTBB(Thread Building Blocks).
Note
If you’re using a version of git earlier than 2.25, -DROCPRIM_FETCH_METHOD=DOWNLOAD and -DROCRAND_FETCH_METHOD=DOWNLOAD will download the entire rocm-libraries repository.
Build rocThrust using the generated make file:
make -j4
After you’ve built rocThrust, you can optionally generate tar, zip, and deb packages:
make package
Finally, install rocThrust:
make install