| name: MLIR | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| 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-linux: | |
| name: MLIR ${{ matrix.build }} ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| build: ["Release", "Debug"] # "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 | |
| - name: Checkout Enzyme repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| path: 'Enzyme' | |
| - name: Checkout LLVM repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| repository: 'llvm/llvm-project' | |
| ref: '018a9e4a74ba5d383351bda907a8b116bc5d8c47' | |
| path: 'llvm-project' | |
| - 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}"/Enzyme | |
| 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: wsmoses/gcp-cache@main | |
| with: | |
| path: ${{ env.BASE_DIR }}/llvm-project/mlir-build | |
| key: ${{ matrix.llbuild }}-${{ matrix.os }}-mlir-${{ steps.mlir-commit.outputs.sha_short }} | |
| gcp-bucket: enzyme-ci-transient | |
| gcp-prefix: enzyme-mlir/ | |
| - 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 \ | |
| -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: Enzyme build | |
| working-directory: ${{ env.BASE_DIR }}/'Enzyme' | |
| run: | | |
| mkdir enzyme-build && cd enzyme-build | |
| cmake ../enzyme -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DLLVM_DIR=${{ env.BASE_DIR }}/llvm-project/mlir-build -DENZYME_MLIR=ON | |
| ninja | |
| - name: Check enzyme-mlir | |
| working-directory: 'Enzyme/enzyme-build' | |
| run: ninja check-enzymemlir | |