From f01cc38602f018e811dae1f21ac02b248372de0d Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Sat, 1 Jun 2019 18:58:42 -0500 Subject: [PATCH 01/17] Adapt pytential's fmmlib support to make use of fast precomputed rotation matrices for 3D M2L --- pytential/qbx/fmmlib.py | 15 +++++++++++++-- pytential/qbx/geometry.py | 31 ++++++++++++++++++++++++++++++- requirements.txt | 2 +- setup.py | 2 +- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/pytential/qbx/fmmlib.py b/pytential/qbx/fmmlib.py index 2d21a3d2..21952f4e 100644 --- a/pytential/qbx/fmmlib.py +++ b/pytential/qbx/fmmlib.py @@ -120,6 +120,16 @@ class ToHostTransferredGeoDataWrapper(object): """All (not just non-QBX) targets packaged into a single array.""" return np.array(list(self.tree().targets)) + @memoize_method + def m2l_rotation_angles(self): + # Already on host + return self.geo_data.m2l_rotation_angles() + + @memoize_method + def m2l_rotation_lists(self): + # Already on host + return self.geo_data.m2l_rotation_lists() + # }}} @@ -136,7 +146,7 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): # FMMLib is CPU-only. This wrapper gets the geometry out of # OpenCL-land. - self.geo_data = ToHostTransferredGeoDataWrapper(queue, geo_data) + geo_data = ToHostTransferredGeoDataWrapper(queue, geo_data) self.qbx_order = qbx_order @@ -215,13 +225,14 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): frozenset([("k", helmholtz_k)]), tree, level) super(QBXFMMLibExpansionWrangler, self).__init__( - self.geo_data.tree(), + geo_data.tree(), helmholtz_k=helmholtz_k, dipole_vec=dipole_vec, dipoles_already_reordered=True, fmm_level_to_nterms=inner_fmm_level_to_nterms, + geo_data=geo_data, ifgrad=ifgrad) diff --git a/pytential/qbx/geometry.py b/pytential/qbx/geometry.py index 4eadefbe..b0432ed5 100644 --- a/pytential/qbx/geometry.py +++ b/pytential/qbx/geometry.py @@ -29,6 +29,7 @@ import pyopencl as cl import pyopencl.array # noqa from pytools import memoize_method from boxtree.tools import DeviceDataRecord +from boxtree.pyfmmlib_integration import FMMLibGeometryDataInterface import loopy as lp from loopy.version import MOST_RECENT_LANGUAGE_VERSION from cgen import Enum @@ -254,6 +255,12 @@ class QBXFMMGeometryCodeGetter(TreeCodeContainerMixin): knl = lp.split_iname(knl, "i", 128, inner_tag="l.0", outer_tag="g.0") return knl + @property + @memoize_method + def rotation_classes_builder(self): + from boxtree.traversal import RotationClassesBuilder + return RotationClassesBuilder(self.cl_context) + # }}} @@ -300,7 +307,7 @@ class CenterToTargetList(DeviceDataRecord): """ -class QBXFMMGeometryData(object): +class QBXFMMGeometryData(FMMLibGeometryDataInterface): """ .. rubric :: Attributes @@ -350,6 +357,8 @@ class QBXFMMGeometryData(object): .. automethod:: center_to_tree_targets() .. automethod:: non_qbx_box_target_lists() .. automethod:: plot() + .. method:: m2l_rotation_lists() + .. method:: m2l_rotation_angles() """ def __init__(self, code_getter, lpot_source, @@ -824,6 +833,26 @@ class QBXFMMGeometryData(object): return result.with_queue(None) + @memoize_method + def build_rotation_classes_lists(self): + trav = self.traversal() + tree = self.tree() + + with cl.CommandQueue(self.cl_context) as queue: + return (self + .code_getter + .rotation_classes_builder(queue, trav, tree)[0].get(queue)) + + @memoize_method + def m2l_rotation_lists(self): + return self.build_rotation_classes_lists().from_sep_siblings_rotation_classes + + @memoize_method + def m2l_rotation_angles(self): + return (self + .build_rotation_classes_lists() + .from_sep_siblings_rotation_class_to_angle) + # {{{ plotting (for debugging) def plot(self, draw_circles=False, draw_center_numbers=False, diff --git a/requirements.txt b/requirements.txt index dd15a69e..e6e46f95 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@fast-m2l git+https://github.com/inducer/meshmode git+https://gitlab.tiker.net/inducer/sumpy git+https://gitlab.tiker.net/inducer/pyfmmlib diff --git a/setup.py b/setup.py index e2a1ae90..c1422252 100644 --- a/setup.py +++ b/setup.py @@ -105,7 +105,7 @@ setup(name="pytential", "loo.py>=2017.2", "sumpy>=2013.1", "cgen>=2013.1.2", - "pyfmmlib>=2018.1", + "pyfmmlib>=2019.1", "six", ]) -- GitLab From 377921388cfabe5f000b8a2c90596f7618250882 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Sat, 1 Jun 2019 19:51:16 -0500 Subject: [PATCH 02/17] Point Conda requirements.txt to fast-m2l branch of boxtree --- .test-conda-env-py3-requirements.txt | 2 +- examples/laplace-dirichlet-3d.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.test-conda-env-py3-requirements.txt b/.test-conda-env-py3-requirements.txt index fa6c0426..285c7d5c 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@fast-m2l git+https://github.com/inducer/pymbolic git+https://github.com/inducer/loopy git+https://gitlab.tiker.net/inducer/sumpy diff --git a/examples/laplace-dirichlet-3d.py b/examples/laplace-dirichlet-3d.py index 4166dddf..413ef6e4 100644 --- a/examples/laplace-dirichlet-3d.py +++ b/examples/laplace-dirichlet-3d.py @@ -66,7 +66,8 @@ def main(): QBXLayerPotentialSource, QBXTargetAssociationFailedException) qbx, _ = QBXLayerPotentialSource( pre_density_discr, fine_order=bdry_ovsmp_quad_order, qbx_order=qbx_order, - fmm_order=fmm_order + fmm_order=fmm_order, + fmm_backend="fmmlib", ).with_refinement() density_discr = qbx.density_discr -- GitLab From 5a3fb37746a3dcc190c74bbf8c26d30fa769ce28 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Sat, 1 Jun 2019 19:52:34 -0500 Subject: [PATCH 03/17] Revert change to laplace-dirichlet-3d.py --- examples/laplace-dirichlet-3d.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/laplace-dirichlet-3d.py b/examples/laplace-dirichlet-3d.py index 413ef6e4..db93fadf 100644 --- a/examples/laplace-dirichlet-3d.py +++ b/examples/laplace-dirichlet-3d.py @@ -67,7 +67,6 @@ def main(): qbx, _ = QBXLayerPotentialSource( pre_density_discr, fine_order=bdry_ovsmp_quad_order, qbx_order=qbx_order, fmm_order=fmm_order, - fmm_backend="fmmlib", ).with_refinement() density_discr = qbx.density_discr -- GitLab From 6df64a87258f928eb4e1dc2243794b06cba2a659 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Sun, 2 Jun 2019 05:16:05 +0200 Subject: [PATCH 04/17] Update setup.py to require pyfmmlib 2019.1.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c1422252..d8f69dcb 100644 --- a/setup.py +++ b/setup.py @@ -105,7 +105,7 @@ setup(name="pytential", "loo.py>=2017.2", "sumpy>=2013.1", "cgen>=2013.1.2", - "pyfmmlib>=2019.1", + "pyfmmlib>=2019.1.1", "six", ]) -- GitLab From ac852c79ab2cd73a1deaf9925ab0b18bfcd11885 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Sat, 8 Jun 2019 16:01:59 -0500 Subject: [PATCH 05/17] Bump boxtree version dependence --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c1422252..3df7e6d2 100644 --- a/setup.py +++ b/setup.py @@ -100,7 +100,7 @@ setup(name="pytential", "pytools>=2018.2", "modepy>=2013.3", "pyopencl>=2013.1", - "boxtree>=2018.2", + "boxtree>=2019.1", "pymbolic>=2013.2", "loo.py>=2017.2", "sumpy>=2013.1", -- GitLab From db2bc8128cb4b3343dcc5c0bc4e19a00f42a4027 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Wed, 12 Jun 2019 23:48:19 -0500 Subject: [PATCH 06/17] Set geo_data --- pytential/qbx/fmmlib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pytential/qbx/fmmlib.py b/pytential/qbx/fmmlib.py index 21952f4e..4db24dd2 100644 --- a/pytential/qbx/fmmlib.py +++ b/pytential/qbx/fmmlib.py @@ -148,6 +148,7 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): # OpenCL-land. geo_data = ToHostTransferredGeoDataWrapper(queue, geo_data) + self.geo_data = geo_data self.qbx_order = qbx_order # {{{ digest out_kernels -- GitLab From 250c6004a414fa5924b18702dad85618c76268e0 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Wed, 12 Jun 2019 23:51:13 -0500 Subject: [PATCH 07/17] Revert "Set geo_data" This reverts commit db2bc8128cb4b3343dcc5c0bc4e19a00f42a4027. --- pytential/qbx/fmmlib.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pytential/qbx/fmmlib.py b/pytential/qbx/fmmlib.py index 4db24dd2..21952f4e 100644 --- a/pytential/qbx/fmmlib.py +++ b/pytential/qbx/fmmlib.py @@ -148,7 +148,6 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): # OpenCL-land. geo_data = ToHostTransferredGeoDataWrapper(queue, geo_data) - self.geo_data = geo_data self.qbx_order = qbx_order # {{{ digest out_kernels -- GitLab From 54c85353b918b71e292b79173af399aeadd8030d Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Thu, 13 Jun 2019 00:48:06 -0500 Subject: [PATCH 08/17] Update for boxtree renaming of geo_data to optional_geo_data --- pytential/qbx/fmmlib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pytential/qbx/fmmlib.py b/pytential/qbx/fmmlib.py index 21952f4e..decfbd3e 100644 --- a/pytential/qbx/fmmlib.py +++ b/pytential/qbx/fmmlib.py @@ -148,6 +148,7 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): # OpenCL-land. geo_data = ToHostTransferredGeoDataWrapper(queue, geo_data) + self.geo_data = geo_data self.qbx_order = qbx_order # {{{ digest out_kernels @@ -232,7 +233,7 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): dipoles_already_reordered=True, fmm_level_to_nterms=inner_fmm_level_to_nterms, - geo_data=geo_data, + optional_geo_data=geo_data, ifgrad=ifgrad) -- GitLab From ea6348919d5f56e55fc967d549788562f8160583 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Thu, 13 Jun 2019 00:54:47 -0500 Subject: [PATCH 09/17] Update for changing location of RotationClassesBuilder in boxtree --- pytential/qbx/geometry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytential/qbx/geometry.py b/pytential/qbx/geometry.py index b0432ed5..c8090db8 100644 --- a/pytential/qbx/geometry.py +++ b/pytential/qbx/geometry.py @@ -258,7 +258,7 @@ class QBXFMMGeometryCodeGetter(TreeCodeContainerMixin): @property @memoize_method def rotation_classes_builder(self): - from boxtree.traversal import RotationClassesBuilder + from boxtree.rotation_classes import RotationClassesBuilder return RotationClassesBuilder(self.cl_context) # }}} -- GitLab From 5f598c2ef7ee85b6a18bd614baf61ebc7e178afd Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Thu, 13 Jun 2019 13:18:48 -0500 Subject: [PATCH 10/17] Changes for renaming optional_geometry_data to rotation_data in boxtree --- pytential/qbx/fmmlib.py | 2 +- pytential/qbx/geometry.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pytential/qbx/fmmlib.py b/pytential/qbx/fmmlib.py index decfbd3e..0cda4945 100644 --- a/pytential/qbx/fmmlib.py +++ b/pytential/qbx/fmmlib.py @@ -233,7 +233,7 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): dipoles_already_reordered=True, fmm_level_to_nterms=inner_fmm_level_to_nterms, - optional_geo_data=geo_data, + rotation_data=geo_data, ifgrad=ifgrad) diff --git a/pytential/qbx/geometry.py b/pytential/qbx/geometry.py index c8090db8..33348a83 100644 --- a/pytential/qbx/geometry.py +++ b/pytential/qbx/geometry.py @@ -29,7 +29,7 @@ import pyopencl as cl import pyopencl.array # noqa from pytools import memoize_method from boxtree.tools import DeviceDataRecord -from boxtree.pyfmmlib_integration import FMMLibGeometryDataInterface +from boxtree.pyfmmlib_integration import FMMLibRotationDataInterface import loopy as lp from loopy.version import MOST_RECENT_LANGUAGE_VERSION from cgen import Enum @@ -307,7 +307,7 @@ class CenterToTargetList(DeviceDataRecord): """ -class QBXFMMGeometryData(FMMLibGeometryDataInterface): +class QBXFMMGeometryData(FMMLibRotationDataInterface): """ .. rubric :: Attributes -- GitLab From 77ebbf83facfcb5d945fd39b32810ff42c5aa710 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Thu, 13 Jun 2019 23:26:05 -0500 Subject: [PATCH 11/17] Revert "Point Conda requirements.txt to fast-m2l branch of boxtree" This reverts commit 377921388cfabe5f000b8a2c90596f7618250882. --- .test-conda-env-py3-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.test-conda-env-py3-requirements.txt b/.test-conda-env-py3-requirements.txt index 285c7d5c..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@fast-m2l +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 -- GitLab From a14649c92898e0361bc3ae274f6284df07d8d939 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Thu, 13 Jun 2019 23:26:32 -0500 Subject: [PATCH 12/17] Point requirements.txt to boxtree master --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e6e46f95..dd15a69e 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@fast-m2l +git+https://gitlab.tiker.net/inducer/boxtree git+https://github.com/inducer/meshmode git+https://gitlab.tiker.net/inducer/sumpy git+https://gitlab.tiker.net/inducer/pyfmmlib -- GitLab From 16c1f86d0ff41f62244e1f958772bab26b3cbb9c Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Thu, 13 Jun 2019 23:27:25 -0500 Subject: [PATCH 13/17] Revert "Point requirements.txt to boxtree master" This reverts commit a14649c92898e0361bc3ae274f6284df07d8d939. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index dd15a69e..e6e46f95 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@fast-m2l git+https://github.com/inducer/meshmode git+https://gitlab.tiker.net/inducer/sumpy git+https://gitlab.tiker.net/inducer/pyfmmlib -- GitLab From cdfb7a05ece3726440b9c8bbbb7b6b435d9a8e98 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Thu, 13 Jun 2019 23:27:30 -0500 Subject: [PATCH 14/17] Revert "Revert "Point Conda requirements.txt to fast-m2l branch of boxtree"" This reverts commit 77ebbf83facfcb5d945fd39b32810ff42c5aa710. --- .test-conda-env-py3-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.test-conda-env-py3-requirements.txt b/.test-conda-env-py3-requirements.txt index fa6c0426..285c7d5c 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@fast-m2l git+https://github.com/inducer/pymbolic git+https://github.com/inducer/loopy git+https://gitlab.tiker.net/inducer/sumpy -- GitLab From e6309a8648289cc5a481b26d6366d3d321050fde Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 9 Jul 2019 15:07:13 -0500 Subject: [PATCH 15/17] Revert "Revert "Revert "Point Conda requirements.txt to fast-m2l branch of boxtree""" This reverts commit cdfb7a05ece3726440b9c8bbbb7b6b435d9a8e98. --- .test-conda-env-py3-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.test-conda-env-py3-requirements.txt b/.test-conda-env-py3-requirements.txt index 285c7d5c..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@fast-m2l +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 -- GitLab From 90b8aa013ee654f83aaef2d640ae770b237bf0db Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 9 Jul 2019 15:07:42 -0500 Subject: [PATCH 16/17] Revert "Revert "Point requirements.txt to boxtree master"" This reverts commit 16c1f86d0ff41f62244e1f958772bab26b3cbb9c. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e6e46f95..dd15a69e 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@fast-m2l +git+https://gitlab.tiker.net/inducer/boxtree git+https://github.com/inducer/meshmode git+https://gitlab.tiker.net/inducer/sumpy git+https://gitlab.tiker.net/inducer/pyfmmlib -- GitLab From f98cd18a6c65465dd61b81ec4fa93f091f62f2d5 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Wed, 10 Jul 2019 17:00:33 -0500 Subject: [PATCH 17/17] More documentation --- pytential/qbx/geometry.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pytential/qbx/geometry.py b/pytential/qbx/geometry.py index 33348a83..72b054f5 100644 --- a/pytential/qbx/geometry.py +++ b/pytential/qbx/geometry.py @@ -357,6 +357,10 @@ class QBXFMMGeometryData(FMMLibRotationDataInterface): .. automethod:: center_to_tree_targets() .. automethod:: non_qbx_box_target_lists() .. automethod:: plot() + + The following methods implement the + :class:`boxtree.pyfmmlib_integration.FMMLibRotationDataInterface`. + .. method:: m2l_rotation_lists() .. method:: m2l_rotation_angles() """ -- GitLab