Skip to content

Commit

Permalink
Incorporate Eugene's feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
GleasonK committed Aug 30, 2022
1 parent 54a9778 commit fd6eabd
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 51 deletions.
19 changes: 8 additions & 11 deletions .github/actions/setup-build/action.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
# 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

# Get ninja for cmake build.
- 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
run: |
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/[email protected]
with:
key: ${{ runner.os }}-stablehlo_build_assets-${{ inputs.llvm-ref }}
key: ${{ runner.os }}-stablehlo_build_assets-${{ inputs.llvm-version }}
max-size: 4G
30 changes: 12 additions & 18 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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:
Expand All @@ -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"
3 changes: 1 addition & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 15 additions & 19 deletions build_tools/github_actions/ci_build_llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path/to/llvm> <build_dir>"
Expand All @@ -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
2 changes: 1 addition & 1 deletion build_tools/github_actions/ci_build_stablehlo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fd6eabd

Please sign in to comment.