Skip to content

Commit

Permalink
Merge pull request #98 from xdslproject/add_topology_tests
Browse files Browse the repository at this point in the history
tests: Add test topology
  • Loading branch information
georgebisbas authored Jun 10, 2024
2 parents 95bf4c4 + 47bffa2 commit a9843db
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions tests/test_xdsl_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,75 @@ def test_acoustic_3D(self, shape, so, to, nt):
xdsl_norm = norm(u)

assert np.isclose(devito_norm, xdsl_norm, rtol=1e-04).all()


class TestTopology(object):

@pytest.mark.parallel(mode=[2])
@pytest.mark.parametrize('shape', [(10, 10, 10)])
@pytest.mark.parametrize('to', [2])
@pytest.mark.parametrize('nt', [10])
def test_topology(self, shape, to, nt):

grid = Grid(shape=shape)
dt = 0.0001

# Define the wavefield with the size of the model and the time dimension
u = TimeFunction(name="u", grid=grid, time_order=to)

stencil = Eq(u.forward, u + 1)
u.data[:, :, :] = 0

# XDSL Operator
xdslop = Operator([stencil], opt='xdsl')
topology, _ = xdslop.mpi_shape

assert topology == (2, 1, 1)

xdslop.apply(time=nt, dt=dt)

@pytest.mark.parallel(mode=[4])
@pytest.mark.parametrize('shape', [(10, 10, 10)])
@pytest.mark.parametrize('to', [2])
@pytest.mark.parametrize('nt', [10])
def test_topology_4(self, shape, to, nt):

grid = Grid(shape=shape)
dt = 0.0001

# Define the wavefield with the size of the model and the time dimension
u = TimeFunction(name="u", grid=grid, time_order=to)

stencil = Eq(u.forward, u + 1)
u.data[:, :, :] = 0

# XDSL Operator
xdslop = Operator([stencil], opt='xdsl')
topology, _ = xdslop.mpi_shape

assert topology == (2, 2, 1)

xdslop.apply(time=nt, dt=dt)

@pytest.mark.parallel(mode=[8])
@pytest.mark.parametrize('shape', [(10, 10, 10)])
@pytest.mark.parametrize('to', [2])
@pytest.mark.parametrize('nt', [10])
def test_topology_8(self, shape, to, nt):

grid = Grid(shape=shape)
dt = 0.0001

# Define the wavefield with the size of the model and the time dimension
u = TimeFunction(name="u", grid=grid, time_order=to)

stencil = Eq(u.forward, u + 1)
u.data[:, :, :] = 0

# XDSL Operator
xdslop = Operator([stencil], opt='xdsl')
topology, _ = xdslop.mpi_shape

assert topology == (2, 2, 2)

xdslop.apply(time=nt, dt=dt)

0 comments on commit a9843db

Please sign in to comment.