From ad5d7f59636b0130fd222edc480015d24ef9bfcb Mon Sep 17 00:00:00 2001 From: Isuru Fernando <isuruf@gmail.com> Date: Wed, 6 Apr 2022 02:00:02 -0500 Subject: [PATCH] memoize max_nsources_in_one_box --- sumpy/fmm.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sumpy/fmm.py b/sumpy/fmm.py index 231013b9..f71f350c 100644 --- a/sumpy/fmm.py +++ b/sumpy/fmm.py @@ -539,12 +539,18 @@ class SumpyExpansionWrangler(ExpansionWranglerInterface): return obj_array_vectorize(reorder, potentials) - def get_max_nsources_in_one_box(self, queue): - return int(pyopencl.array.max(self.tree.box_source_counts_nonchild, + @property + @memoize_method + def max_nsources_in_one_box(self): + with cl.CommandQueue(self.tree_indep.cl_context) as queue: + return int(pyopencl.array.max(self.tree.box_source_counts_nonchild, queue).get()) - def get_max_ntargets_in_one_box(self, queue): - return int(pyopencl.array.max(self.tree.box_target_counts_nonchild, + @property + @memoize_method + def max_ntargets_in_one_box(self): + with cl.CommandQueue(self.tree_indep.cl_context) as queue: + return int(pyopencl.array.max(self.tree.box_target_counts_nonchild, queue).get()) # }}} @@ -682,8 +688,8 @@ class SumpyExpansionWrangler(ExpansionWranglerInterface): source_box_lists=source_box_lists, strength=src_weight_vecs, result=pot, - max_npoints_in_one_box=max(self.get_max_nsources_in_one_box(queue), - self.get_max_ntargets_in_one_box(queue)), + max_npoints_in_one_box=max(self.max_nsources_in_one_box, + self.max_ntargets_in_one_box), **kwargs) events.append(evt) -- GitLab