|
| 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 | + ® |
| 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 |
0 commit comments