yaxunl created this revision. yaxunl added reviewers: tra, scchan, b-sumner, arsenm. Herald added a project: All. yaxunl requested review of this revision. Herald added a subscriber: wdng.
start with example usage, predefined macros and env vars. https://reviews.llvm.org/D154123 Files: clang/docs/HIPSupport.rst
Index: clang/docs/HIPSupport.rst =================================================================== --- /dev/null +++ clang/docs/HIPSupport.rst @@ -0,0 +1,104 @@ +.. raw:: html + + <style type="text/css"> + .none { background-color: #FFCCCC } + .part { background-color: #FFFF99 } + .good { background-color: #CCFF99 } + </style> + +.. role:: none +.. role:: part +.. role:: good + +.. contents:: + :local: + +=========== +HIP Support +=========== + +`HIP (Heterogeneous-Compute Interface for Portability) <https://github.com/ROCm-Developer-Tools/HIP>`_ +is a C++ Runtime API and Kernel Language that allows developers to create portable applications for +GPUs from single source code. + +Clang supports HIP on `ROCm platform <https://rocm.docs.amd.com/en/latest/#>`_. + +Example Usage +============= + +To compile a HIP program, you can use the following command: + +.. code-block:: shell + + clang -c --offload-arch=gfx906 test.hip -o test.o + +To link a HIP program, you can use this command: + +.. code-block:: shell + + clang --hip-link --offload-arch=gfx906 test.o -o test + +In the above commands, ``gfx906`` is the GPU architecture that the code is being compiled for. +The supported GPU architectures can be found in the `AMDGPU Processor Table <https://llvm.org/docs/AMDGPUUsage.html#processors>`_. +Alternatively, you can run the ``amdgpu-arch`` tool that comes with Clang to list the GPU architecture on your sytem: + +.. code-block:: shell + + amdgpu-arch + +You can also use ``--offload-arch=native`` to let ``amdgpu-arch`` automatically detect the GPU architecture on your system: + +.. code-block:: shell + + clang -c --offload-arch=native test.hip -o test.o + +Environment Variables +===================== + +.. list-table:: + :header-rows: 1 + + * - Variable + - Description + - Default Value + * - ``ROCM_PATH`` + - ROCm installation path. + - Empty + * - ``HIP_PATH`` + - HIP runtime installation path. + - Empty + * - ``HIP_DEVICE_LIB_PATH`` + - HIP device library installation path. + - Empty + +Predefined Macros +================= + +.. list-table:: + :header-rows: 1 + + * - Macro + - Description + * - ``__CLANG_RDC__`` + - This macro indicates that Clang is used for relocatable device code compilation (RDC). + * - ``__HIP__`` + - This macro is defined when the HIP language option is enabled. It is used to indicate that the code is being compiled for the HIP environment. + * - ``__HIPCC__`` + - This macro indicates that the code is being compiled using the HIP compiler. + * - ``__HIP_MEMORY_SCOPE_SINGLETHREAD`` + - This macro is set to 1 and represents the memory scope that is limited to a single thread in HIP. + * - ``__HIP_MEMORY_SCOPE_WAVEFRONT`` + - This macro is set to 2 and represents the memory scope that is limited to a wavefront in HIP. + * - ``__HIP_MEMORY_SCOPE_WORKGROUP`` + - This macro is set to 3 and represents the memory scope that is limited to a workgroup in HIP. + * - ``__HIP_MEMORY_SCOPE_AGENT`` + - This macro is set to 4 and represents the memory scope that is limited to an agent in HIP. + * - ``__HIP_MEMORY_SCOPE_SYSTEM`` + - This macro is set to 5 and represents the memory scope that is limited to the system in HIP. + * - ``__HIP_DEVICE_COMPILE__`` + - This macro is defined when the code is being compiled for a HIP device. + * - ``__HIP_NO_IMAGE_SUPPORT`` + - This macro is set to 1 when the target device does not support HIP image functions. + * - ``HIP_API_PER_THREAD_DEFAULT_STREAM`` + - This macro is defined when the GPU default stream kind is set to per-thread. +
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits