From a1177fdab36d7db8eb82b4706658fc2f40a0c0e8 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 29 Apr 2018 18:53:13 -0500 Subject: [PATCH 1/3] Allow setting _max_leaf_refine_weight from QBXLayerPotentialSource.copy --- pytential/qbx/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pytential/qbx/__init__.py b/pytential/qbx/__init__.py index 3fe9071e..6055e2bb 100644 --- a/pytential/qbx/__init__.py +++ b/pytential/qbx/__init__.py @@ -197,6 +197,7 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): target_association_tolerance=_not_provided, _expansions_in_tree_have_extent=_not_provided, _expansion_stick_out_factor=_not_provided, + _max_leaf_refine_weight=None, _tree_kind=None, geometry_data_inspector=None, fmm_backend=None, @@ -272,7 +273,8 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): if _expansion_stick_out_factor is not _not_provided 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, + _max_leaf_refine_weight=( + _max_leaf_refine_weight or 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=( -- GitLab From eef264d360003ed112704a0f3b2dd413e1154fb4 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 29 Apr 2018 18:57:47 -0500 Subject: [PATCH 2/3] Fix 3D order powers in cost models --- pytential/qbx/fmm.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/pytential/qbx/fmm.py b/pytential/qbx/fmm.py index d3622e59..4be9e5ca 100644 --- a/pytential/qbx/fmm.py +++ b/pytential/qbx/fmm.py @@ -525,6 +525,7 @@ def drive_fmm(expansion_wrangler, src_weights): def assemble_performance_data(geo_data, uses_pde_expansions, translation_source_power=None, translation_target_power=None, + translation_max_power=None, summarize_parallel=None, merge_close_lists=True): """ :arg uses_pde_expansions: A :class:`bool` indicating whether the FMM @@ -573,10 +574,13 @@ def assemble_performance_data(geo_data, uses_pde_expansions, if d == 2: default_translation_source_power = 1 default_translation_target_power = 1 + default_translation_max_power = 0 elif d == 3: - default_translation_source_power = 2 - default_translation_target_power = 1 + # Based on a reading of FMMlib, i.e. a point-and-shoot FMM. + default_translation_source_power = 0 + default_translation_target_power = 0 + default_translation_max_power = 3 else: raise ValueError("Don't know how to estimate expansion complexities " @@ -592,11 +596,16 @@ def assemble_performance_data(geo_data, uses_pde_expansions, translation_source_power = default_translation_source_power if translation_target_power is None: translation_target_power = default_translation_target_power + if translation_max_power is None: + translation_max_power = default_translation_max_power def xlat_cost(p_source, p_target): + from pymbolic.primitives import Max return ( p_source ** translation_source_power - * p_target ** translation_target_power) + * p_target ** translation_target_power + * Max((p_source, p_target)) ** translation_max_power + ) result.update( nlevels=tree.nlevels, @@ -759,11 +768,15 @@ def assemble_performance_data(geo_data, uses_pde_expansions, # {{{ form global qbx locals global_qbx_centers = geo_data.global_qbx_centers() + + # If merge_close_lists is False above, then this builds another traversal + # (which is OK). qbx_center_to_target_box = geo_data.qbx_center_to_target_box() center_to_targets_starts = geo_data.center_to_tree_targets().starts qbx_center_to_target_box_source_level = np.empty( (tree.nlevels,), dtype=object ) + for src_level in range(tree.nlevels): qbx_center_to_target_box_source_level[src_level] = ( geo_data.qbx_center_to_target_box_source_level(src_level) -- GitLab From 4825efd6f80e2d774dcc390725aae6e368fe3c23 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 29 Apr 2018 23:56:16 -0500 Subject: [PATCH 3/3] Tweak defaults for _max_leaf_refine_weight --- pytential/qbx/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pytential/qbx/__init__.py b/pytential/qbx/__init__.py index 6055e2bb..e45835d3 100644 --- a/pytential/qbx/__init__.py +++ b/pytential/qbx/__init__.py @@ -78,7 +78,7 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): _expansions_in_tree_have_extent=True, _expansion_stick_out_factor=0.5, _well_sep_is_n_away=2, - _max_leaf_refine_weight=32, + _max_leaf_refine_weight=None, _box_extent_norm=None, _from_sep_smaller_crit=None, _from_sep_smaller_min_nsources_cumul=None, @@ -139,6 +139,15 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): def fmm_level_to_order(kernel, kernel_args, tree, level): return fmm_order + if _max_leaf_refine_weight is None: + if density_discr.ambient_dim == 2: + _max_leaf_refine_weight = 64 + elif density_discr.ambient_dim == 3: + _max_leaf_refine_weight = 128 + else: + # Just guessing... + _max_leaf_refine_weight = 64 + 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 -- GitLab