From 551dded61e0193188c1f5dda4968c6c99805ec8d Mon Sep 17 00:00:00 2001 From: Jerry Zhang Jian Date: Fri, 18 Oct 2024 01:46:11 -0700 Subject: [PATCH 1/5] github: rework clang-compilation CI Signed-off-by: Jerry Zhang Jian --- .github/workflows/clang-compilation.yml | 158 +++++++++++++++++------- 1 file changed, 112 insertions(+), 46 deletions(-) diff --git a/.github/workflows/clang-compilation.yml b/.github/workflows/clang-compilation.yml index dae68e44f..3dc066965 100644 --- a/.github/workflows/clang-compilation.yml +++ b/.github/workflows/clang-compilation.yml @@ -1,61 +1,127 @@ name: Clang (LLVM) intrinsic test case compilation -on: [push] +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: # Allows manual triggering of the workflow jobs: - build: + build-and-test: runs-on: ubuntu-latest strategy: matrix: - llvm-version: ["main", "latest-rel"] + llvm-version: [latest-rel] + + env: + COMPILER: llvm-project/build/bin/clang + EXTRA_CFLAGS: "-target riscv64" + steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Checkout rvv-intrinsic-doc + uses: actions/checkout@v4 with: - python-version: '3.11' - - name: Prerequisites - run: | - sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev dejagnu - - name: Install dependencies - run: | - pip install --user junitparser - - name: Download LLVM + repository: riscv-non-isa/rvv-intrinsic-doc + path: rvv-intrinsic-doc + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install Python dependencies run: | - cd .. - rm -rf llvm-project - git clone https://github.com/llvm/llvm-project -j `nproc` - - name: Checkout LLVM version + pip install junitparser + working-directory: ${{ github.workspace }} + + - name: Set up LLVM (latest release) + if: matrix.llvm-version == 'latest-rel' run: | - cd ../llvm-project - if [ "${{ matrix.llvm-version }}" = "latest-rel" ]; then - latestTag=$(git describe --tags `git rev-list --tags --max-count=1`) - git checkout $latestTag + latest_release=$(curl -sL https://api.github.com/repos/llvm/llvm-project/releases/latest) + download_url=$(echo "$latest_release" | jq -r '.assets[] | select(.name | endswith("Linux-X64.tar.xz")) | .browser_download_url') + if [ -z "$download_url" ]; then + echo "Error: Could not find Linux X64 tarball URL" + exit 1 fi - - name: Build LLVM with Ninja - run: | - cd ../llvm-project - mkdir build && cd build - cmake -G Ninja \ - -DCMAKE_C_COMPILER=gcc \ - -DCMAKE_CXX_COMPILER=g++ \ - -DLLVM_TARGETS_TO_BUILD="RISCV" \ - -DLLVM_PARALLEL_LINK_JOBS=12 \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_SHARED_LIBS=OFF \ - -DLLVM_DEFAULT_TARGET_TRIPLE="riscv64-unknown-linux-gnu" \ - -DLLVM_ENABLE_PROJECTS="clang;lld" \ - ../llvm - ninja -j `nproc` - echo $(pwd) - ls bin - - name: Run compilation test, non-overloaded intrinsics (default (TAMA) policy) + filename=$(basename "$download_url") + echo "Downloading $filename..." + curl -sL -o "$filename" "$download_url" + tar xf "$filename" + extracted_dir=$(tar tf "$filename" | head -1 | cut -f1 -d"/") + # Set the COMPILER environment variable + echo "COMPILER=${{ github.workspace }}/$extracted_dir/bin/clang" >> $GITHUB_ENV + working-directory: ${{ github.workspace }} + + - name: Install prerequisites (main) + if: matrix.llvm-version == 'main' run: | - make -C rvv-intrinsic-generator run-api-testing run-bfloat16-api-testing run-vector-crypto-api-testing COMPILER=$(pwd)/../llvm-project/build/bin/clang EXTRA_CFLAGS="-target riscv64" - - name: Run compilation test, overloaded intrinsics (default (TAMA) policy) + sudo apt-get update + sudo apt-get install -y ninja-build + working-directory: ${{ github.workspace }} + + - name: Checkout LLVM (main) + if: matrix.llvm-version == 'main' + uses: actions/checkout@v4 + with: + repository: llvm/llvm-project + path: llvm-project + fetch-depth: 1 + + - name: Configure & Build LLVM (main) + if: matrix.llvm-version == 'main' run: | - make -C rvv-intrinsic-generator run-overloaded-api-testing run-bfloat16-overloaded-api-testing run-vector-crypto-overloaded-api-testing COMPILER=$(pwd)/../llvm-project/build/bin/clang EXTRA_CFLAGS="-target riscv64" - - name: Run compilation test, non-overloaded intrinsics (non-default policy) + mkdir -p build && cd build + cmake -G Ninja ../llvm \ + -DCMAKE_C_COMPILER=`which clang` \ + -DCMAKE_CXX_COMPILER=`which clang++` \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_PROJECTS="clang" \ + -DLLVM_TARGETS_TO_BUILD="RISCV" \ + -DLLVM_DEFAULT_TARGET_TRIPLE="riscv64-unknown-linux-gnu" + ninja + working-directory: llvm-project + + - name: Test + # shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"' + shell: bash run: | - make -C rvv-intrinsic-generator run-policy-api-testing run-bfloat16-policy-api-testing run-vector-crypto-policy-api-testing COMPILER=$(pwd)/../llvm-project/build/bin/clang EXTRA_CFLAGS="-target riscv64" - - name: Run compilation test, overloaded intrinsics (non-default policy) + export PYTHONUNBUFFERED=1 + make -C rvv-intrinsic-generator run-vector-crypto-api-testing SHELL="bash -x" + continue-on-error: true + working-directory: rvv-intrinsic-doc + + - name: show log + # shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"' + shell: bash + if: always() run: | - make -C rvv-intrinsic-generator run-policy-overloaded-api-testing run-bfloat16-policy-overloaded-api-testing run-vector-crypto-policy-overloaded-api-testing COMPILER=$(pwd)/../llvm-project/build/bin/clang EXTRA_CFLAGS="-target riscv64" + ls -al auto-generated/vector-crypto/api-testing/ + cat auto-generated/vector-crypto/api-testing/*.log + continue-on-error: true + working-directory: rvv-intrinsic-doc + + # - name: Run compilation test, non-overloaded intrinsics (default (TAMA) policy) + # run: | + # set -e # Exit on any error + # make -C rvv-intrinsic-generator run-api-testing run-bfloat16-api-testing run-vector-crypto-api-testing + # working-directory: rvv-intrinsic-doc + + # - name: Run compilation test, overloaded intrinsics (default (TAMA) policy) + # run: | + # set -e # Exit on any error + # make -C rvv-intrinsic-generator run-overloaded-api-testing run-bfloat16-overloaded-api-testing run-vector-crypto-overloaded-api-testing + # working-directory: rvv-intrinsic-doc + + # - name: Run compilation test, non-overloaded intrinsics (non-default policy) + # run: | + # set -e # Exit on any error + # make -C rvv-intrinsic-generator run-policy-api-testing run-bfloat16-policy-api-testing run-vector-crypto-policy-api-testing + # working-directory: rvv-intrinsic-doc + + # - name: Run compilation test, overloaded intrinsics (non-default policy) + # run: | + # set -e # Exit on any error + # make -C rvv-intrinsic-generator run-policy-overloaded-api-testing run-bfloat16-policy-overloaded-api-testing run-vector-crypto-policy-overloaded-api-testing + # working-directory: rvv-intrinsic-doc From 7921843de011dd1a8e424d15852452c558b6b2d2 Mon Sep 17 00:00:00 2001 From: Jerry Zhang Jian Date: Thu, 24 Oct 2024 10:18:59 -0700 Subject: [PATCH 2/5] makefile: change to stdout/err explicit redirection Signed-off-by: Jerry Zhang Jian --- rvv-intrinsic-generator/Makefile.api | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rvv-intrinsic-generator/Makefile.api b/rvv-intrinsic-generator/Makefile.api index 94affa72c..f5a659b51 100644 --- a/rvv-intrinsic-generator/Makefile.api +++ b/rvv-intrinsic-generator/Makefile.api @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### +SHELL := /bin/bash CFLAGS?=-O -Werror=implicit-function-declaration -menable-experimental-extensions ARCH_FLAG?=-march=rv64gcv_zfh_zvbb_zvbc_zvfbfmin_zvfbfwma_zvfh_zvkng_zvksg_zvl512b @@ -39,4 +40,6 @@ clean: rm -f test_report.xml %.log: $(BASE_DIR)/%.c - -$(CC) $< -S -o /dev/null $(ARCH_FLAG) $(CFLAGS) $(EXTRA_CFLAGS) &> $@ + @echo "Testing $<..." + -bash -c "$(CC) $< -S -o /dev/null $(ARCH_FLAG) $(CFLAGS) $(EXTRA_CFLAGS)" > $@ 2>&1 + @echo "Completed testing $< (log size: $$(wc -c < $@))" \ No newline at end of file From a35c09c789e8e37ede9240367209173e7af3470d Mon Sep 17 00:00:00 2001 From: Jerry Zhang Jian Date: Thu, 24 Oct 2024 11:05:50 -0700 Subject: [PATCH 3/5] fixup! github: rework clang-compilation CI Signed-off-by: Jerry Zhang Jian --- .github/workflows/clang-compilation.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/clang-compilation.yml b/.github/workflows/clang-compilation.yml index 3dc066965..1fe34913e 100644 --- a/.github/workflows/clang-compilation.yml +++ b/.github/workflows/clang-compilation.yml @@ -84,10 +84,9 @@ jobs: working-directory: llvm-project - name: Test - # shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"' - shell: bash + shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"' + # shell: bash run: | - export PYTHONUNBUFFERED=1 make -C rvv-intrinsic-generator run-vector-crypto-api-testing SHELL="bash -x" continue-on-error: true working-directory: rvv-intrinsic-doc From 8aaa4fbe45ac4f2097f0354817840d0f571fd5be Mon Sep 17 00:00:00 2001 From: Jerry Zhang Jian Date: Thu, 24 Oct 2024 11:13:56 -0700 Subject: [PATCH 4/5] fixup! makefile: change to stdout/err explicit redirection Signed-off-by: Jerry Zhang Jian --- rvv-intrinsic-generator/Makefile.api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rvv-intrinsic-generator/Makefile.api b/rvv-intrinsic-generator/Makefile.api index f5a659b51..48309694c 100644 --- a/rvv-intrinsic-generator/Makefile.api +++ b/rvv-intrinsic-generator/Makefile.api @@ -41,5 +41,5 @@ clean: %.log: $(BASE_DIR)/%.c @echo "Testing $<..." - -bash -c "$(CC) $< -S -o /dev/null $(ARCH_FLAG) $(CFLAGS) $(EXTRA_CFLAGS)" > $@ 2>&1 + -bash -c "$(CC) $< -S -o /dev/null $(ARCH_FLAG) $(CFLAGS) $(EXTRA_CFLAGS)" 2>&1 | tee $@ @echo "Completed testing $< (log size: $$(wc -c < $@))" \ No newline at end of file From 731913eef5598f3920c93297238926d2152db9dd Mon Sep 17 00:00:00 2001 From: Jerry Zhang Jian Date: Thu, 24 Oct 2024 11:25:56 -0700 Subject: [PATCH 5/5] ci: exp 3 shells Signed-off-by: Jerry Zhang Jian --- .github/workflows/clang-compilation.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-compilation.yml b/.github/workflows/clang-compilation.yml index 1fe34913e..14b866bd5 100644 --- a/.github/workflows/clang-compilation.yml +++ b/.github/workflows/clang-compilation.yml @@ -83,9 +83,22 @@ jobs: ninja working-directory: llvm-project - - name: Test + - name: Test1 shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"' - # shell: bash + run: | + make -C rvv-intrinsic-generator run-vector-crypto-api-testing SHELL="bash -x" + continue-on-error: true + working-directory: rvv-intrinsic-doc + + - name: Test2 + shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' + run: | + make -C rvv-intrinsic-generator run-vector-crypto-api-testing SHELL="bash -x" + continue-on-error: true + working-directory: rvv-intrinsic-doc + + - name: Test3 + shell: script -q -e -c "$(printf "'%s' " "$@")" run: | make -C rvv-intrinsic-generator run-vector-crypto-api-testing SHELL="bash -x" continue-on-error: true