Skip to content

Commit

Permalink
test-bench: Add benchmark tests
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebisbas committed Nov 13, 2023
1 parent 680f278 commit 2ebcc2d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
15 changes: 10 additions & 5 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 Down Expand Up @@ -41,11 +43,12 @@ 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 xdsl
- name: Cache binaries
id: cache-binary
uses: actions/cache@v3
Expand Down Expand Up @@ -84,11 +87,13 @@ 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
Expand Down
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))
assert np.isclose(norm(u), norm(devito_out), rtol=1e-5)
9 changes: 7 additions & 2 deletions fast/diffusion_3D_wBCs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from devito import (Grid, TimeFunction, Eq, solve, Operator, Constant,
norm, XDSLOperator, configuration)
from devito.logger import info, warning

from fast.bench_utils import plot_3dfunc

parser = argparse.ArgumentParser(description='Process arguments.')
Expand Down Expand Up @@ -42,7 +44,7 @@
so = args.space_order
to = args.time_order

print("dx %s, dy %s, dz %s" % (dx, dy, dz))
# print("dx %s, dy %s, dz %s" % (dx, dy, dz))

grid = Grid(shape=(nx, ny, nz), extent=(2., 2., 2.))
u = TimeFunction(name='u', grid=grid, space_order=so)
Expand Down Expand Up @@ -89,4 +91,7 @@
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 2ebcc2d

Please sign in to comment.