From d4bb38305e59317607fb4e9275d16917ac375051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Tue, 19 Dec 2023 11:28:25 +0100 Subject: [PATCH] CI: fix HIP install script Fix CI HIP install script to support alpaka'S CI base container instead require native ROCM containers. - ROCm 6 shipped clang is broken and `clang -v` is failing. Therefore this PR is changing all compiler `-v` querries to `--version`. - CMake: set ROCM 6.0 as supported version CI_FILTER: ^linux_hipcc --- cmake/alpakaCommon.cmake | 16 +++++++++++++--- script/install_clang.sh | 2 +- script/install_hip.sh | 26 +++++++++++++++++++------- script/install_oneapi.sh | 4 ++-- script/run.sh | 2 +- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/cmake/alpakaCommon.cmake b/cmake/alpakaCommon.cmake index 65dcdb86428d..d1140b7f41d8 100644 --- a/cmake/alpakaCommon.cmake +++ b/cmake/alpakaCommon.cmake @@ -502,12 +502,18 @@ if(alpaka_ACC_GPU_HIP_ENABLE) # supported HIP version range set(_alpaka_HIP_MIN_VER 5.0) - set(_alpaka_HIP_MAX_VER 5.5) + set(_alpaka_HIP_MAX_VER 5.7) + set(_alpaka_HIP_NEXT_MAJOR_MIN_VER 6.0) + find_package(hip "${_alpaka_HIP_MIN_VER}...${_alpaka_HIP_MAX_VER}") if(NOT TARGET hip) message(WARNING "Could not find HIP <=v${_alpaka_HIP_MAX_VER}. Now searching for unsupported HIP >v${_alpaka_HIP_MAX_VER}") find_package(hip "${_alpaka_HIP_MAX_VER}") + if(NOT TARGET hip) + message(WARNING "Could not find HIP >=v${_alpaka_HIP_MAX_VER}. Now searching for unsupported HIP >v${_alpaka_HIP_NEXT_MAJOR_MIN_VER}") + find_package(hip "${_alpaka_HIP_NEXT_MAJOR_MIN_VER}") + endif() endif() if(NOT TARGET hip) @@ -525,17 +531,21 @@ if(alpaka_ACC_GPU_HIP_ENABLE) # hiprand requires ROCm implementation of random numbers by rocrand # hip::hiprand is currently not expressing this dependency find_package(rocrand REQUIRED CONFIG - HINTS "${HIP_ROOT_DIR}/rocrand" + HINTS "${ROCM_ROOT_DIR}" + HINTS "${ROCM_ROOT_DIR}/rocrand" + HINTS "/opt/rocm" HINTS "/opt/rocm/rocrand") if(rocrand_FOUND) target_link_libraries(alpaka INTERFACE roc::rocrand) else() - MESSAGE(FATAL_ERROR "Could not find rocRAND (also searched in: HIP_ROOT_DIR=${HIP_ROOT_DIR}/rocrand).") + MESSAGE(FATAL_ERROR "Could not find rocRAND (also searched in: ROCM_ROOT_DIR=${ROCM_ROOT_DIR}/rocrand).") endif() # HIP random numbers find_package(hiprand REQUIRED CONFIG + HINTS "${HIP_ROOT_DIR}/" HINTS "${HIP_ROOT_DIR}/hiprand" + HINTS "/opt/rocm" HINTS "/opt/rocm/hiprand") if(hiprand_FOUND) target_link_libraries(alpaka INTERFACE hip::hiprand) diff --git a/script/install_clang.sh b/script/install_clang.sh index 55238e06f7ca..8c8382c90eee 100755 --- a/script/install_clang.sh +++ b/script/install_clang.sh @@ -68,4 +68,4 @@ then fi which "${CXX}" -${CXX} -v +${CXX} --version diff --git a/script/install_hip.sh b/script/install_hip.sh index 78f6107af580..9a1bd568146d 100755 --- a/script/install_hip.sh +++ b/script/install_hip.sh @@ -12,23 +12,35 @@ source ./script/set.sh : "${ALPAKA_CI_HIP_ROOT_DIR?'ALPAKA_CI_HIP_ROOT_DIR must be specified'}" : "${ALPAKA_CI_HIP_VERSION?'ALPAKA_CI_HIP_VERSION must be specified'}" +function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } + if agc-manager -e rocm@${ALPAKA_CI_HIP_VERSION} ; then export ROCM_PATH=$(agc-manager -b rocm@${ALPAKA_CI_HIP_VERSION}) else travis_retry apt-get -y --quiet update travis_retry apt-get -y --quiet install wget gnupg2 # AMD container keys are outdated and must be updated + source /etc/os-release wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | sudo apt-key add - + echo "deb https://repo.radeon.com/rocm/apt/${ALPAKA_CI_HIP_VERSION} ${VERSION_CODENAME} main" | sudo tee -a /etc/apt/sources.list.d/rocm.list travis_retry apt-get -y --quiet update - # AMD container are not shipped with rocrand/hiprand - travis_retry sudo apt-get -y --quiet install rocrand + ALPAKA_CI_ROCM_VERSION=$ALPAKA_CI_HIP_VERSION + # append .0 if no patch level is defined + if ! echo $ALPAKA_CI_ROCM_VERSION | grep -Eq '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+'; then + ALPAKA_CI_ROCM_VERSION="${ALPAKA_CI_ROCM_VERSION}.0" + fi + + apt install --no-install-recommends -y rocm-llvm${ALPAKA_CI_ROCM_VERSION} hip-runtime-amd${ALPAKA_CI_ROCM_VERSION} rocm-dev${ALPAKA_CI_ROCM_VERSION} rocm-utils${ALPAKA_CI_ROCM_VERSION} rocrand-dev${ALPAKA_CI_ROCM_VERSION} rocminfo${ALPAKA_CI_ROCM_VERSION} rocm-cmake${ALPAKA_CI_ROCM_VERSION} rocm-device-libs${ALPAKA_CI_ROCM_VERSION} rocm-core${ALPAKA_CI_ROCM_VERSION} rocm-smi-lib${ALPAKA_CI_ROCM_VERSION} + if [ $(version ${ALPAKA_CI_ROCM_VERSION}) -ge $(version "6.0.0") ]; then + apt install --no-install-recommends -y hiprand-dev${ALPAKA_CI_ROCM_VERSION} + fi export ROCM_PATH=/opt/rocm fi # ROCM_PATH required by HIP tools -export HIP_PATH=${ROCM_PATH}/hip - -export HIP_LIB_PATH=${HIP_PATH}/lib +export HIP_PLATFORM="amd" +export HIP_DEVICE_LIB_PATH=${ROCM_PATH}/amdgcn/bitcode +export HSA_PATH=$ROCM_PATH export PATH=${ROCM_PATH}/bin:$PATH export PATH=${ROCM_PATH}/llvm/bin:$PATH @@ -38,8 +50,8 @@ sudo update-alternatives --install /usr/bin/clang++ clang++ ${ROCM_PATH}/llvm/bi sudo update-alternatives --install /usr/bin/cc cc ${ROCM_PATH}/llvm/bin/clang 50 sudo update-alternatives --install /usr/bin/c++ c++ ${ROCM_PATH}/llvm/bin/clang++ 50 -export LD_LIBRARY_PATH=${ROCM_PATH}/lib64:${ROCM_PATH}/hiprand/lib:${LD_LIBRARY_PATH}:${ROCM_PATH}/llvm/lib -export CMAKE_PREFIX_PATH=${ROCM_PATH}:${ROCM_PATH}/hiprand:${CMAKE_PREFIX_PATH:-} +export LD_LIBRARY_PATH=${ROCM_PATH}/lib:${ROCM_PATH}/lib64:${ROCM_PATH}/hiprand/lib:${ROCM_PATH}/hip/lib:${ROCM_PATH}/llvm/lib:${LD_LIBRARY_PATH} +export CMAKE_PREFIX_PATH=${ROCM_PATH}:${ROCM_PATH}/hiprand:${ROCM_PATH}/hip:${CMAKE_PREFIX_PATH:-} if [[ "$CI_RUNNER_TAGS" =~ .*cpuonly.* ]] ; then # In cases where the compile-only job is executed on a GPU runner but with different kinds of accelerators diff --git a/script/install_oneapi.sh b/script/install_oneapi.sh index 0494c1f4eeed..507799f56086 100755 --- a/script/install_oneapi.sh +++ b/script/install_oneapi.sh @@ -44,7 +44,7 @@ then fi which "${CXX}" -${CXX} -v +${CXX} --version which "${CC}" -${CC} -v +${CC} --version sycl-ls diff --git a/script/run.sh b/script/run.sh index b3309c3e941b..4249c21c8d75 100755 --- a/script/run.sh +++ b/script/run.sh @@ -104,7 +104,7 @@ then fi which "${CXX}" - ${CXX} -v + ${CXX} --version fi if [ "$ALPAKA_CI_OS_NAME" = "Linux" ]