Skip to content

Commit

Permalink
ci: Add MLIR
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebisbas committed Nov 13, 2023
1 parent b179126 commit 09c3a1c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
45 changes: 15 additions & 30 deletions .github/workflows/ci-mlir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ name: CI - MLIR-based Testing

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
# but only for the master branch
push:
branches:
- main
- master
pull_request:
branches:
- master
workflow_dispatch:

jobs:
Expand All @@ -22,10 +24,11 @@ jobs:
env:
LLVM_SYMBOLIZER_PATH: /usr/lib/llvm-11/bin/llvm-symbolizer
MLIR-Version: 04fc02e583b06b846315904a55af9c273c8b20b9

steps:
- uses: actions/checkout@v3
with:
path: xdsl
- name: Checkout Devito
uses: actions/checkout@v3


- name: Install native dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
Expand All @@ -41,11 +44,10 @@ jobs:
- name: Upgrade pip
run: |
pip install --upgrade pip
- name: Install the package locally and nbval
- name: Install requirements and xDSL
run: |
# Change directory so that xdsl-opt can be found during installation.
cd xdsl
pip install -r requirements.txt
pip install -e .[tests]
pip install xdsl==0.14
- name: Cache binaries
id: cache-binary
uses: actions/cache@v3
Expand Down Expand Up @@ -76,41 +78,24 @@ jobs:
mkdir llvm-project/build
cd llvm-project/build
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS="mlir;clang;openmp;lld" \
-DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_ENABLE_PROJECTS="mlir;clang;openmp;lld"\
-DLLVM_TARGETS_TO_BUILD="Native" \
-DLLVM_ENABLE_LLD=ON \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_BINUTILS_INCDIR=/usr/include
- name: MLIR Build
if: steps.cache-binary.outputs.cache-hit != 'true'
run: |
cd llvm-project/build
cmake --build . --target mlir-opt mlir-cpu-runner
- name: Test with pytest and generate code coverage
run: |
cd xdsl
pytest -W error --cov --cov-config=.coveragerc .
- name: Execute lit tests
run: |
cd xdsl
# Add mlir-opt to the path
export PATH=$PATH:${GITHUB_WORKSPACE}/llvm-project/build/bin/
lit -v tests/filecheck/ -DCOVERAGE
lit -v docs/Toy/examples/ -DCOVERAGE
- name: Test MLIR dependent examples/tutorials
- name: ADD TO PATH
run: |
cd xdsl
# Add mlir-opt to the path
export PATH=$PATH:${GITHUB_WORKSPACE}/llvm-project/build/bin/
pytest --nbval docs/mlir_interoperation.ipynb --maxfail 1 -vv
- name: Combine coverage data
- name: Test with pytest and generate code coverage
run: |
cd xdsl
coverage combine --append
coverage report
coverage xml
pytest -W error -m "not parallel" -k "not adjoint" tests/
4 changes: 3 additions & 1 deletion fast/diffusion_2D_wBCs.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,6 @@
print("XDSL Field norm is:", norm(u))

if args.xdsl and args.devito:
print("Max error: ", np.max(np.abs(u.data - devito_out.data)))
assert np.isclose(norm(u), norm(devito_out), rtol=1e-5)
max_error = np.max(np.abs(u.data - devito_out.data))
print("Max error: ", max_error)
4 changes: 3 additions & 1 deletion fast/diffusion_3D_wBCs.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,6 @@
plot_3dfunc(u)

if args.xdsl and args.devito:
print("Max error: ", np.max(np.abs(u.data - devito_out.data)))
assert np.isclose(norm(u), norm(devito_out), rtol=1e-5)
max_error = np.max(np.abs(u.data - devito_out.data))
assert np.isclose(norm(u), norm(devito_out), rtol=1e-5)

0 comments on commit 09c3a1c

Please sign in to comment.