HIP can be easily installed using pre-built binary packages using the package manager for your platform.
HIP code can be developed either on AMD ROCm platform using hcc or clang compiler, or a CUDA platform with nvcc installed:
-
Install the rocm packages. ROCm will install all of the necessary components, including the kernel driver, runtime software, HCC compiler, and HIP.
-
Default paths and environment variables:
- By default HIP looks for hcc in /opt/rocm/hcc (can be overridden by setting HCC_HOME environment variable)
- By default HIP looks for HSA in /opt/rocm/hsa (can be overridden by setting HSA_PATH environment variable)
- By default HIP is installed into /opt/rocm/hip (can be overridden by setting HIP_PATH environment variable).
- Optionally, consider adding /opt/rocm/bin to your PATH to make it easier to use the tools.
-
Using clang to compile HIP program for AMD GPU is under development. Users need to build LLVM, clang, lld, ROCm device library, and HIP from source.
-
Install the rocm packages. ROCm will install some of the necessary components, including the kernel driver, HSA runtime, etc.
-
Build LLVM/clang/lld by using the following repository and branch and following the general LLVM/clang build procedure:
- LLVM: https://github.com/RadeonOpenCompute/llvm.git amd-common branch
- clang: https://github.com/RadeonOpenCompute/clang checkout amd-hip-upstream branch, then merge with amd-common branch to match LLVM/lld
- lld: https://github.com/RadeonOpenCompute/lld amd-common branch
-
Build Rocm device library
- Checkout https://github.com/RadeonOpenCompute/ROCm-Device-Libs.git amd-hip branch and build it with clang built from the last step.
-
Build HIP
- Checkout https://github.com/ROCm-Developer-Tools/HIP.git hip-clang branch and build it with HCC installed with ROCm packages.
-
Environment variables to let hipcc to use clang to compile HIP program
By default hipcc uses hcc to compile HIP program for AMD GPU. To let hipcc to use clang to compile HIP program, the following environment variables must be set:
- HIP_CLANG_PATH - Path to clang
- DEVICE_LIB_PATH - Path to the device library
-
Default paths and environment variables:
- By default HIP looks for HSA in /opt/rocm/hsa (can be overridden by setting HSA_PATH environment variable)
- By default HIP is installed into /opt/rocm/hip (can be overridden by setting HIP_PATH environment variable).
- Optionally, consider adding /opt/rocm/bin to your PATH to make it easier to use the tools.
- Optionally, set HIPCC_VERBOSE=7 to output the command line for compilation to make sure clang is used instead of hcc.
- Configure the additional package server as described here.
- Install the "hip_nvcc" package. This will install CUDA SDK and the HIP porting layer.
apt-get install hip_nvcc
- Default paths and environment variables:
- By default HIP looks for CUDA SDK in /usr/local/cuda (can be overriden by setting CUDA_PATH env variable)
- By default HIP is installed into /opt/rocm/hip (can be overridden by setting HIP_PATH environment variable).
- Optionally, consider adding /opt/rocm/bin to your path to make it easier to use the tools.
Run hipconfig (instructions below assume default installation path) :
/opt/rocm/bin/hipconfig --full
Compile and run the square sample.
HIP source code is available and the project can be built from source on the HCC platform.
- Follow the above steps to install and validate the binary packages.
- Download HIP source code (from the GitHub repot.)
- Install HIP build-time dependencies using
sudo apt-get install libelf-dev
. - Build and install HIP (This is the simple version assuming default paths ; see below for additional options.)
cd HIP
mkdir build
cd build
cmake ..
make
make install
- Default paths:
- By default cmake looks for hcc in /opt/rocm/hcc (can be overridden by setting
-DHCC_HOME=/path/to/hcc
in the cmake step).* - By default cmake looks for HSA in /opt/rocm/hsa (can be overridden by setting
-DHSA_PATH=/path/to/hsa
in the cmake step).* - By default cmake installs HIP to /opt/rocm/hip (can be overridden by setting
-DCMAKE_INSTALL_PREFIX=/where/to/install/hip
in the cmake step).*
- By default cmake looks for hcc in /opt/rocm/hcc (can be overridden by setting
Here's a richer command-line that overrides the default paths:
cd HIP
mkdir build
cd build
cmake -DHSA_PATH=/path/to/hsa -DHCC_HOME=/path/to/hcc -DCMAKE_INSTALL_PREFIX=/where/to/install/hip -DCMAKE_BUILD_TYPE=Release ..
make
make install
- After installation, make sure HIP_PATH is pointed to
/where/to/install/hip
.
AMD recently released a direct-to-GCN-ISA target. This compiler generates GCN ISA directly from LLVM, without going through an intermediate compiler IR such as HSAIL or PTX. The native GCN target is included with upstream LLVM, and has also been integrated with HCC compiler and can be used to compiler HIP programs for AMD. Binary packages for the direct-to-isa package are included with the rocm package. Alternatively, this sections describes how to build it from source:
- Install the ROCm packages as described above.
- Follow the instructions here
- In the make step for HCC, we recommend setting -DCMAKE_INSTALL_PREFIX.
- Set HCC_HOME environment variable before compiling HIP program to point to the native compiler:
export HCC_HOME=/path/to/native/hcc