Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Add a test-only init for issue 2448 #2465

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion tests/test_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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


Expand Down Expand Up @@ -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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: You don't need all these brackets right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorporated in #2477


u_v = Eq(v.forward, solve(pde_v, v.forward))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work with just Eq(v.forward, tau.dx) and Eq(tau.forward, v.forward.dx)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aa I will have to try

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,))
Expand Down
Loading