Skip to content

Commit

Permalink
tests: Add elastic 3D tests
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebisbas committed Jun 24, 2024
1 parent 92fb903 commit c8f4352
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 532 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/ci-lit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,24 @@ jobs:
- name: Checkout Devito
uses: actions/checkout@v4

- name: Install native dependencies
run: |
apt-get update && apt install curl mpich -y
- name: Python Setup
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Upgrade pip
run: |
pip install --upgrade pip
- name: Install native dependencies
run: |
apt-get update && apt install curl mpich -y
- name: Install requirements and xDSL
run: |
pip install -e .[tests]
pip install git+https://github.com/xdslproject/xdsl@f8bb935880276cf077e0a80f1905105d0a98eb33
pip install -e .[tests]
- name: Execute lit tests
run: |
export PATH=/xdsl-sc/llvm-project/build/bin/:$PATH
lit -v tests/filecheck/
5 changes: 0 additions & 5 deletions .github/workflows/ci-mlir-mpi-openmp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ jobs:
run: |
apt-get update && apt install curl mpich -y
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Upgrade pip
run: |
pip install --upgrade pip
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/ci-mlir-mpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ jobs:
run: |
apt-get update && apt install curl mpich -y
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Upgrade pip
run: |
pip install --upgrade pip
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/ci-mlir-openmp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ jobs:
run: |
apt-get update && apt install curl mpich -y
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Upgrade pip
run: |
pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion requirements-testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ nbval
scipy
lit<19.0.0
filecheck<0.0.25
pooch; python_version >= "3.8"
pooch; python_version >= "3.8"
8 changes: 0 additions & 8 deletions tests/filecheck/.lit_test_times.txt

This file was deleted.

497 changes: 0 additions & 497 deletions tests/filecheck/elastic.py

This file was deleted.

14 changes: 11 additions & 3 deletions tests/filecheck/lit.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import lit.formats
import os

config.test_source_root = os.path.dirname(__file__)
xdsl_src = os.path.dirname(os.path.dirname(config.test_source_root))

config.name = "Devito/xDSL"
config.test_format = lit.formats.ShTest()
config.suffixes = ['.mlir', '.py']
config.name = "xDSL"
config.test_format = lit.formats.ShTest(preamble_commands=[f"cd {xdsl_src}"])
config.suffixes = ['.test', '.mlir', '.py']

xdsl_opt = "xdsl/tools/xdsl-opt"
xdsl_run = "xdsl/tools/xdsl_run.py"
irdl_to_pyrdl = "xdsl/tools/irdl_to_pyrdl.py"

config.substitutions.append(('XDSL_ROUNDTRIP', "xdsl-opt %s --print-op-generic --split-input-file | xdsl-opt --split-input-file | filecheck %s"))
config.substitutions.append(("XDSL_GENERIC_ROUNDTRIP", "xdsl-opt %s --print-op-generic --split-input-file | filecheck %s --check-prefix=CHECK-GENERIC"))
if "COVERAGE" in lit_config.params:
config.substitutions.append(('xdsl-opt', f"coverage run {xdsl_opt}"))
config.substitutions.append(('xdsl-run', f"coverage run {xdsl_run}"))
Expand Down
3 changes: 3 additions & 0 deletions tests/filecheck/version.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// RUN: xdsl-opt --version | filecheck %s

//CHECK: xdsl-opt built from xdsl version {{.*}}
13 changes: 11 additions & 2 deletions tests/test_xdsl_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,6 @@ def test_elastic_2D(self, shape, so, nt):
assert not np.isclose(xdsl_norm_tau2, 0.0, rtol=1e-04)
assert not np.isclose(xdsl_norm_tau3, 0.0, rtol=1e-04)


@pytest.mark.parametrize('shape', [(101, 101, 101), (201, 201, 201)])
@pytest.mark.parametrize('so', [2, 4, 8])
@pytest.mark.parametrize('nt', [10, 20, ])
Expand Down Expand Up @@ -1198,11 +1197,21 @@ def test_elastic_3D(self, shape, so, nt):
# TODO: Reinitialize the fields to zero
v[0].data[:] = 0
v[1].data[:] = 0
v[2].data[:] = 0

# t_xx, t_xy, t_xz
# t_yx, t_yy, t_yz
# t_zx, t_zy, t_zz

tau[0].data[:] = 0
tau[1].data[:] = 0
tau[2].data[:] = 0
tau[3].data[:] = 0
tau[4].data[:] = 0
tau[5].data[:] = 0
tau[6].data[:] = 0
tau[7].data[:] = 0
tau[8].data[:] = 0

# Inject sources. We use it to preinject data
op = Operator([u_v] + [u_t] + src_xx + src_yy + src_zz)
Expand Down Expand Up @@ -1230,4 +1239,4 @@ def test_elastic_3D(self, shape, so, nt):
assert not np.isclose(xdsl_norm_tau0, 0.0, rtol=1e-04)
assert not np.isclose(xdsl_norm_tau1, 0.0, rtol=1e-04)
assert not np.isclose(xdsl_norm_tau2, 0.0, rtol=1e-04)
assert not np.isclose(xdsl_norm_tau3, 0.0, rtol=1e-04)
assert not np.isclose(xdsl_norm_tau3, 0.0, rtol=1e-04)
2 changes: 1 addition & 1 deletion xdsl_examples/diffusion_2D_wBCs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
help="Block levels")
parser.add_argument("-devito", "--devito", default=False, type=bool, help="Devito run")
parser.add_argument("-xdsl", "--xdsl", default=False, type=bool, help="xDSL run")
args = parser.parse_args()
parser.add_argument("-plot", "--plot", default=False, type=bool, help="Plot2D")
args = parser.parse_args()


mpiconf = configuration['mpi']
Expand Down

0 comments on commit c8f4352

Please sign in to comment.