From 3dae7945ff90e8d2e0d65b8ffc2e170bb93cb6cb Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Mon, 6 Jan 2020 02:02:47 -0500 Subject: [PATCH] Update HIP-Clang build instruction (#1764) [ROCm/hip commit: af697eaefed7806d1d561f9f5087f07f7013a4ec] --- projects/hip/INSTALL.md | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/projects/hip/INSTALL.md b/projects/hip/INSTALL.md index 2dc12f81a8..c66bc4baeb 100644 --- a/projects/hip/INSTALL.md +++ b/projects/hip/INSTALL.md @@ -42,20 +42,43 @@ apt-get install hip-hcc * Install the [rocm](http://gpuopen.com/getting-started-with-boltzmann-components-platforms-installation/) 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. It is recommended to use -DCMAKE_INSTALL_PREFIX=/opt/rocm/llvm with cmake so that LLVM/clang/lld are installed to the default path expected by hipcc. +* Build HIP-Clang + +``` +git clone https://github.com/llvm/llvm-project.git +cd llvm-project/llvm/tools +ln -s clang ../../clang +ln -s lld ../../lld +cd ../.. +mkdir -p build && cd build +cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=1 -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" ../llvm +make -j +sudo make install +``` - * LLVM: https://github.com/RadeonOpenCompute/llvm.git amd-common branch - * clang: https://github.com/RadeonOpenCompute/clang amd-common branch - * lld: https://github.com/RadeonOpenCompute/lld amd-common branch - * Build Rocm device library - * Checkout https://github.com/RadeonOpenCompute/ROCm-Device-Libs.git master branch and build it with clang built from the last step. - +``` +export PATH=/opt/rocm/llvm/bin:$PATH +git clone -b master https://github.com/RadeonOpenCompute/ROCm-Device-Libs.git +cd ROCm-Device-Libs +mkdir -p build && cd build +CC=clang CXX=clang++ cmake -DLLVM_DIR=/opt/rocm/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_WERROR=1 -DLLVM_ENABLE_ASSERTIONS=1 .. +make -j +sudo make install +``` + * Build HIP - * Checkout https://github.com/ROCm-Developer-Tools/HIP.git master branch and build it with HCC installed with ROCm packages. Please use -DHIP_COMPILER=clang with cmake to enable hip-clang. - +``` +git clone -b master https://github.com/ROCm-Developer-Tools/HIP.git +cd HIP +mkdir -p build && cd build +cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm/hip -DHIP_COMPILER=clang -DCMAKE_BUILD_TYPE=Release .. +make -j +sudo make install +``` + * Default paths and environment variables: * By default HIP looks for HSA in /opt/rocm/hsa (can be overridden by setting HSA_PATH environment variable)