Fix typo on readme #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
# Adapted from: https://github.com/tancheng/mlir-cgra/blob/main/.github/workflows/main.yml | |
# Adapted from: https://github.com/llvm/circt/blob/main/.github/workflows/buildAndTest.yml | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
BUILD_TYPE: Release | |
LLVM_COMMIT: 339a7687e1c036a5f91c9d5391523b93e2e76cd3 | |
LLVM_SRC_DIR: /tmp/src/llvm-project | |
LLVM_BUILD_DIR: /tmp/builds/llvm-project/build | |
LLVM_INSTALL_DIR: /tmp/installs/llvm-project/install | |
SODA_OPT_BUILD_DIR: /tmp/builds/soda-opt/build | |
SODA_OPT_INSTALL_DIR: /tmp/installs/soda-opt/install | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
python-version: ["3.9.16"] | |
steps: | |
# Clone the SODA-OPT repo. Do shallow clone to save clone time. | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
# Install python and build dependencies. | |
- name: Install dependencies | |
working-directory: ${{github.workspace}} | |
run: | | |
sudo apt-get install python3.9 python3.9-dev | |
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py | |
python3.9 get-pip.py | |
sudo apt-get install ninja-build | |
# Clone a specific verion of llvm-project and install python dependencies. | |
- name: Setup LLVM | |
id: clone-llvm | |
run: | | |
mkdir -p /tmp/src/ && cd /tmp/src | |
git init llvm-project | |
cd /tmp/src/llvm-project | |
git remote add origin https://github.com/llvm/llvm-project.git | |
git fetch --depth=1 origin $LLVM_COMMIT | |
git reset --hard $LLVM_COMMIT | |
pip3.9 install -r ./mlir/python/requirements.txt | |
# ---------------------------------- | |
# Try to fetch LLVM from the cache. | |
# Extract the LLVM submodule hash for use in the cache key. | |
- name: Get LLVM Hash | |
id: get-llvm-hash | |
run: echo "hash=$LLVM_COMMIT" >> $GITHUB_OUTPUT | |
- name: Get workflow spec hash | |
id: get-workflow-hash | |
run: echo "hash=$(md5sum $GITHUB_WORKSPACE/.github/workflows/buildAndTest.yml | awk '{print $1}')" >> $GITHUB_OUTPUT | |
# Try to fetch LLVM from the cache. | |
- name: Cache LLVM | |
id: cache-llvm | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ env.LLVM_BUILD_DIR }}/bin/llvm-lit | |
${{ env.LLVM_INSTALL_DIR }} | |
key: ${{ runner.os }}-llvm-${{ steps.get-llvm-hash.outputs.hash }}-${{ steps.get-workflow-hash.outputs.hash }} | |
# Build LLVM if we didn't hit in the cache. Even though we build it in | |
# the previous job, there is a low chance that it'll have been evicted by | |
# the time we get here. | |
- name: Compile and Install LLVM | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
run: | | |
cd /tmp/src/llvm-project | |
cmake -GNinja \ | |
"-H$LLVM_SRC_DIR/llvm" \ | |
"-B$LLVM_BUILD_DIR" \ | |
-DCMAKE_INSTALL_PREFIX=$LLVM_INSTALL_DIR \ | |
-DLLVM_ENABLE_PROJECTS=mlir \ | |
-DLLVM_TARGETS_TO_BUILD="host" \ | |
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \ | |
-DLLVM_INSTALL_UTILS=ON \ | |
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \ | |
-DLLVM_ENABLE_ASSERTIONS=OFF \ | |
-DLLVM_BUILD_EXAMPLES=OFF | |
cmake --build $LLVM_BUILD_DIR --target opt mlir-opt mlir-translate mlir-cpu-runner install -j $(nproc) | |
- name: Compile and Test soda-opt | |
working-directory: ${{ github.workspace }} | |
run: | | |
export SODA_OPT_SRC_DIR=${{ github.workspace }} | |
cmake -GNinja \ | |
"-H$SODA_OPT_SRC_DIR" \ | |
"-B$SODA_OPT_BUILD_DIR" \ | |
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \ | |
-DLLVM_EXTERNAL_LIT=$LLVM_BUILD_DIR/bin/llvm-lit \ | |
-DMLIR_DIR=$LLVM_INSTALL_DIR/lib/cmake/mlir \ | |
-DLLVM_DIR=$LLVM_INSTALL_DIR/lib/cmake/llvm \ | |
-DMLIR_ENABLE_BINDINGS_PYTHON=ON | |
cmake --build $SODA_OPT_BUILD_DIR --target check-soda -j $(nproc) |