Skip to content

Commit f891407

Browse files
committed
tests: Add initial test for specialization at operator apply
1 parent 860089d commit f891407

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

devito/operator/operator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,8 @@ def apply(self, **kwargs):
10141014
if k not in specialize}
10151015

10161016
# TODO: Does this cause problems for profilers?
1017+
# FIXME: Need some way to inspect this Operator for testing
1018+
# FIXME: Perhaps this should use some separate method
10171019
return op.apply(**specialized_kwargs)
10181020

10191021
# Invoke kernel function with args

tests/test_specialization.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,23 @@ def test_apply_basic(self):
203203
assert np.all(check == f.data)
204204

205205

206-
# class TestApply:
207-
# """Tests for specialization of operators at apply time"""
206+
class TestApply:
207+
"""Tests for specialization of operators at apply time"""
208208

209-
# def test_basic(self):
210-
# grid = Grid(shape=(11, 11))
209+
def test_basic(self):
210+
grid = Grid(shape=(11, 11))
211+
f = Function(name='f', grid=grid, dtype=np.int32)
212+
op = Operator(Eq(f, f+1))
213+
214+
# TODO: Need to verify that specialized operator is actually the one
215+
# being run. How can I achieve this?
216+
op.apply(specialize=('x_m', 'x_M'))
211217

212-
# f = TimeFunction(name='f', grid=grid, space_order=2)
218+
check = np.array(f.data[:])
219+
f.data[:] = 0
220+
op.apply()
213221

214-
# op = Operator(Eq(f.forward, f + 1))
222+
assert np.all(check == f.data)
215223

216-
# op.apply(time_M=10, specialize=('x_m', 'x_M'))
224+
# Need to test combining specialization and overrides (a range of them)
225+
# Need to test specialization with MPI (both at)

0 commit comments

Comments
 (0)