Skip to content

Bazel

Bazel #207

Workflow file for this run

name: Bazel
on:
schedule:
- cron: 0 0 * * *
push:
branches:
- main
paths:
- '.github/workflows/enzyme-bazel.yml'
- 'enzyme/Enzyme/**'
- 'enzyme/includes/**'
- 'enzyme/test/**'
- 'enzyme/tools/**'
- 'enzyme/BUILD'
- 'enzyme/WORKSPACE'
pull_request:
branches:
- main
paths:
- '.github/workflows/enzyme-bazel.yml'
- 'enzyme/Enzyme/**'
- 'enzyme/includes/**'
- 'enzyme/test/**'
- 'enzyme/tools/**'
- 'enzyme/BUILD'
- 'enzyme/WORKSPACE'
merge_group:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
build:
name: Reactant Build - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build: ["Release"] # "RelWithDebInfo"
llbuild: ["Release"]
os: [linux-x86-n2-32]
timeout-minutes: 500
container:
image: ${{ (contains(matrix.os, 'linux') && 'ghcr.io/enzymead/reactant-docker-images@sha256:91e1edb7a7c869d5a70db06e417f22907be0e67ca86641d48adcea221fedc674' ) || '' }}
steps:
- name: Install dependencies
run: |
apt-get update
apt-get install -y binutils ninja-build cmake gcc g++ python3 python3-dev
- uses: actions/checkout@v4
with:
path: 'Reactant'
- uses: actions/checkout@v4
with:
repository: 'llvm/llvm-project'
ref: '4749bf56a65e38ee7b05ac7f9fe261aab6cb5bc6'
path: 'llvm-project'
- uses: actions/checkout@v4
with:
repository: 'EnzymeAD/Enzyme-JaX'
path: 'Enzyme-JaX'
- uses: actions/checkout@v4
with:
repository: 'wsmoses/Enzyme-GPU-Tests'
path: 'Enzyme-GPU-Tests'
- name: Set BASE_DIR
# We have to use `${GITHUB_WORKSPACE}` instead of `github.workspace` because GitHub
# is terrible and the two don't match inside containers:
# https://github.com/actions/runner/issues/2058
run: |
BASE_DIR=${GITHUB_WORKSPACE}
# Make sure this directory exists, for good measure
ls -lhrt "${BASE_DIR}"/Reactant
ls -lhrt "${BASE_DIR}"/Enzyme-JaX
ls -lhrt "${BASE_DIR}"/llvm-project
echo "BASE_DIR=${BASE_DIR}" >> ${GITHUB_ENV}
- name: Get MLIR commit hash
id: mlir-commit
working-directory: 'llvm-project'
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Cache MLIR
id: cache-mlir
uses: actions/cache@v4
with:
path: ${{ env.BASE_DIR }}/llvm-project/mlir-build
key: ${{ matrix.llbuild }}-${{ matrix.os }}-mlir-${{ steps.mlir-commit.outputs.sha_short }}
- name: MLIR build
if: steps.cache-mlir.outputs.cache-hit != 'true'
working-directory: ${{ env.BASE_DIR }}/'llvm-project'
run: |
mkdir mlir-build && cd mlir-build && cmake ../llvm -GNinja -DLLVM_ENABLE_PROJECTS="llvm;clang;mlir" -DLLVM_ENABLE_RUNTIMES=openmp -DCMAKE_BUILD_TYPE=${{ matrix.llbuild }} \
-DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_TARGETS_TO_BUILD="X86;NVPTX" \
-DLLVM_USE_LINKER=gold -DLLVM_PARALLEL_LINK_JOBS=2 \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF -DCLANG_ENABLE_ARCMT=OFF \
-DLLVM_OPTIMIZED_TABLEGEN=ON && ninja || echo "already built"
- name: Reactant build
working-directory: ${{ env.BASE_DIR }}/'Reactant'
run: |
mkdir reactant-build && cd reactant-build
cmake ../enzyme -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DLLVM_DIR=${{ env.BASE_DIR }}/llvm-project/mlir-build
ninja
- uses: bazel-contrib/[email protected]
name: Set up Bazel
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}-${{ matrix.os }}
# Share repository cache between workflows.
repository-cache: true
bazelisk-version: 1.x
- name: Set BAZEL_FLAGS
shell: bash
run: |
set -e
BAZEL_FLAGS=""
BAZEL_FLAGS="${BAZEL_FLAGS} --linkopt=-fuse-ld=lld"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=TPU_TOPOLOGY"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=TPU_WORKER_ID"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=TPU_SKIP_MDS_QUERY=true"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=TPU_TOPOLOGY_WRAP"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=TPU_CHIPS_PER_HOST_BOUNDS"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=TPU_ACCELERATOR_TYPE"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=TPU_RUNTIME_METRICS_PORTS"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=TPU_TOPOLOGY_ALT"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=TPU_HOST_BOUNDS"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=TPU_WORKER_HOSTNAMES"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=CHIPS_PER_HOST_BOUNDS"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=HOST_BOUNDS"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=ALT=false"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=WRAP"
BAZEL_FLAGS="${BAZEL_FLAGS} --test_env=VBAR_CONTROL_SERVICE_URL"
BAZEL_FLAGS="${BAZEL_FLAGS} --repo_env=CC=`which clang`"
BAZEL_FLAGS="${BAZEL_FLAGS} --define=using_clang=true"
echo "BAZEL_FLAGS=${BAZEL_FLAGS}" >> "${GITHUB_ENV}"
- name: EnzymeJaX build
working-directory: ${{ env.BASE_DIR }}/'Enzyme-JaX'
run: |
bazel build $BAZEL_FLAGS --color=yes -c opt //:libRaise.so --test_output=errors
- name: LBM build
working-directory: ${{ env.BASE_DIR }}/'Enzyme-GPU-Tests'
run: |
cd LBM
make -j