Skip to content

Commit fc02c48

Browse files
committed
tests: Add test for memory estimate on devices
1 parent 9a3ff77 commit fc02c48

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

devito/operator/operator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,8 +1386,8 @@ def get_nbytes(obj):
13861386
else:
13871387
host += v
13881388
elif i._mem_mapped:
1389-
if isinstance(self.platform, Device):
1390-
device += v
1389+
# No need to add to device, as it will be counted
1390+
# by nbytes_consumed_memmapped
13911391
host += v
13921392

13931393
return {disk_layer: 0, host_layer: host, device_layer: device}

tests/test_operator.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,4 +2217,25 @@ def test_overrides(self, caplog):
22172217
expected = ("Kernel", 0, check, 0)
22182218
self.parse_output(caplog, expected)
22192219

2220-
# Test with OpenACC
2220+
def test_device(self, caplog):
2221+
# Note: this uses switchconfig and runs on all backends to reflect expected
2222+
# usage: users are likely to run the estimate on the orchestration node which
2223+
# may not have the intended hardware, before using this output to determine which
2224+
# nodes to farm jobs out to.
2225+
grid = Grid(shape=(101, 101))
2226+
2227+
f = Function(name='f', grid=grid, space_order=2)
2228+
2229+
# Compiler is never invoked, so this should be fine
2230+
config = {'log_level': 'DEBUG', 'language': 'openacc',
2231+
'platform': 'nvidiaX'}
2232+
with switchconfig(**config), caplog.at_level(logging.DEBUG):
2233+
op = Operator(Eq(f, 1))
2234+
2235+
op.estimate_memory(human_readable=False)
2236+
2237+
check = reduce(mul, f.shape_allocated)*np.dtype(f.dtype).itemsize
2238+
2239+
# Matching memory allocated both on host and device for memmap
2240+
expected = ("Kernel", 0, check, check)
2241+
self.parse_output(caplog, expected)

0 commit comments

Comments
 (0)