Building rocThrust for different backends

Building rocThrust for different backends#

API calls can run either on the device (GPU) system or on the host (CPU) system. The system on which computations are run depends on the execution policy used in the code, as well as the options that were set when rocThrust was built and installed.

Two build options are used to set the backend when the different execution policies are used. THRUST_DEVICE_SYSTEM sets the backend for the thrust::device execution policy and THRUST_HOST_SYSTEM sets the backend for the thrust::host policy.

The options for THRUST_DEVICE_SYSTEM are:

Backend

Description

HIP

HIP backend for device acceleration.
Requires a HIP-aware clang compiler such as hipcc.
Default setting.

TBB

Parallelizes computations on the host using oneTBB with no device acceleration.
Requires a compiler that supports oneTBB.

OMP

OpenMP® backend.
Parallelizes computations on the host using OpenMP with no device acceleration.
Requires a compiler that supports OpenMP.

CPP

Uses the g++ or clang++ compiler, and the standard C++ library.
Forces sequential computation on the host with no device acceleration.

Note

rocThrust examples and benchmarks require device acceleration. rocThrust must be built with THRUST_DEVICE_SYSTEM=HIP to use its examples and benchmarks.

The options for THRUST_HOST_SYSTEM are:

Backend

Description

CPP

The standard C++ library.
Uses the g++ or clang++ compiler for sequential computations on the host with no device acceleration.
Default setting.

OMP

OpenMP backend.
Parallelizes host-side operations using OpenMP.
Requires a compiler that supports OpenMP.

TBB

oneTBB backend.
Parallelizes host-side operations using oneTBB.
Requires a compiler that supports oneTBB.

Note

If THRUST_DEVICE_SYSTEM is set to OMP, TBB, or CPP, then THRUST_HOST_SYSTEM must be set to the same backend.

rocThrust will link to the rocPRIM libraries even when the thrust::host execution policy is used and THRUST_DEVICE_SYSTEM is set to OMP, TBB, or CPP. For full host-side execution, without linking to rocPRIM, rocThrust must be built with LINK_HIP_DEVICE_LIBS=OFF. Setting LINK_HIP_DEVICE_LIBS=OFF at build time will prevent rocThrust from linking to the rocPRIM libraries.

When rocThrust is built with LINK_HIP_DEVICE_LIBS=OFF, the thrust::device policy will be ignored and the API calls will run on the host device.

For example, to build rocThrust with no device acceleration, using only the g++ compiler:

`ROCM_PATH=/opt/rocm CXX=g++ cmake -B build -DBUILD_BENCHMARK=OFF -DBUILD_TEST=OFF -DTHRUST_HOST_SYSTEM=CPP -DTHRUST_DEVICE_SYSTEM=CPP -DLINK_HIP_DEVICE_LIBS=OFF`

For more information about build options and how to set them, see building rocThrust with CMake and building rocThrust with rmake.