diff --git a/sumpy/fmm.py b/sumpy/fmm.py index 231013b9cbb1e7c7b011d8e891ce54203c320590..f71f350cbea1c61bc19a3fc4db0c1886b2554f2f 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)