From fd6eabd5feff575b03123e2f1d4d8636ac1afe81 Mon Sep 17 00:00:00 2001 From: Kevin Gleason Date: Tue, 30 Aug 2022 15:33:33 +0000 Subject: [PATCH] Incorporate Eugene's feedback. --- .github/actions/setup-build/action.yml | 19 +++++------ .github/workflows/buildAndTest.yml | 30 +++++++--------- .github/workflows/lint.yml | 3 +- build_tools/github_actions/ci_build_llvm.sh | 34 ++++++++----------- .../github_actions/ci_build_stablehlo.sh | 2 +- 5 files changed, 37 insertions(+), 51 deletions(-) diff --git a/.github/actions/setup-build/action.yml b/.github/actions/setup-build/action.yml index 70dcae5e662..f8cc0af6fa7 100644 --- a/.github/actions/setup-build/action.yml +++ b/.github/actions/setup-build/action.yml @@ -1,27 +1,24 @@ # Copyright 2022 The StableHLO Authors. # The setup-build action gets everything needed by buildAndTest into the workspace. -# This checks out the proper revision of the LLVM repository, installs ninja, and sets -# up the ccache for faster re-compilation. name: "Setup build environment (ninja, ccache, llvm, lld)" inputs: - llvm-ref: + llvm-version: description: | - LLVM Commit Ref for checkout and build. Used for ccache value and checkout. + LLVM version for checkout and build. Used for ccache value and checkout. required: true - runs: - # Based on https://github.com/llvm/torch-mlir/blob/main/.github/actions/setup-build/action.yml + # This is a composite action - has a list of steps to execute. using: "composite" steps: - # Checkout llvm at revision specified in input argument. + # Checkout llvm at version specified in input argument. - uses: actions/checkout@v2 with: repository: llvm/llvm-project - ref: ${{ inputs.llvm-ref }} + ref: ${{ inputs.llvm-version }} path: llvm-project fetch-depth: 1 @@ -29,7 +26,7 @@ runs: - name: Install Ninja uses: llvm/actions/install-ninja@55d844821959226fab4911f96f37071c1d4c3268 - # Get LLD + # Get LLD - Improves build speed on Linux - name: Install LLD if: "runner.os == 'Linux'" shell: bash @@ -37,9 +34,9 @@ runs: sudo apt-get install -y lld # Setup C++ caching using ccache. - # Cache key is a combination of OS arch and LLVM ref. + # Cache key is a combination of OS arch and LLVM version. - name: Ccache for C++ compilation uses: hendrikmuhs/ccache-action@v1.2 with: - key: ${{ runner.os }}-stablehlo_build_assets-${{ inputs.llvm-ref }} + key: ${{ runner.os }}-stablehlo_build_assets-${{ inputs.llvm-version }} max-size: 4G diff --git a/.github/workflows/buildAndTest.yml b/.github/workflows/buildAndTest.yml index 945db205904..072f3c30035 100644 --- a/.github/workflows/buildAndTest.yml +++ b/.github/workflows/buildAndTest.yml @@ -6,9 +6,9 @@ on: pull_request: branches: [ main ] push: - branches: [ main ] + branches: [ main, actions ] schedule: - # Always regenerate once every day + # Run buildAndTest workflow once a day - cron: '* 12 * * *' workflow_dispatch: @@ -22,7 +22,6 @@ concurrency: # Build using CMake and run tests. # Use Cached LLVM to improve build times. -# Current setup only builds on linux. jobs: build-test: strategy: @@ -32,40 +31,35 @@ jobs: include: - os-arch: ubuntu-x86_64 os: ubuntu-22.04 - llvm-build-dir: "$GITHUB_WORKSPACE/llvm-build" - stablehlo-build-dir: "$GITHUB_WORKSPACE/build" - os-arch: maci-x86_64 os: macos-latest - llvm-build-dir: "$GITHUB_WORKSPACE/llvm-build-maci" - stablehlo-build-dir: "$GITHUB_WORKSPACE/build-maci" runs-on: ${{ matrix.os }} steps: - - # Check out stablehlo repo - - name: Checkout stablehlo + # Check out StableHLO repo + - name: Checkout StableHLO uses: actions/checkout@v2 - # Read llvm revision from `build_tools/llvm_version.txt` - - name: Get LLVM Revision - id: llvm-revision + # Read LLVM version from `build_tools/llvm_version.txt` + - name: Get LLVM Version + id: llvm-version shell: bash run: | - echo "::set-output name=revision::$(cat ${{ github.workspace }}/build_tools/llvm_version.txt)" + echo "::set-output name=version::$(cat ${{ github.workspace }}/build_tools/llvm_version.txt)" - # Check out LLVM, download Ninja, setup ccache + # Check out LLVM, and install tools for compilation - name: Setup workspace uses: ./.github/actions/setup-build with: - llvm-ref: ${{ steps.llvm-revision.outputs.revision }} + llvm-version: ${{ steps.llvm-version.outputs.version }} # Configuration for linux - name: Configure and Build LLVM os-arch='${{ matrix.os-arch }}' shell: bash run: | - ./build_tools/github_actions/ci_build_llvm.sh "$GITHUB_WORKSPACE/llvm-project/" ${{ matrix.llvm-build-dir }} + ./build_tools/github_actions/ci_build_llvm.sh "$GITHUB_WORKSPACE/llvm-project/" "$GITHUB_WORKSPACE/llvm-build" # Configure for linux - name: Build and Test StableHLO os-arch='${{ matrix.os-arch }}' run: | - ./build_tools/github_actions/ci_build_stablehlo.sh ${{ matrix.llvm-build-dir }} ${{ matrix.stablehlo-build-dir }} + ./build_tools/github_actions/ci_build_stablehlo.sh "$GITHUB_WORKSPACE/llvm-build" "$GITHUB_WORKSPACE/stablehlo-build" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 00c8b87b2ec..67aa7d404c5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,10 +2,9 @@ name: Lint -on: [pull_request] +on: [pull_request, push] jobs: - # Based on https://github.com/iree-org/iree/blob/main/.github/workflows/lint.yml clang-format: if: "github.event_name == 'pull_request'" runs-on: ubuntu-latest diff --git a/build_tools/github_actions/ci_build_llvm.sh b/build_tools/github_actions/ci_build_llvm.sh index 9c769a96398..95f40100547 100755 --- a/build_tools/github_actions/ci_build_llvm.sh +++ b/build_tools/github_actions/ci_build_llvm.sh @@ -14,7 +14,7 @@ # limitations under the License. # This file is similar to build_mlir.sh, but passes different flags for -# cacheing in GitHub Actions to improve build speeds. +# caching in GitHub Actions to improve build speeds. if [[ $# -ne 2 ]] ; then echo "Usage: $0 " @@ -26,36 +26,32 @@ LLVM_SRC_DIR="$1" LLVM_BUILD_DIR="$2" # Check for LLD -FLAGS="" -LLD_FLAG="-DLLVM_ENABLE_LLD=ON" +LLVM_ENABLE_LLD="" if command -v lld &> /dev/null then - echo "lld found, appending flag '$LLD_FLAG'" - FLAGS="$LLD_FLAG" + LLVM_ENABLE_LLD="-DLLVM_ENABLE_LLD=ON" + echo "lld found, compiling with '$LLVM_ENABLE_LLD'" else echo "lld not found, using default linker" fi -# Call cmake -echo "Using additional flags: '$FLAGS'" - cmake -GNinja \ - "$FLAGS" \ - "-B$LLVM_BUILD_DIR" \ "-H$LLVM_SRC_DIR/llvm" \ + "-B$LLVM_BUILD_DIR" \ + -DLLVM_INSTALL_UTILS=ON \ + "$LLVM_ENABLE_LLD" \ + -DLLVM_ENABLE_PROJECTS=mlir \ + -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \ + -DLLVM_INCLUDE_TOOLS=ON \ + -DLLVM_ENABLE_BINDINGS=OFF \ + -DLLVM_BUILD_TOOLS=OFF \ + -DLLVM_INCLUDE_TESTS=OFF \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DLLVM_ENABLE_ASSERTIONS=On \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_C_COMPILER=clang \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DLLVM_BUILD_TOOLS=OFF \ - -DLLVM_ENABLE_ASSERTIONS=On \ - -DLLVM_ENABLE_BINDINGS=OFF \ - -DLLVM_ENABLE_PROJECTS=mlir \ - -DLLVM_INCLUDE_TESTS=OFF \ - -DLLVM_INCLUDE_TOOLS=ON \ - -DLLVM_INSTALL_UTILS=ON \ - -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" + -DCMAKE_C_COMPILER_LAUNCHER=ccache # Build LLVM/MLIR cmake --build "$LLVM_BUILD_DIR" --target all --target mlir-cpu-runner diff --git a/build_tools/github_actions/ci_build_stablehlo.sh b/build_tools/github_actions/ci_build_stablehlo.sh index fe11c1978a0..f130b9c2a60 100755 --- a/build_tools/github_actions/ci_build_stablehlo.sh +++ b/build_tools/github_actions/ci_build_stablehlo.sh @@ -14,7 +14,7 @@ # limitations under the License. # This file is similar to build_mlir.sh, but passes different flags for -# cacheing in GitHub Actions. +# caching in GitHub Actions. # This file gets called on build directory where resources are placed # during `ci_configure`, and builds stablehlo in the directory specified