Last active
April 8, 2020 12:57
-
-
Save psychocoderHPC/0f451dbbd79ee9a15dfaf3cb8298406e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # IMPORTANT: The script is currently not checking for compile time errors | |
| # | |
| # issue I have: | |
| # HIP - https://github.com/ROCm-Developer-Tools/HIP/blob/5f1420a229b41662f1f3f178de56daa10028d39c/CMakeLists.txt#L317-L318 | |
| # both lines must be removed because cmake says `hiprtc is not defined` | |
| # | |
| # rocprofiler (clang issue): | |
| # - /src/core/intercept_queue.h and /src/core/intercept_queue.cpp | |
| # `static std::atomic<rocprofiler_callback_t> dispatch_callback_;` must be `static volatile std::atomic<rocprofiler_callback_t> dispatch_callback_;` | |
| # set empty if you install in user space | |
| export INSTALL_PRIVILEGE=sudo | |
| export HIP_VERSION=3.3.0 | |
| # destination where HIP will be installed to | |
| export INSTALL_HOME=/opt/hip-clang-${HIP_VERSION} | |
| # set compiler which is used to compile clang | |
| # export CC=gcc | |
| # export CXX=g++ | |
| # cmake 3.15+ or newer should be used | |
| # here we use spack to load cmake https://github.com/spack/ | |
| # spack load [email protected] | |
| mkdir build-${HIP_VERSION}-${INSTALL_PRIVILEGE} | |
| cd build-${HIP_VERSION}-${INSTALL_PRIVILEGE} | |
| export BHOME=`pwd` | |
| #BUILD LLVM | |
| git clone https://github.com/RadeonOpenCompute/llvm.git | |
| cd llvm/ | |
| cd tools/ | |
| git clone https://github.com/RadeonOpenCompute/lld | |
| git clone https://github.com/RadeonOpenCompute/clang | |
| cd .. | |
| mkdir build | |
| cd build | |
| cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" .. -DCMAKE_INSTALL_PREFIX=$INSTALL_HOME/llvm | |
| make -j16 | |
| $INSTALL_PRIVILEGE make -j16 install | |
| export HIP_PATH=$INSTALL_HOME | |
| export HIP_CLANG_PATH=$HIP_PATH/llvm/bin | |
| export PATH=$HIP_PATH/llvm/bin:$PATH | |
| export CC=clang | |
| export CXX=clang++ | |
| # BUILD ROCM Device Libs | |
| cd $BHOME | |
| git clone https://github.com/RadeonOpenCompute/ROCm-Device-Libs | |
| cd ROCm-Device-Libs/ | |
| git checkout tags/rocm-hcc-${HIP_VERSION} | |
| mkdir build | |
| cd build/ | |
| export LLVM_BUILD=$INSTALL_HOME/llvm | |
| cmake -DLLVM_DIR=$LLVM_BUILD/ -DCMAKE_INSTALL_PREFIX=$INSTALL_HOME/llvm .. | |
| make -j 16 | |
| $INSTALL_PRIVILEGE make -j 16 install | |
| #roctracer | |
| cd $BHOME | |
| git clone https://github.com/ROCm-Developer-Tools/roctracer | |
| cd roctracer | |
| git checkout tags/roc-${HIP_VERSION} | |
| mkdir build | |
| cd build | |
| pip install --user CppHeaderParser argparse | |
| export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:/opt/rocm | |
| export HIP_PATH=$INSTALL_HOME | |
| export HCC_HOME=/opt/rocm/hcc | |
| cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_HOME .. | |
| make -j 16 | |
| $INSTALL_PRIVILEGE make install | |
| #rocprofiler | |
| cd $BHOME | |
| export CMAKE_DEBUG_TRACE=1 | |
| git clone https://github.com/ROCm-Developer-Tools/rocprofiler.git | |
| cd rocprofiler | |
| git checkout tags/roc-${HIP_VERSION} | |
| mkdir build | |
| cd build | |
| export CMAKE_PREFIX_PATH=/opt/rocm/include/hsa:/opt/rocm:$CMAKE_PREFIX_PATH | |
| cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_HOME | |
| make -j 16 | |
| $INSTALL_PRIVILEGE make install | |
| #BUILD HIP | |
| cd $BHOME | |
| git clone https://github.com/ROCm-Developer-Tools/HIP.git | |
| cd HIP/ | |
| git checkout tags/rocm-${HIP_VERSION} | |
| mkdir build | |
| cd build | |
| export PATH=$INSTALL_HOME/llvm/bin:$PATH | |
| cmake -DHIP_COMPILER=clang .. -DCMAKE_BUILD_TYPE=Release -DHIP_PLATFORM=hcc -DUSE_PROF_API=1 -DPROF_API_HEADER_PATH=$INSTALL_HOME//roctracer/include/ext -DCMAKE_INSTALL_PREFIX=$INSTALL_HOME/ | |
| make -j 16 | |
| $INSTALL_PRIVILEGE make -j 16 install | |
| export HIP_PLATFORM=clang | |
| export HIP_CLANG_PATH=$HIP_PATH/llvm/bin | |
| export DEVICE_LIB_PAT=$HIP_PATH/llvm/lib | |
| export PATH=$HIP_PATH/bin:$HIP_PATH/llvm/bin:$HIP_PATH/rocprofiler/bin:$PATH | |
| export LD_LIBRARY_PATH=$HIP_PATH/lib:$HIP_PATH/llvm/lib:$HIP_PATH/roctracer:$HIP_PATH/rocprofiler/lib:$LD_LIBRARY_PATH | |
| export CMAKE_PREFIX_PATH=$HIP_PATH:$HIP_PATH/llvm:$CMAKE_PREFIX_PATH | |
| cd $BHOME | |
| git clone https://github.com/ROCmSoftwarePlatform/rocRAND.git | |
| cd rocRAND | |
| git checkout tags/rocm-${HIP_VERSION} | |
| mkdir build | |
| cd build | |
| export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:/opt/rocm | |
| export CXX=hcc | |
| HIP_PLATFORM=hcc cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_HOME -DCMAKE_CXX_COMPILER=hcc -Dhip_DIR=$INSTALL_HOME/ -DBUILD_TEST=OFF | |
| make -j 16 | |
| $INSTALL_PRIVILEGE make install | |
| echo "\n\nThe following environment variables should be set" | |
| echo "----------------------------------------" | |
| echo "export HIP_PATH=$INSTALL_HOME" | |
| echo "export HCC_HOME=/opt/rocm/hcc" | |
| echo "export HIP_PLATFORM=clang" | |
| echo 'export HIP_CLANG_PATH=$HIP_PATH/llvm/bin' | |
| echo 'export DEVICE_LIB_PAT=$HIP_PATH/llvm/lib' | |
| echo 'export PATH=$HIP_PATH/bin:$HIP_PATH/llvm/bin:$HIP_PATH/rocprofiler/bin:$PATH' | |
| echo 'export LD_LIBRARY_PATH=$HIP_PATH/lib:$HIP_PATH/llvm/lib:$HIP_PATH/roctracer:$HIP_PATH/rocprofiler/lib:$LD_LIBRARY_PATH' | |
| echo 'export CMAKE_PREFIX_PATH=$HIP_PATH:$HIP_PATH/llvm:$CMAKE_PREFIX_PATH' | |
| echo"----------------------------------------" | |
| echo "... or use a module system and use the following lines as templte" | |
| echo"----------------------------------------" | |
| echo 'module-whatis "HIP clang environment to compute on AMD GPUs"' | |
| echo 'proc ModulesHelp { } {' | |
| echo 'puts stderr "HIP clang environment"' | |
| echo '}' | |
| echo 'setenv HIP_PATH "/opt/hip-clang-'${HIP_VERSION}'"' | |
| echo 'setenv HIP_PLATFORM "clang"' | |
| echo 'setenv HIP_CLANG_PATH "$env(HIP_PATH)/llvm/bin"' | |
| echo 'setenv DEVICE_LIB_PAT "$env(HIP_PATH)/llvm/lib"' | |
| echo 'prepend-path PATH "$env(HIP_PATH)/rocprofiler/bin"' | |
| echo 'prepend-path PATH "$env(HIP_PATH)/llvm/bin"' | |
| echo 'prepend-path PATH "$env(HIP_PATH)/bin"' | |
| echo 'prepend-path LD_LIBRARY_PATH "$env(HIP_PATH)/hiprand/lib"' | |
| echo 'prepend-path LD_LIBRARY_PATH "$env(HIP_PATH)/rocrand/lib"' | |
| echo 'prepend-path LD_LIBRARY_PATH "$env(HIP_PATH)/lib"' | |
| echo 'prepend-path LD_LIBRARY_PATH "$env(HIP_PATH)/rocprofiler/lib"' | |
| echo 'prepend-path LD_LIBRARY_PATH "$env(HIP_PATH)/roctracer"' | |
| echo 'prepend-path LD_LIBRARY_PATH "$env(HIP_PATH)/llvm/lib"' | |
| echo 'prepend-path LD_LIBRARY_PATH "$env(HIP_PATH)/lib"' | |
| echo 'prepend-path CMAKE_PREFIX_PATH "$env(HIP_PATH)/llvm"' | |
| echo 'prepend-path CMAKE_PREFIX_PATH "$env(HIP_PATH)"' | |
| echo 'setenv CC "$env(HIP_PATH)/llvm/bin/clang"' | |
| echo 'setenv CXX "$env(HIP_PATH)/llvm/bin/clang++"' | |
| echo"----------------------------------------" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment