From 69a0e5f0ec88142b2daded81f68ca8f566b2c794 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Tue, 8 Oct 2024 16:57:34 +0300 Subject: [PATCH 1/2] tests: Add a test-only init for issue 2448 --- tests/test_mpi.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/tests/test_mpi.py b/tests/test_mpi.py index 74e09575c1..4c7a35b297 100644 --- a/tests/test_mpi.py +++ b/tests/test_mpi.py @@ -7,7 +7,7 @@ SparseTimeFunction, Dimension, ConditionalDimension, div, SubDimension, SubDomain, Eq, Ne, Inc, NODE, Operator, norm, inner, configuration, switchconfig, generic_derivative, - PrecomputedSparseFunction, DefaultDimension, Buffer) + PrecomputedSparseFunction, DefaultDimension, Buffer, solve) from devito.arch.compiler import OneapiCompiler from devito.data import LEFT, RIGHT from devito.ir.iet import (Call, Conditional, Iteration, FindNodes, FindSymbols, @@ -17,7 +17,9 @@ ComputeCall) from devito.mpi.distributed import CustomTopology from devito.tools import Bunch +from devito.types.dimension import SpaceDimension +from examples.seismic import Receiver, TimeAxis from examples.seismic.acoustic import acoustic_setup @@ -1005,6 +1007,59 @@ def test_avoid_haloupdate_if_distr_but_sequential(self, mode): calls = FindNodes(Call).visit(op) assert len(calls) == 0 + @pytest.mark.parallel(mode=1) + def test_issue_2448(self, mode): + # TOFIX: Placeholder test for issue 2448 + # Space related + extent = (1500., ) + shape = (201, ) + x = SpaceDimension(name='x', spacing=Constant(name='h_x', + value=extent[0]/(shape[0]-1))) + grid = Grid(extent=extent, shape=shape, dimensions=(x, )) + + # Time related + t0, tn = 0., 30. + dt = (10. / np.sqrt(2.)) / 6. + time_range = TimeAxis(start=t0, stop=tn, step=dt) + + # Velocity and pressure fields + so = 2 + to = 1 + v = TimeFunction(name='v', grid=grid, space_order=so, time_order=to) + tau = TimeFunction(name='tau', grid=grid, space_order=so, time_order=to) + + # The receiver + nrec = 1 + rec = Receiver(name="rec", grid=grid, npoint=nrec, time_range=time_range) + rec.coordinates.data[:, 0] = np.linspace(0., extent[0], num=nrec) + rec_term = rec.interpolate(expr=v) + + # First order elastic-like dependencies equations + pde_v = v.dt - (tau.dx) + pde_tau = (tau.dt - ((v.forward).dx)) + + u_v = Eq(v.forward, solve(pde_v, v.forward)) + u_tau = Eq(tau.forward, solve(pde_tau, tau.forward)) + + op = Operator([u_v] + [u_tau] + rec_term) + + calls = [i for i in FindNodes(Call).visit(op) + if isinstance(i, HaloUpdateCall)] + + # try: + + # The correct we want + assert len(calls) == 2 + assert calls[0].arguments[0] is tau + assert calls[1].arguments[0] is v + + #except: + # # Current redundant codegen + # assert len(calls) == 3 + # assert calls[0].arguments[0] is tau + # assert calls[1].arguments[0] is v + # assert calls[2].arguments[0] is v + @pytest.mark.parallel(mode=1) def test_avoid_haloupdate_with_subdims(self, mode): grid = Grid(shape=(4,)) From a09dfc405c3d28d43287a71e266ec8374dfda9e3 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Tue, 8 Oct 2024 17:03:52 +0300 Subject: [PATCH 2/2] flake8: fix --- tests/test_mpi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mpi.py b/tests/test_mpi.py index 4c7a35b297..fc7710b46a 100644 --- a/tests/test_mpi.py +++ b/tests/test_mpi.py @@ -1053,7 +1053,7 @@ def test_issue_2448(self, mode): assert calls[0].arguments[0] is tau assert calls[1].arguments[0] is v - #except: + # except: # # Current redundant codegen # assert len(calls) == 3 # assert calls[0].arguments[0] is tau