Skip to content

Commit 4c4d637

Browse files
committed
tests: Fix tests
1 parent 020bf84 commit 4c4d637

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

devito/operator/operator.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,6 @@ def estimate_memory(self, **kwargs):
893893
894894
Parameters
895895
----------
896-
human_readable: bool
897-
Return human-readable values, rather than raw byte counts. Default is False.
898896
**kwargs: dict
899897
As per `Operator.apply()`.
900898
@@ -910,8 +908,6 @@ def estimate_memory(self, **kwargs):
910908

911909
memreport = {'host': mem[host_layer], 'device': mem[device_layer]}
912910

913-
# from IPython import embed; embed()
914-
915911
# Extra information for enriched Operators
916912
extras = self._enrich_memreport(args)
917913
memreport.update(extras)

tests/test_operator.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
NODE, CELL, dimensions, configuration, TensorFunction,
2121
TensorTimeFunction, VectorFunction, VectorTimeFunction,
2222
div, grad, switchconfig, exp, Buffer)
23-
from devito import Inc, Le, Lt, Ge, Gt # noqa
23+
from devito import Inc, Le, Lt, Ge, Gt, sin # noqa
24+
from devito.arch.archinfo import Device
2425
from devito.exceptions import InvalidOperator
2526
from devito.finite_differences.differentiable import diff2sympy
2627
from devito.ir.equations import ClusterizedEq
@@ -2066,12 +2067,11 @@ def test_indirection(self):
20662067
class TestEstimateMemory:
20672068
"""Tests for the Operator.estimate_memory() utility"""
20682069

2069-
_array_temp = "r0L0(x, y)" if "CXX" in configuration['language'] else "r0[x][y]"
2070-
_devicelangs = ('openacc',)
2070+
_array_temp = "r0L0(" if "CXX" in configuration['language'] else "r0["
20712071

20722072
def parse_output(self, summary, check, arrays=0):
2073-
expected = ((check, check + arrays) if configuration['language']
2074-
in self._devicelangs else (check + arrays, 0))
2073+
device = isinstance(configuration['platform'], Device)
2074+
expected = ((check, check + arrays) if device else (check + arrays, 0))
20752075
assert (summary['host'], summary['device']) == expected
20762076

20772077
def sum_sizes(self, funcs):
@@ -2185,8 +2185,8 @@ def test_temp_array(self, caplog, override):
21852185
b = Function(name='b', grid=grid, space_order=0)
21862186

21872187
# Reuse an expensive function to encourage generation of an array temp
2188-
eq0 = Eq(f.forward, g + sympy.sin(a))
2189-
eq1 = Eq(g.forward, f + sympy.sin(a))
2188+
eq0 = Eq(f.forward, g + sin(a).dx)
2189+
eq1 = Eq(g.forward, f + sin(a).dx)
21902190

21912191
with switchconfig(log_level='DEBUG'), caplog.at_level(logging.DEBUG):
21922192
op = Operator([eq0, eq1])
@@ -2201,7 +2201,9 @@ def test_temp_array(self, caplog, override):
22012201
check = self.sum_sizes(funcs)
22022202

22032203
# Factor in the temp array
2204-
array_check = reduce(mul, b.shape_allocated)*np.dtype(b.dtype).itemsize
2204+
# Note: temp array size is incremented by one in the x dimension
2205+
# due to derivative.
2206+
array_check = (b.shape_allocated[0]+1)*b.shape_allocated[1]*np.dtype(b.dtype).itemsize
22052207
self.parse_output(summary, check, arrays=array_check)
22062208

22072209
def test_overrides(self, caplog):

0 commit comments

Comments
 (0)