HIP Support and Options

Describes preliminary HIP support in Clang

Beta support for HIP language is provided in this release.

HIP is supported only for AMD GPU targets and requires an AMD ROCm install for HIP header files and runtime libraries. CCE is compatible with ROCm 4.0. Older and newer releases of ROCm may not be compatible.

Several flags must be specified explicitly to compile and link HIP source files. For example, the following command lines will compile and link a HIP source file targeting an AMD MI100 GPU:

CC -std=c++11 -D__HIP_ROCclr__ --offload-arch=gfx908 -D__HIP_ARCH_GFX908__=1 \
 --rocm-path=ROCM-INSTALL-PATH -c -x hip [options] filename ...

CC --rocm-path=ROCM-INSTALL-PATH -L ROCM-INSTALL-PATH/lib -lamdhip64 [options] filename

The following compiler options are relevant for compiling and linking HIP source files:

-x hip
Enable HIP compilation for any input files that appear after this option on the command line. This option should not be used on a link line with object files as input, since CCE will treat the object files as HIP source.
--rocm-path=ROCM-INSTALL-PATH
Specifies the location of a ROCm install; used to locate HIP header files and device runtime libraries.
--offload-arch=[gfx906|gfx908]
Specifies the HIP offload target architecture. CCE currently supports gfx906 (AMD MI50 and AMD MI60) and gfx908 (AMD MI100). This flag can be specified multiple times to produce a "fat binary" that contains device code for multiple GPUs.
--cuda-offload-arch=[gfx906|gfx908]
A synonym for --offload-arch.
-D__HIP_ARCH_GFX906__=1
Enables gfx906 specific settings in the HIP header files; should be used with --offload-arch=gfx906.
-D__HIP_ARCH_GFX908__=1
Enables gfx908 specific settings in the HIP header files; should be used with --offload-arch=gfx908.
-D__HIP_ROCclr__
Enables use of the AMD ROCm Common Language Runtime interface in the HIP header files, which is necessary with ROCm 3.5 or newer.
-fgpu-rdc, -fno-gpu-rdc
Generate relocatable device code, allowing separate compilation of HIP source files with cross-file references. Compiling with -fgpu-rdc will produce a bundled HIP offload object file that requires linking with --hip-link. Compiling with -fno-gpu-rdc will produce ordinary host object files that do not need to be linked with --hip-link. However, -fno-gpu-rdc requires that all HIP device code in a HIP source file must be completely self-contained, without referencing any external user-defined symbols. The default is -fno-gpu-rdc.
--hip-link
Enables device linking for bundled HIP offload object files. This option is required when linking object files compiled with -fgpu-rdc.