From 10ab882adbd6be9c2e9e39440297c15fecc3a578 Mon Sep 17 00:00:00 2001 From: Andrew Whitmell Date: Wed, 21 Jul 2021 11:05:11 +0100 Subject: [PATCH] Implement num_bytes --- pyop2/base.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pyop2/base.py b/pyop2/base.py index 1d7939d9e..c0e034477 100644 --- a/pyop2/base.py +++ b/pyop2/base.py @@ -3537,8 +3537,21 @@ def num_flops(self): @cached_property def num_bytes(self): - # Fake number serving as place holder - return 1e7 + # Measuring Streaming data footprint + n_bytes = 0 + for arg in self.args: + n_bytes += arg.data.nbytes + if arg.access is not READ: + # Writing access counts as 2 accesses + n_bytes += arg.data.nbytes + for map_ in arg.map_tuple: + if map_ is not None: + for m in map_: + n_bytes += m._values.nbytes + if self.iterset.size == 0: + return 0 + else: + return n_bytes/self.iterset.size def log_flops(self, flops): pass