Skip to content

Commit aaa49d9

Browse files
[rocm-libraries] ROCm/rocm-libraries#5074 (commit 66e3be7)
[rocthrust] adding the updated backend build info into the documentation (#5074) ## Motivation The backend build information was removed from the documentation previously because it was incorrect. This PR reintroduces the topic with updated information. This is the companion to #4983 and shouldn't be merged in before 4983 is merged in.
1 parent 69e9b6e commit aaa49d9

4 files changed

Lines changed: 104 additions & 0 deletions

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
.. meta::
2+
:description: Building rocThrust for different backends
3+
:keywords: rocThrust, ROCm, HIPSTDPAR, installation
4+
5+
*******************************************
6+
Building rocThrust for different backends
7+
*******************************************
8+
9+
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 :doc:`built and installed <../install/rocThrust-install-overview>`.
10+
11+
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.
12+
13+
The options for ``THRUST_DEVICE_SYSTEM`` are:
14+
15+
.. list-table::
16+
:widths: 20 80
17+
:header-rows: 1
18+
19+
* - Backend
20+
- Description
21+
22+
* - ``HIP``
23+
- | `HIP <https://rocm.docs.amd.com/projects/HIP/en/latest/index.html>`_ backend for device acceleration.
24+
| Requires a HIP-aware clang compiler such as hipcc.
25+
| Default setting.
26+
27+
* - ``TBB``
28+
- | |oneTBB|_ backend.
29+
| Parallelizes computations on the host using oneTBB with no device acceleration.
30+
| Requires a compiler that supports oneTBB.
31+
32+
* - ``OMP``
33+
- | |OMP|_ backend.
34+
| Parallelizes computations on the host using OpenMP with no device acceleration.
35+
| Requires a compiler that supports OpenMP.
36+
37+
* - ``CPP``
38+
- | Uses the g++ or clang++ compiler, and the standard C++ library.
39+
| Forces sequential computation on the host with no device acceleration.
40+
41+
42+
.. note::
43+
44+
rocThrust examples and benchmarks require device acceleration. rocThrust must be built with ``THRUST_DEVICE_SYSTEM=HIP`` to use its examples and benchmarks.
45+
46+
The options for ``THRUST_HOST_SYSTEM`` are:
47+
48+
.. list-table::
49+
:widths: 20 80
50+
:header-rows: 1
51+
52+
* - Backend
53+
- Description
54+
55+
* - ``CPP``
56+
- | The standard C++ library.
57+
| Uses the g++ or clang++ compiler for sequential computations on the host with no device acceleration.
58+
| Default setting.
59+
60+
* - ``OMP``
61+
- | OpenMP backend.
62+
| Parallelizes host-side operations using OpenMP.
63+
| Requires a compiler that supports OpenMP.
64+
65+
* - ``TBB``
66+
- | oneTBB backend.
67+
| Parallelizes host-side operations using oneTBB.
68+
| Requires a compiler that supports oneTBB.
69+
70+
.. note::
71+
72+
If ``THRUST_DEVICE_SYSTEM`` is set to ``OMP``, ``TBB``, or ``CPP``, then ``THRUST_HOST_SYSTEM`` must be set to the same backend.
73+
74+
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.
75+
76+
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.
77+
78+
For example, to build rocThrust with no device acceleration, using only the g++ compiler:
79+
80+
.. code:: shell
81+
82+
`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`
83+
84+
For more information about build options and how to set them, see :doc:`building rocThrust with CMake <../install/rocThrust-install-with-cmake>` and :doc:`building rocThrust with rmake <../install/rocThrust-rmake-install>`.
85+
86+
87+
.. |reg| raw:: html
88+
89+
&reg;
90+
91+
.. |oneTBB| replace:: Intel\ |reg| oneAPI Threading Building Blocks (oneTBB)
92+
.. _oneTBB: https://www.intel.com/content/www/us/en/developer/tools/oneapi/onetbb.html
93+
94+
.. |OMP| replace:: OpenMP\ |reg|
95+
.. _OMP: https://www.openmp.org

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The rocThrust project is located in https://github.com/ROCm/rocm-libraries/tree/
2525

2626
.. grid-item-card:: How to
2727

28+
* :doc:`Build rocThrust for different backends <./how-to/rocThrust-build-for-backends>`
2829
* :doc:`Add rocThrust to a CMake project <./how-to/use-rocThrust-in-a-project>`
2930
* :doc:`Run tests on multiple GPUs <./how-to/run-rocThrust-tests-on-multiple-gpus>`
3031
* :doc:`Use HIPSTDPAR <./how-to/rocThrust-hipstdpar>`

docs/install/rocThrust-rmake-install.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ The ``-c`` option builds all clients, including the unit tests:
2424
2525
python rmake.py -c
2626
27+
:doc:`CMake build options <./rocThrust-install-with-cmake>` can be passed to the ``rmake.py`` script using the ``--cmake-darg`` option:
28+
29+
.. code:: shell
30+
31+
python rmake.py -ci --cmake-darg THRUST_HOST_SYSTEM=OMP --cmake-darg THRUST_DEVICE_SYSTEM=OMP
32+
2733
To see a complete list of ``rmake.py`` options, run:
2834

2935
.. code-block:: shell

docs/sphinx/_toc.yml.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ subtrees:
2020

2121
- caption: How to
2222
entries:
23+
- file: how-to/rocThrust-build-for-backends.rst
24+
title: Build for different backends
2325
- file: how-to/use-rocThrust-in-a-project.rst
2426
title: Add rocThrust to a CMake project
2527
- file: how-to/run-rocThrust-tests-on-multiple-gpus

0 commit comments

Comments
 (0)