HIP: Heterogenous-computing Interface for Portability
Table of Contents

Installing pre-built packages

HIP can be easily installed using pre-built binary packages using the package manager for your platform.

Prerequisites

HIP code can be developed either on AMD ROCm platform using HIP-Clang compiler, or a CUDA platform with nvcc installed.

AMD Platform

1 sudo apt install mesa-common-dev
2 sudo apt install clang
3 sudo apt install comgr
4 sudo apt-get -y install rocm-dkms

Public link for Rocm installation https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html

HIP-Clang is the compiler for compiling HIP programs on AMD platform.

HIP-Clang can be built manually:

1 git clone -b rocm-4.1.x https://github.com/RadeonOpenCompute/llvm-project.git
2 cd llvm-project
3 mkdir -p build && cd build
4 cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=1 -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" ../llvm
5 make -j
6 sudo make install

Rocm device library can be manually built as following,

1 export PATH=/opt/rocm/llvm/bin:$PATH
2 git clone -b rocm-4.1.x https://github.com/RadeonOpenCompute/ROCm-Device-Libs.git
3 cd ROCm-Device-Libs
4 mkdir -p build && cd build
5 CC=clang CXX=clang++ cmake -DLLVM_DIR=/opt/rocm/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_WERROR=1 -DLLVM_ENABLE_ASSERTIONS=1 -DCMAKE_INSTALL_PREFIX=/opt/rocm ..
6 make -j
7 sudo make install

NVIDIA Platform

HIP-nvcc is the compiler for HIP program compilation on NVIDIA platform.

Building HIP from source

Build ROCclr

ROCclr is defined on AMD platform that HIP use Radeon Open Compute Common Language Runtime (ROCclr), which is a virtual device interface that HIP runtimes interact with different backends. See https://github.com/ROCm-Developer-Tools/ROCclr

1 git clone -b rocm-4.1.x https://github.com/ROCm-Developer-Tools/ROCclr.git
2 export ROCclr_DIR="$(readlink -f ROCclr)"
3 git clone -b rocm-4.1.x https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git
4 export OPENCL_DIR="$(readlink -f ROCm-OpenCL-Runtime)"
5 cd "$ROCclr_DIR"
6 mkdir -p build;cd build
7 cmake -DOPENCL_DIR="$OPENCL_DIR" -DCMAKE_INSTALL_PREFIX=/opt/rocm/rocclr ..
8 make -j
9 sudo make install

Build HIP

1 git clone -b rocm-4.1.x https://github.com/ROCm-Developer-Tools/HIP.git
2 export HIP_DIR="$(readlink -f HIP)"
3 cd "$HIP_DIR"
4 mkdir -p build; cd build
5 cmake -DCMAKE_PREFIX_PATH="$ROCclr_DIR/build;/opt/rocm/" -DCMAKE_INSTALL_PREFIX=</where/to/install/hip> ..
6 make -j
7 sudo make install
8 Note: If you don't specify CMAKE_INSTALL_PREFIX, hip-rocclr runtime will be installed to "/opt/rocm/hip".

Default paths and environment variables

After installation, make sure HIP_PATH is pointed to /where/to/install/hip

Verify your installation

Run hipconfig (instructions below assume default installation path) :

1 /opt/rocm/bin/hipconfig --full

Compile and run the square sample.