From 2d94f1ce30a2548eb715777d30b2ccf739dceada Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 1 Oct 2017 23:02:32 -0500 Subject: [PATCH 1/6] Initial support for extent tracking: Make QBX lpot source args for box extent norm and from_sep_smaller_crit --- .test-conda-env-py3-requirements.txt | 2 +- pytential/qbx/__init__.py | 10 +++++++++- pytential/qbx/geometry.py | 9 +++++++-- requirements.txt | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.test-conda-env-py3-requirements.txt b/.test-conda-env-py3-requirements.txt index fa6c0426..6ed3f7ae 100644 --- a/.test-conda-env-py3-requirements.txt +++ b/.test-conda-env-py3-requirements.txt @@ -1,4 +1,4 @@ -git+https://gitlab.tiker.net/inducer/boxtree +git+https://gitlab.tiker.net/inducer/boxtree@l2-extents-and-tracking git+https://github.com/inducer/pymbolic git+https://github.com/inducer/loopy git+https://gitlab.tiker.net/inducer/sumpy diff --git a/pytential/qbx/__init__.py b/pytential/qbx/__init__.py index a5a5d115..80abf600 100644 --- a/pytential/qbx/__init__.py +++ b/pytential/qbx/__init__.py @@ -79,6 +79,8 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): _expansion_stick_out_factor=0.5, _well_sep_is_n_away=2, _max_leaf_refine_weight=32, + _box_extent_norm=None, + _from_sep_smaller_crit=None, geometry_data_inspector=None, fmm_backend="sumpy", target_stick_out_factor=_not_provided): @@ -162,6 +164,8 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): self._expansion_stick_out_factor = _expansion_stick_out_factor self._well_sep_is_n_away = _well_sep_is_n_away self._max_leaf_refine_weight = _max_leaf_refine_weight + self._box_extent_norm = _box_extent_norm + self._from_sep_smaller_crit = _from_sep_smaller_crit self.geometry_data_inspector = geometry_data_inspector # /!\ *All* parameters set here must also be set by copy() below, @@ -242,6 +246,8 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): else self._expansion_stick_out_factor), _well_sep_is_n_away=self._well_sep_is_n_away, _max_leaf_refine_weight=self._max_leaf_refine_weight, + _box_extent_norm=self._box_extent_norm, + _from_sep_smaller_crit=self._from_sep_smaller_crit, geometry_data_inspector=( geometry_data_inspector or self.geometry_data_inspector), fmm_backend=self.fmm_backend, @@ -481,7 +487,9 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): def qbx_fmm_code_getter(self): from pytential.qbx.geometry import QBXFMMGeometryCodeGetter return QBXFMMGeometryCodeGetter(self.cl_context, self.ambient_dim, - debug=self.debug, _well_sep_is_n_away=self._well_sep_is_n_away) + debug=self.debug, + _well_sep_is_n_away=self._well_sep_is_n_away, + _from_sep_smaller_crit=self._from_sep_smaller_crit) # {{{ fmm-based execution diff --git a/pytential/qbx/geometry.py b/pytential/qbx/geometry.py index 374d37d2..b21c9548 100644 --- a/pytential/qbx/geometry.py +++ b/pytential/qbx/geometry.py @@ -104,11 +104,13 @@ class target_state(Enum): # noqa class QBXFMMGeometryCodeGetter(object): - def __init__(self, cl_context, ambient_dim, debug, _well_sep_is_n_away): + def __init__(self, cl_context, ambient_dim, debug, _well_sep_is_n_away, + _from_sep_smaller_crit): self.cl_context = cl_context self.ambient_dim = ambient_dim self.debug = debug self._well_sep_is_n_away = _well_sep_is_n_away + self._from_sep_smaller_crit = _from_sep_smaller_crit @memoize_method def copy_targets_kernel(self): @@ -141,7 +143,9 @@ class QBXFMMGeometryCodeGetter(object): from boxtree.traversal import FMMTraversalBuilder return FMMTraversalBuilder( self.cl_context, - well_sep_is_n_away=self._well_sep_is_n_away) + well_sep_is_n_away=self._well_sep_is_n_away, + from_sep_smaller_crit=self._from_sep_smaller_crit, + ) @memoize_method def qbx_center_to_target_box_lookup(self, particle_id_dtype, box_id_dtype): @@ -508,6 +512,7 @@ class QBXFMMGeometryData(object): refine_weights=refine_weights, debug=self.debug, stick_out_factor=lpot_src._expansion_stick_out_factor, + extent_norm=lpot_src._box_extent_norm, kind="adaptive") if self.debug: diff --git a/requirements.txt b/requirements.txt index dc15e1ef..a402ba60 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ git+https://github.com/inducer/modepy git+https://github.com/inducer/pyopencl git+https://github.com/inducer/islpy git+https://github.com/inducer/loopy -git+https://gitlab.tiker.net/inducer/boxtree +git+https://gitlab.tiker.net/inducer/boxtree@l2-extents-and-tracking git+https://github.com/inducer/meshpy git+https://github.com/inducer/meshmode git+https://gitlab.tiker.net/inducer/sumpy -- GitLab From f59132469e5abcc4ba07a0602ef6620d1d2f8086 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 4 Oct 2017 19:46:20 -0500 Subject: [PATCH 2/6] Expose _from_sep_smaller_min_nsources_cumul in QBX lpot source constructor --- pytential/qbx/__init__.py | 5 +++++ pytential/qbx/geometry.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pytential/qbx/__init__.py b/pytential/qbx/__init__.py index adaff8dd..0f48035b 100644 --- a/pytential/qbx/__init__.py +++ b/pytential/qbx/__init__.py @@ -81,6 +81,7 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): _max_leaf_refine_weight=32, _box_extent_norm=None, _from_sep_smaller_crit=None, + _from_sep_smaller_min_nsources_cumul=None, geometry_data_inspector=None, fmm_backend="sumpy", target_stick_out_factor=_not_provided): @@ -166,6 +167,8 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): self._max_leaf_refine_weight = _max_leaf_refine_weight self._box_extent_norm = _box_extent_norm self._from_sep_smaller_crit = _from_sep_smaller_crit + self._from_sep_smaller_min_nsources_cumul = \ + _from_sep_smaller_min_nsources_cumul self.geometry_data_inspector = geometry_data_inspector # /!\ *All* parameters set here must also be set by copy() below, @@ -248,6 +251,8 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): _max_leaf_refine_weight=self._max_leaf_refine_weight, _box_extent_norm=self._box_extent_norm, _from_sep_smaller_crit=self._from_sep_smaller_crit, + _from_sep_smaller_min_nsources_cumul=( + self._from_sep_smaller_min_nsources_cumul), geometry_data_inspector=( geometry_data_inspector or self.geometry_data_inspector), fmm_backend=self.fmm_backend, diff --git a/pytential/qbx/geometry.py b/pytential/qbx/geometry.py index e5420412..cf0949ed 100644 --- a/pytential/qbx/geometry.py +++ b/pytential/qbx/geometry.py @@ -533,7 +533,9 @@ class QBXFMMGeometryData(object): with cl.CommandQueue(self.cl_context) as queue: trav, _ = self.code_getter.build_traversal(queue, self.tree(), - debug=self.debug) + debug=self.debug, + _from_sep_smaller_min_nsources_cumul=( + self.lpot_source._from_sep_smaller_min_nsources_cumul)) if self.lpot_source._expansions_in_tree_have_extent: trav = trav.merge_close_lists(queue) -- GitLab From c6dd7cc7a7cfed7c58389d9d8f45e2b62524dafa Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 5 Oct 2017 11:15:33 -0500 Subject: [PATCH 3/6] Default box extent norm to l2 if not given --- pytential/qbx/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pytential/qbx/__init__.py b/pytential/qbx/__init__.py index 57178d45..ef571df6 100644 --- a/pytential/qbx/__init__.py +++ b/pytential/qbx/__init__.py @@ -128,6 +128,9 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): if fmm_order is not None and fmm_level_to_order is not None: raise TypeError("may not specify both fmm_order and fmm_level_to_order") + if _box_extent_norm is None: + _box_extent_norm = "l2" + if fmm_level_to_order is None: if fmm_order is False: fmm_level_to_order = False -- GitLab From 87b539ec8a0f415974c6dff12dc2c16aa96e6d31 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 5 Oct 2017 12:57:27 -0500 Subject: [PATCH 4/6] Log QBX FMM time by default [ci skip] --- pytential/qbx/fmm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pytential/qbx/fmm.py b/pytential/qbx/fmm.py index e34574be..69a378d4 100644 --- a/pytential/qbx/fmm.py +++ b/pytential/qbx/fmm.py @@ -379,6 +379,8 @@ def drive_fmm(expansion_wrangler, src_weights): # Interface guidelines: Attributes of the tree are assumed to be known # to the expansion wrangler and should not be passed. + from time import time + start_time = time() logger.info("start qbx fmm") logger.info("reorder source weights") @@ -525,7 +527,7 @@ def drive_fmm(expansion_wrangler, src_weights): # }}} - logger.info("qbx fmm complete") + logger.info("qbx fmm complete in %.2f s" % (time() - start_time)) return result -- GitLab From 5176ed4d5399bcefb986ffd23f6cf4a784638a38 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 7 Oct 2017 13:54:43 -0500 Subject: [PATCH 5/6] Set a default for _from_sep_smaller_min_nsources_cumul --- pytential/qbx/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pytential/qbx/__init__.py b/pytential/qbx/__init__.py index ef571df6..e0bf9992 100644 --- a/pytential/qbx/__init__.py +++ b/pytential/qbx/__init__.py @@ -138,6 +138,14 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): def fmm_level_to_order(kernel, kernel_args, tree, level): return fmm_order + if _from_sep_smaller_min_nsources_cumul is None: + # See here for the comment thread that led to these defaults: + # https://gitlab.tiker.net/inducer/boxtree/merge_requests/28#note_18661 + if density_discr.dim == 1: + _from_sep_smaller_min_nsources_cumul = 15 + else: + _from_sep_smaller_min_nsources_cumul = 30 + # }}} self.fine_order = fine_order -- GitLab From ee8b9f48a8fb834d64acad52d0f270e14960e549 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 7 Oct 2017 13:54:56 -0500 Subject: [PATCH 6/6] Reset boxtree dep back to master --- .test-conda-env-py3-requirements.txt | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.test-conda-env-py3-requirements.txt b/.test-conda-env-py3-requirements.txt index 6ed3f7ae..fa6c0426 100644 --- a/.test-conda-env-py3-requirements.txt +++ b/.test-conda-env-py3-requirements.txt @@ -1,4 +1,4 @@ -git+https://gitlab.tiker.net/inducer/boxtree@l2-extents-and-tracking +git+https://gitlab.tiker.net/inducer/boxtree git+https://github.com/inducer/pymbolic git+https://github.com/inducer/loopy git+https://gitlab.tiker.net/inducer/sumpy diff --git a/requirements.txt b/requirements.txt index a402ba60..dc15e1ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ git+https://github.com/inducer/modepy git+https://github.com/inducer/pyopencl git+https://github.com/inducer/islpy git+https://github.com/inducer/loopy -git+https://gitlab.tiker.net/inducer/boxtree@l2-extents-and-tracking +git+https://gitlab.tiker.net/inducer/boxtree git+https://github.com/inducer/meshpy git+https://github.com/inducer/meshmode git+https://gitlab.tiker.net/inducer/sumpy -- GitLab