From 34bd76f492e8bdd143a53be635af0d57d5daa7c8 Mon Sep 17 00:00:00 2001 From: jujiang Date: Tue, 20 Jul 2021 11:00:53 -0400 Subject: [PATCH] SWDEV-288929 - Update HIP documents Change-Id: Ic633e6783162a1e697597a1e077d814c23ceaa07 [ROCm/hip commit: 992b7a56a54ffb057accacb0b182be2ad8764a67] --- projects/hip/INSTALL.md | 46 ++++++++++--------- projects/hip/docs/markdown/hip_faq.md | 4 ++ .../docs/markdown/hip_programming_guide.md | 1 + 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/projects/hip/INSTALL.md b/projects/hip/INSTALL.md index 5136004918..5eef9147d1 100644 --- a/projects/hip/INSTALL.md +++ b/projects/hip/INSTALL.md @@ -42,7 +42,6 @@ cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_EN make -j sudo make install ``` - Rocm device library can be manually built as following, ``` export PATH=/opt/rocm/llvm/bin:$PATH @@ -63,7 +62,6 @@ HIP-nvcc is the compiler for HIP program compilation on NVIDIA platform. ``` 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). @@ -71,36 +69,43 @@ apt-get install hip-nvcc # Building HIP from source -## Build ROCclr +## Get HIP source code + +``` +git clone -b rocm-4.4.x https://github.com/ROCm-Developer-Tools/hipamd.git +git clone -b rocm-4.4.x https://github.com/ROCm-Developer-Tools/hip.git +git clone -b rocm-4.4.x https://github.com/ROCm-Developer-Tools/ROCclr.git +git clone -b rocm-4.4.x https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git +``` + +## Set the environment variables + +``` +export HIPAMD_DIR="$(readlink -f hipamd)" +export HIP_DIR="$(readlink -f hip)" +export ROCclr_DIR="$(readlink -f ROCclr)" +export OPENCL_DIR="$(readlink -f ROCm-OpenCL-Runtime)" +``` 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 -``` -git clone -b rocm-4.3.x https://github.com/ROCm-Developer-Tools/ROCclr.git -export ROCclr_DIR="$(readlink -f ROCclr)" -git clone -b rocm-4.3.x https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git -export OPENCL_DIR="$(readlink -f ROCm-OpenCL-Runtime)" -cd "$ROCclr_DIR" -mkdir -p build;cd build -cmake -DOPENCL_DIR="$OPENCL_DIR" -DCMAKE_INSTALL_PREFIX=/opt/rocm/rocclr .. -make -j -sudo make install -``` +HIPAMP repository provides implementation specifically for AMD platform. +See https://github.com/ROCm-Developer-Tools/hipamd ## Build HIP ``` -git clone -b rocm-4.3.x https://github.com/ROCm-Developer-Tools/HIP.git -export HIP_DIR="$(readlink -f HIP)" -cd "$HIP_DIR" +cd "$HIPAMD_DIR" mkdir -p build; cd build -cmake -DCMAKE_PREFIX_PATH="$ROCclr_DIR/build;/opt/rocm/" -DCMAKE_INSTALL_PREFIX= .. -make -j +cmake -DHIP_COMMON_DIR=$HIP_DIR -DAMD_OPENCL_PATH=$OPENCL_DIR -DROCCLR_PATH=$ROCCLR_DIR -DCMAKE_PREFIX_PATH="/opt/rocm/" -DCMAKE_INSTALL_PREFIX=$PWD/install .. +make -j$(nproc) sudo make install -Note: If you don't specify CMAKE_INSTALL_PREFIX, hip-rocclr runtime will be installed to "/opt/rocm/hip". ``` +Note: If you don't specify CMAKE_INSTALL_PREFIX, hip runtime will be installed to "/opt/rocm/hip". +By default, release version of AMDHIP is built. + ## Default paths and environment variables * By default HIP looks for HSA in /opt/rocm/hsa (can be overridden by setting HSA_PATH environment variable). @@ -119,6 +124,5 @@ Run hipconfig (instructions below assume default installation path) : /opt/rocm/bin/hipconfig --full ``` - Compile and run the [square sample](https://github.com/ROCm-Developer-Tools/HIP/tree/main/samples/0_Intro/square). diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index ee1b379d2c..04c164067e 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -19,6 +19,7 @@ - [Can I develop HIP code on an Nvidia CUDA platform?](#can-i-develop-hip-code-on-an-nvidia-cuda-platform) - [Can I develop HIP code on an AMD HIP-Clang platform?](#can-i-develop-hip-code-on-an-amd-hip-clang-platform) - [What is ROCclr?](#what-is-rocclr) +- [What is hipamd?](#what-is-hipamd) - [Can a HIP binary run on both AMD and Nvidia platforms?](#can-a-hip-binary-run-on-both-amd-and-nvidia-platforms) - [On HIP-Clang, can I link HIP code with host code compiled with another compiler such as gcc, icc, or clang?](#on-HIP-Clang-can-i-link-hip-code-with-host-code-compiled-with-another-compiler-such-as-gcc-icc-or-clang-) - [HIP detected my platform (hip-clang vs nvcc) incorrectly - what should I do?](#hip-detected-my-platform-hip-clang-vs-nvcc-incorrectly---what-should-i-do) @@ -180,6 +181,9 @@ NOTE: If HIP_ROCCLR_HOME is set, there is no need to set HIP_CLANG_PATH since hi ### What is ROCclr? ROCclr (Radeon Open Compute Common Language Runtime) is a virtual device interface that compute runtimes interact with backends such as ROCr on Linux, as well as PAL on Windows. +### What is HIPAMD? +HIPAMD is a repository branched out from HIP, mainly the implementation for AMD GPU. + ### Can a HIP binary run on both AMD and Nvidia platforms? HIP is a source-portable language that can be compiled to run on either AMD or NVIDIA platform. HIP tools don't create a "fat binary" that can run on either platform, however. diff --git a/projects/hip/docs/markdown/hip_programming_guide.md b/projects/hip/docs/markdown/hip_programming_guide.md index efd80a32c7..08a2374aa8 100644 --- a/projects/hip/docs/markdown/hip_programming_guide.md +++ b/projects/hip/docs/markdown/hip_programming_guide.md @@ -45,6 +45,7 @@ else { . . . } ``` +Please note, the managed memory capability check may not be necessary, but if HMM is not supported, then managed malloc will fall back to using system memory and other managed memory API calls will have undefined behavior. For more details on managed memory APIs, please refer to the documentation HIP-API.pdf. ### HIP Stream Memory Operations