Files
TheRock/rocm-libraries/projects/rocthrust/docs/how-to/rocThrust-build-for-backends.rst
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

95 lines
3.9 KiB
ReStructuredText

.. meta::
:description: Building rocThrust for different backends
:keywords: rocThrust, ROCm, HIPSTDPAR, installation
*******************************************
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 :ref:`built and installed from source <build-from-source>`.
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:
.. list-table::
:widths: 20 80
:header-rows: 1
* - Backend
- Description
* - ``HIP``
- | `HIP <https://rocm.docs.amd.com/projects/HIP/en/latest/index.html>`_ backend for device acceleration.
| Requires a HIP-aware clang compiler such as hipcc.
| Default setting.
* - ``TBB``
- | |oneTBB|_ backend.
| Parallelizes computations on the host using oneTBB with no device acceleration.
| Requires a compiler that supports oneTBB.
* - ``OMP``
- | |OMP|_ 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:
.. list-table::
:widths: 20 80
:header-rows: 1
* - 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:
.. code:: shell
`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 :doc:`Build rocThrust from source <../install/source-build>`.
.. |reg| raw:: html
&reg;
.. |oneTBB| replace:: Intel\ |reg| oneAPI Threading Building Blocks (oneTBB)
.. _oneTBB: https://www.intel.com/content/www/us/en/developer/tools/oneapi/onetbb.html
.. |OMP| replace:: OpenMP\ |reg|
.. _OMP: https://www.openmp.org