hip.md 2.6 KB


title: HIP breadcrumbs:

  • title: High-Performance Computing (HPC) --- {% include header.md %}

HIP (TODO abbreviation) is AMD ROCm's runtime API and kernel language, which is compilable for both AMD (through ROCm) and NVIDIA (through CUDA) GPUs. Compared to OpenCL (which is also supported by both NVIDIA and AMD), it's much more similar to CUDA (making it very easy to port CUDA code) and allows using existing profiling tools and similar for CUDA and ROCm.

Related Pages

{:.no_toc}

Resources

Info

  • HIP code can be compiled for AMD ROCm using the HIP-Clang compiler or for CUDA using the NVCC compiler.
  • If using both CUDA with an NVIDIA GPU and ROCm with an AMD GPU in the same system, HIP seems to prefer ROCm with the AMD GPU when building application. I found not way of changing the target platform (TODO).

Setup

Linux Installation (Debian)

Common Steps Before

  1. Add the ROCm package repo (overlaps with ROCm installation):
    1. Install requirements: sudo apt install libnuma-dev wget gnupg2
    2. Add public key: wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | sudo apt-key add -
    3. Add repo: echo 'deb [arch=amd64] https://repo.radeon.com/rocm/apt/debian/ ubuntu main' | sudo tee /etc/apt/sources.list.d/rocm.list
    4. Update cache: sudo apt update

Steps for NVIDIA Paltforms

  1. Install the CUDA toolkit and the NVIDIA driver: See CUDA.
  2. Install: sudo apt install hip-nvcc

Steps for AMD Paltforms

  1. Install stuff: sudo apt install mesa-common-dev clang comgr
  2. Install ROCm: See ROCm.

Common Steps After

  1. Fix symlinks and PATH:
    • (NVIDIA platforms only) CUDA symlink (/usr/local/cuda): Should already point to the right thing.
    • (AMD platforms only) ROCm symlink (/opt/rocm): sudo ln -s /opt/rocm-4.2.0 /opt/rocm (example)
    • Add to PATH: echo 'export PATH=$PATH:/opt/rocm/bin:/opt/rocm/rocprofiler/bin:/opt/rocm/opencl/bin' | sudo tee -a /etc/profile.d/rocm.sh
  2. Verify installation: /opt/rocm/bin/hipconfig --full
  3. (Optional) Try to build the square example program: square (ROCm HIP samples)

Usage and Tools

  • Show system info:
    • Show lots of HIP stuff: hipconfig --config
    • Show platform (amd or nvidia): hipconfig --platform
  • Convert CUDA program to HIP: hipify-perl input.cu > output.cpp

{% include footer.md %}