From ae9b6000c2c9774d434c8d0baed4b5be442dc3fe Mon Sep 17 00:00:00 2001 From: Mike Lau Date: Thu, 18 Apr 2024 13:32:21 +0200 Subject: [PATCH 1/2] (build) add aocc installation --- .github/workflows/build.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2acd7ba98..1daa5f92d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,6 +54,7 @@ jobs: fail-fast: false matrix: system: + - aocc - gfortran - ifort batch: ${{ fromJson(needs.matrix_prep.outputs.batch) }} @@ -105,6 +106,40 @@ jobs: source /opt/intel/oneapi/setvars.sh printenv >> $GITHUB_ENV + - name: Install AOCC compiler + if: matrix.system == 'aocc' + id: aocc-install + run: | + REPO_NAME=aocc_flang + TMP_DIR="$(mktemp -d)" + cd "$TMP_DIR" || exit 42 + git clone https://github.com/zaikunzhang/"$REPO_NAME".git + cd "$REPO_NAME" || exit 42 + AOCC_7Z="aocc_flang.deb.7z.001" + 7za x "$AOCC_7Z" -aoa # -aoa: overwrite all existing files without prompt + sudo apt update && sudo apt install p7zip-full libncurses* -y # libncurses* needed for libtinfo.so + sudo dpkg -i "$TMP_DIR"/"$REPO_NAME"/aocc_flang.deb + rm -rf "$TMP_DIR" + # Run the script that sets the necessary environment variables and then damp them to $GITHUB_ENV + # so that they are available in subsequent steps. + if [[ -d /opt/AMD ]] ; then + AOCCDIR="$(find /opt/AMD -maxdepth 1 -name "aocc-compiler*" -type d -print | sort | tail -n 1)" + AOCC_ENVSH="$(find "$AOCCDIR" -name "*setenv*.sh" -type f)" + #shellcheck disable=SC1090 + source "$AOCC_ENVSH" + AFLANG="$(find "$AOCCDIR" -type f -executable -name "clang-*" | grep -E "clang-[0-9]{2}" | head -1)" + if [[ -n "$AFLANG" ]] ; then sudo ln -s "$AFLANG" "$(dirname "$AFLANG")"/aflang ; fi + export PATH=$(dirname "$AFLANG"):$PATH + else + exit 1 + fi + env | grep -i 'aocc\|AMD' >> "$GITHUB_ENV" + # Show the result of the installation. + echo "The AOCC flang installed is:" + aflang --version + echo "The path to AOCC flang is:" + command -v aflang + - name: Install numpy and matplotlib for analysis unit tests run: | sudo apt-get install -y python3-numpy From 2379e17de70e3f4c5ab62dd3593ede55c6a4bd8e Mon Sep 17 00:00:00 2001 From: Mike Lau Date: Fri, 19 Apr 2024 11:16:19 +0200 Subject: [PATCH 2/2] (set_hierarchical) replace findloc with maxloc for aocc build --- src/setup/set_hierarchical_utils.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup/set_hierarchical_utils.f90 b/src/setup/set_hierarchical_utils.f90 index 50aa1866e..327cb1738 100644 --- a/src/setup/set_hierarchical_utils.f90 +++ b/src/setup/set_hierarchical_utils.f90 @@ -403,13 +403,13 @@ subroutine find_hier_level_orb_elem(hl_temp, hs, m1, m2, accr1, accr2, & !print *,'labels passing: ', trim(adjustl(hl_temp))//'1 ', m1,trim(adjustl(hl_temp))//'2 ',m2 if (any(hs%labels%sink == trim(adjustl(hl_temp))//'1')) then - accr1 = hs%sinks(findloc(hs%labels%sink,trim(adjustl(hl_temp))//'1', 1))%accr + accr1 = hs%sinks( maxloc( merge(0,1,hs%labels%sink==trim(adjustl(hl_temp))//'1' ), 1) )%accr else accr1 = 1. endif if (any(hs%labels%sink == trim(adjustl(hl_temp))//'2')) then - accr2 = hs%sinks(findloc(hs%labels%sink,trim(adjustl(hl_temp))//'2', 1))%accr + accr2 = hs%sinks( maxloc( merge(0,1,hs%labels%sink==trim(adjustl(hl_temp))//'2' ), 1) )%accr else accr2 = 1. endif