diff --git a/.github/workflows/ci-mlir.yml b/.github/workflows/ci-mlir.yml index 0e5e1c15b3..419fdb8367 100644 --- a/.github/workflows/ci-mlir.yml +++ b/.github/workflows/ci-mlir.yml @@ -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: @@ -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 @@ -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 @@ -76,8 +78,7 @@ 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 \ @@ -85,32 +86,16 @@ jobs: -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/ \ No newline at end of file diff --git a/fast/diffusion_2D_wBCs.py b/fast/diffusion_2D_wBCs.py index 7f974eac48..29b09a02bb 100644 --- a/fast/diffusion_2D_wBCs.py +++ b/fast/diffusion_2D_wBCs.py @@ -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) \ No newline at end of file diff --git a/fast/diffusion_3D_wBCs.py b/fast/diffusion_3D_wBCs.py index dc1281cfe1..1aa5863a03 100644 --- a/fast/diffusion_3D_wBCs.py +++ b/fast/diffusion_3D_wBCs.py @@ -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)