Skip to content

Commit ae689d3

Browse files
committed
misc: Cleanup
1 parent 3b08c0d commit ae689d3

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

devito/operator/operator.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,6 @@ def _prepare_arguments(self, autotune=None, estimate_memory=False, **kwargs):
653653
# the subsequent phases of the arguments processing
654654
args = kwargs['args'] = ArgumentsMap(args, grid, self)
655655

656-
# FIXME: Will want to remove this if not using prepare_args to estimate memory
657656
if estimate_memory:
658657
# No need to do anything more if only checking the memory
659658
return args
@@ -1306,7 +1305,6 @@ def nbytes_avail_mapper(self):
13061305
"""
13071306
mapper = {}
13081307

1309-
# TODO: This doesn't account for the size of the snapshots?
13101308
# The amount of space available on the disk
13111309
usage = shutil.disk_usage(gettempdir())
13121310
mapper[disk_layer] = usage.free
@@ -1324,10 +1322,7 @@ def nbytes_avail_mapper(self):
13241322
mapper[host_layer] = int(ANYCPU.memavail() / nproc)
13251323

13261324
for layer in (host_layer, device_layer):
1327-
try:
1328-
mapper[layer] -= self.nbytes_consumed_operator[layer]
1329-
except KeyError:
1330-
continue
1325+
mapper[layer] -= self.nbytes_consumed_operator.get(layer, 0)
13311326

13321327
mapper = {k: int(v) for k, v in mapper.items()}
13331328

@@ -1466,7 +1461,6 @@ def nbytes_consumed_memmapped(self):
14661461

14671462
@cached_property
14681463
def nbytes_snapshots(self):
1469-
disk = 0
14701464

14711465
# Symbols in the operator which may or may not carry data
14721466
op_symbols = FindSymbols().visit(self.op)
@@ -1475,14 +1469,14 @@ def nbytes_snapshots(self):
14751469
op_symbols = [i for i in op_symbols if i.is_AbstractFunction
14761470
and not i.is_ArrayBasic and not i.alias]
14771471

1472+
disk = 0
14781473
for i in op_symbols:
14791474
try:
1480-
disk += i.size_snapshot
1481-
print(i.size_snapshot, i._time_size_ideal)
1475+
disk += i.size_snapshot*i._time_size_ideal*np.dtype(i.dtype).itemsize
14821476
except AttributeError:
14831477
pass
14841478

1485-
return {disk_layer: 0, host_layer: 0, device_layer: 0}
1479+
return {disk_layer: disk, host_layer: 0, device_layer: 0}
14861480

14871481

14881482
def parse_kwargs(**kwargs):

devito/types/sparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ def _arg_defaults(self, alias=None, estimate_memory=False):
652652
if f is not None:
653653
mapper[getattr(self, i)] = f
654654

655-
if estimate_memory: # kwargs.get("estimate_memory", False):
655+
if estimate_memory:
656656
# Avoid touching the data in any capacity, and simply return
657657
# the symbolic objects if merely estimating memory consumption.
658658
return ReducerMap({v.name: k for k, v in mapper.items()})

0 commit comments

Comments
 (0)