From a092529df78846d15417ca5d73395f60af276ae7 Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 17 Mar 2021 09:27:47 -0500 Subject: [PATCH 01/11] Update dep name loo.py -> loopy --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index be9ec06..16f533f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ filelock -e git+https://gitlab.tiker.net/inducer/pyvisfile.git#egg=pyvisfile -e git+https://gitlab.tiker.net/inducer/pymbolic.git#egg=pymbolic -e git+https://gitlab.tiker.net/inducer/sumpy.git#egg=sumpy --e git+https://gitlab.tiker.net/inducer/loopy.git#egg=loo.py +-e git+https://gitlab.tiker.net/inducer/loopy.git#egg=loopy -e git+https://gitlab.tiker.net/inducer/modepy.git#egg=modepy -e .[test,doc] diff --git a/setup.py b/setup.py index 8b037de..eeb43f8 100644 --- a/setup.py +++ b/setup.py @@ -112,7 +112,7 @@ def main(): install_requires=[ "boxtree", "h5py", - "loo.py", + "loopy", "meshmode", "modepy", "pyevtk", -- GitLab From ec731930cdd65b4228272fe4090f78230fc0d2b2 Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 17 Mar 2021 10:51:37 -0500 Subject: [PATCH 02/11] Fixes out_kernels --- volumential/droste.py | 2 + volumential/expansion_wrangler_fpnd.py | 54 +++++++++++++------------- volumential/volume_fmm.py | 2 +- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/volumential/droste.py b/volumential/droste.py index 382fa2f..bceed02 100644 --- a/volumential/droste.py +++ b/volumential/droste.py @@ -802,6 +802,7 @@ class DrosteFull(DrosteBase): ncpus = multiprocessing.cpu_count() knl = self.get_kernel(**kwargs) knl = lp.split_iname(knl, "icase", ncpus, inner_tag="g.0") + knl = lp.add_inames_for_unused_hw_axes(knl) return knl def call_loopy_kernel(self, queue, **kwargs): @@ -1283,6 +1284,7 @@ class DrosteReduced(DrosteBase): knl = self.get_kernel(**kwargs) knl = lp.join_inames(knl, inames=self.basis_vars, new_iname="func") knl = lp.split_iname(knl, "func", ncpus, inner_tag="g.0") + knl = lp.add_inames_for_unused_hw_axes(knl) return knl def call_loopy_kernel_case(self, queue, base_case_id, **kwargs): diff --git a/volumential/expansion_wrangler_fpnd.py b/volumential/expansion_wrangler_fpnd.py index fe9b059..b691f63 100644 --- a/volumential/expansion_wrangler_fpnd.py +++ b/volumential/expansion_wrangler_fpnd.py @@ -124,8 +124,8 @@ class FPNDSumpyExpansionWrangler( ): """ near_field_table can either one of three things: - 1. a single table, when len(out_kernels) = 1 (single level) - 2. a list of tables, when len(out_kernels) = 1 (multiple levels) + 1. a single table, when len(target_kernels) = 1 (single level) + 2. a list of tables, when len(target_kernels) = 1 (multiple levels) 3. otherwise, a dictionary from kernel.__repr__() to a list of its tables """ @@ -136,16 +136,16 @@ class FPNDSumpyExpansionWrangler( self.near_field_table = {} # list of tables for a single out kernel if isinstance(near_field_table, list): - assert len(self.code.out_kernels) == 1 + assert len(self.code.target_kernels) == 1 self.near_field_table[ - self.code.out_kernels[0].__repr__() + self.code.target_kernels[0].__repr__() ] = near_field_table self.n_tables = len(near_field_table) # single table elif isinstance(near_field_table, NearFieldInteractionTable): - assert len(self.code.out_kernels) == 1 - self.near_field_table[self.code.out_kernels[0].__repr__()] = [ + assert len(self.code.target_kernels) == 1 + self.near_field_table[self.code.target_kernels[0].__repr__()] = [ near_field_table ] self.n_tables = 1 @@ -153,7 +153,7 @@ class FPNDSumpyExpansionWrangler( # dictionary of lists of tables elif isinstance(near_field_table, dict): self.n_tables = dict() - for out_knl in self.code.out_kernels: + for out_knl in self.code.target_kernels: if repr(out_knl) not in near_field_table: raise RuntimeError( "Missing nearfield table for %s." % repr(out_knl)) @@ -174,15 +174,15 @@ class FPNDSumpyExpansionWrangler( self.potential_kind = potential_kind # TODO: make all parameters table-specific (allow using inhomogeneous tables) - kname = repr(self.code.out_kernels[0]) + kname = repr(self.code.target_kernels[0]) self.root_table_source_box_extent = ( self.near_field_table[kname][0].source_box_extent) table_starting_level = np.round( np.log(self.tree.root_extent / self.root_table_source_box_extent) / np.log(2) ) - for kid in range(len(self.code.out_kernels)): - kname = self.code.out_kernels[kid].__repr__() + for kid in range(len(self.code.target_kernels)): + kname = self.code.target_kernels[kid].__repr__() for lev, table in zip( range(len(self.near_field_table[kname])), self.near_field_table[kname] @@ -481,11 +481,11 @@ class FPNDSumpyExpansionWrangler( ): pot = self.output_zeros() events = [] - for i in range(len(self.code.out_kernels)): + for i in range(len(self.code.target_kernels)): # print("processing near-field of out_kernel", i) pot[i], evt = self.eval_direct_single_out_kernel( pot[i], - self.code.out_kernels[i], + self.code.target_kernels[i], target_boxes, neighbor_source_boxes_starts, neighbor_source_boxes_lists, @@ -592,12 +592,12 @@ class FPNDFMMLibExpansionWranglerCodeContainer( """ def __init__(self, cl_context, multipole_expansion_factory, local_expansion_factory, - out_kernels, exclude_self=True, *args, **kwargs): + target_kernels, exclude_self=True, *args, **kwargs): self.cl_context = cl_context self.multipole_expansion_factory = multipole_expansion_factory self.local_expansion_factory = local_expansion_factory - self.out_kernels = out_kernels + self.target_kernels = target_kernels self.exclude_self = True def get_wrangler(self, queue, tree, dtype, fmm_level_to_order, @@ -649,14 +649,14 @@ class FPNDFMMLibExpansionWrangler( self.quad_order = quad_order self.potential_kind = potential_kind - # {{{ digest out_kernels + # {{{ digest target_kernels ifgrad = False outputs = [] source_deriv_names = [] k_names = [] - for out_knl in self.code.out_kernels: + for out_knl in self.code.target_kernels: if self.is_supported_helmknl(out_knl): outputs.append(()) @@ -711,16 +711,16 @@ class FPNDFMMLibExpansionWrangler( self.near_field_table = {} # list of tables for a single out kernel if isinstance(near_field_table, list): - assert len(self.code.out_kernels) == 1 + assert len(self.code.target_kernels) == 1 self.near_field_table[ - self.code.out_kernels[0].__repr__() + self.code.target_kernels[0].__repr__() ] = near_field_table self.n_tables = len(near_field_table) # single table elif isinstance(near_field_table, NearFieldInteractionTable): - assert len(self.code.out_kernels) == 1 - self.near_field_table[self.code.out_kernels[0].__repr__()] = [ + assert len(self.code.target_kernels) == 1 + self.near_field_table[self.code.target_kernels[0].__repr__()] = [ near_field_table ] self.n_tables = 1 @@ -728,7 +728,7 @@ class FPNDFMMLibExpansionWrangler( # dictionary of lists of tables elif isinstance(near_field_table, dict): self.n_tables = dict() - for out_knl in self.code.out_kernels: + for out_knl in self.code.target_kernels: if repr(out_knl) not in near_field_table: raise RuntimeError( "Missing nearfield table for %s." % repr(out_knl)) @@ -746,15 +746,15 @@ class FPNDFMMLibExpansionWrangler( raise RuntimeError("Table type unrecognized.") # TODO: make all parameters table-specific (allow using inhomogeneous tables) - kname = repr(self.code.out_kernels[0]) + kname = repr(self.code.target_kernels[0]) self.root_table_source_box_extent = ( self.near_field_table[kname][0].source_box_extent) table_starting_level = np.round( np.log(self.tree.root_extent / self.root_table_source_box_extent) / np.log(2) ) - for kid in range(len(self.code.out_kernels)): - kname = self.code.out_kernels[kid].__repr__() + for kid in range(len(self.code.target_kernels)): + kname = self.code.target_kernels[kid].__repr__() for lev, table in zip( range(len(self.near_field_table[kname])), self.near_field_table[kname] @@ -1090,11 +1090,11 @@ class FPNDFMMLibExpansionWrangler( if pot.dtype != np.object: pot = make_obj_array([pot, ]) events = [] - for i in range(len(self.code.out_kernels)): + for i in range(len(self.code.target_kernels)): # print("processing near-field of out_kernel", i) pot[i], evt = self.eval_direct_single_out_kernel( pot[i], - self.code.out_kernels[i], + self.code.target_kernels[i], target_boxes, neighbor_source_boxes_starts, neighbor_source_boxes_lists, @@ -1107,7 +1107,7 @@ class FPNDFMMLibExpansionWrangler( out_pot.finish() # boxtree.pyfmmlib_integration handles things diffferently - # when out_kernels has only one element + # when target_kernels has only one element if len(pot) == 1: pot = pot[0] diff --git a/volumential/volume_fmm.py b/volumential/volume_fmm.py index 4504f9f..85ef54c 100644 --- a/volumential/volume_fmm.py +++ b/volumential/volume_fmm.py @@ -179,7 +179,7 @@ def drive_volume_fmm(traversal, expansion_wrangler, src_weights, src_func, p2p = P2P( wrangler.queue.context, - wrangler.code.out_kernels, + wrangler.code.target_kernels, exclude_self=wrangler.code.exclude_self, value_dtypes=[wrangler.dtype], ) -- GitLab From 94d938d9a46de9be94b668b9f60d071b26d16cfe Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 17 Mar 2021 15:27:20 -0500 Subject: [PATCH 03/11] Disable pylint CI, and fixes for sumpy multi-outputs changes --- .gitlab-ci.yml | 16 ---------------- volumential/volume_fmm.py | 22 +++++++++++++++++----- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3038472..1fc8f6a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,22 +7,6 @@ Flake8: except: - tags -Pylint: - script: - # Needed to avoid name shadowing issues when running from source directory. - # Pylint won't find the Cython bits without this - - PROJECT_INSTALL_FLAGS="--editable" - - export PY_EXE=python3 - # Pin to numpy 1.15 - # See https://github.com/PyCQA/pylint/issues/2721 - - EXTRA_INSTALL="Cython pybind11 numpy==1.15 mako matplotlib" - - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-pylint.sh - - ". ./prepare-and-run-pylint.sh volumential test examples benchmarks" - tags: - - python3 - except: - - tags - Python 3 POCL: script: - export PY_EXE=python3 diff --git a/volumential/volume_fmm.py b/volumential/volume_fmm.py index 85ef54c..23685ce 100644 --- a/volumential/volume_fmm.py +++ b/volumential/volume_fmm.py @@ -29,6 +29,7 @@ __doc__ = """ import numpy as np import pyopencl as cl +from pytools.obj_array import make_obj_array from boxtree.fmm import TimingRecorder from volumential.expansion_wrangler_interface import ExpansionWranglerInterface from volumential.expansion_wrangler_fpnd import ( @@ -79,9 +80,19 @@ def drive_volume_fmm(traversal, expansion_wrangler, src_weights, src_func, recorder = TimingRecorder() logger.info("start fmm") + # accept unpacked inputs when doing fmm for just one source field + if src_weights.ndim == 1: + src_weights = make_obj_array([src_weights]) + if src_func.ndim == 1: + src_func = make_obj_array([src_func]) + + assert (ns := len(src_weights)) == len(src_func) + if ns > 1: + raise NotImplementedError("Multiple outputs are not yet supported") + if isinstance(expansion_wrangler, FPNDSumpyExpansionWrangler): - assert isinstance(src_weights, cl.array.Array) - assert isinstance(src_func, cl.array.Array) + assert all(isinstance(sw, cl.array.Array) for sw in src_weights) + assert all(isinstance(sf, cl.array.Array) for sf in src_func) elif isinstance(expansion_wrangler, FPNDFMMLibExpansionWrangler): @@ -94,8 +105,9 @@ def drive_volume_fmm(traversal, expansion_wrangler, src_weights, src_func, if reorder_sources: logger.debug("reorder source weights") - src_weights = wrangler.reorder_sources(src_weights) - src_func = wrangler.reorder_targets(src_func) + for idx_s in range(ns): + src_weights[idx_s] = wrangler.reorder_sources(src_weights[idx_s]) + src_func[idx_s] = wrangler.reorder_targets(src_func[idx_s]) # {{{ Construct local multipoles @@ -130,7 +142,7 @@ def drive_volume_fmm(traversal, expansion_wrangler, src_weights, src_func, traversal.target_boxes, traversal.neighbor_source_boxes_starts, traversal.neighbor_source_boxes_lists, - src_func, + src_func[0], # FIXME: handle multiple source fields ) recorder.add("eval_direct", timing_future) -- GitLab From 18976bb4267ffb75035efb3b1941e5ff80e89473 Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 17 Mar 2021 15:53:51 -0500 Subject: [PATCH 04/11] Bump conda env for CI to python3.8 --- .test-conda-env-py3-macos.yml | 2 +- .test-conda-env-py3.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.test-conda-env-py3-macos.yml b/.test-conda-env-py3-macos.yml index 1735795..0f24403 100644 --- a/.test-conda-env-py3-macos.yml +++ b/.test-conda-env-py3-macos.yml @@ -14,7 +14,7 @@ dependencies: - pocl - islpy - pyopencl - - python>=3.6 + - python>=3.8 - symengine=0.3.0 - python-symengine=0.3.0 - cython diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index d579709..69294ea 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -15,7 +15,7 @@ dependencies: - pocl - islpy - pyopencl - - python=3 + - python>=3.8 - symengine=0.3.0 - python-symengine=0.3.0 - pyfmmlib -- GitLab From c74d7c52096bb9120a1907709edf28c9b6183fbb Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 17 Mar 2021 16:44:34 -0500 Subject: [PATCH 05/11] Try to fix conda ci --- .test-conda-env-py3.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index 69294ea..be3f25c 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -8,12 +8,21 @@ dependencies: - binutils - openmp - scipy - - conda-forge::numpy - - conda-forge::sympy + - numpy + - sympy - pytest - pytest-cov - pocl + - toml + - py + - pluggy + - packaging + - iniconfig + - attrs + - genpy - islpy + - colorama + - pyrsistent - pyopencl - python>=3.8 - symengine=0.3.0 @@ -23,8 +32,9 @@ dependencies: - cmake - tbb-devel - dealii - - gmsh - - python-gmsh + - cgen + - h5py + - pyevtk # for pypvfmm - openmpi-mpicxx - fftw @@ -33,7 +43,7 @@ dependencies: - pip: - git+https://gitlab.tiker.net/inducer/loopy - git+https://gitlab.tiker.net/inducer/gmsh_interop - - git+https://gitlab.tiker.net/xywei/boxtree + - git+https://gitlab.tiker.net/inducer/boxtree - git+https://gitlab.tiker.net/inducer/modepy - git+https://gitlab.tiker.net/inducer/meshmode - git+https://gitlab.tiker.net/inducer/pymbolic -- GitLab From 9193237d1c49848f542b74106e1d0a6b01f2ff0f Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 17 Mar 2021 17:09:19 -0500 Subject: [PATCH 06/11] Conda env updates --- .test-conda-env-py3.yml | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index be3f25c..9df7cdc 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -4,40 +4,33 @@ channels: - defaults dependencies: - git - - c-compiler - - binutils - - openmp + - python>=3.8 + - dealii + - pocl + - pyopencl + - pyfmmlib - scipy - numpy - sympy - - pytest - - pytest-cov - - pocl + - matplotlib + - cgen + - cython - toml - py - pluggy - packaging - iniconfig - attrs + - pytest - genpy - - islpy - colorama + - islpy - pyrsistent - - pyopencl - - python>=3.8 - - symengine=0.3.0 - - python-symengine=0.3.0 - - pyfmmlib - - cython - - cmake - - tbb-devel - - dealii - - cgen - h5py - pyevtk - # for pypvfmm - - openmpi-mpicxx - - fftw + - pytest + - pytest-cov + - cmake - pip - pip: -- GitLab From fad466ef102b7bb4245220e1b9ed1eb616b262de Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 17 Mar 2021 17:20:08 -0500 Subject: [PATCH 07/11] Add symengine --- .test-conda-env-py3.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index 9df7cdc..d70a22d 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -31,6 +31,7 @@ dependencies: - pytest - pytest-cov - cmake + - symengine - pip - pip: -- GitLab From 33dec8d230257818b99dbb1d742af93df82789ff Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 17 Mar 2021 18:13:18 -0500 Subject: [PATCH 08/11] Add python-symengine --- .test-conda-env-py3.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index d70a22d..9d29c63 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -32,6 +32,7 @@ dependencies: - pytest-cov - cmake - symengine + - python-symengine - pip - pip: -- GitLab From d41b1ba16e17f09dac9da3a9ee84df7f1cafa2b7 Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 17 Mar 2021 18:51:01 -0500 Subject: [PATCH 09/11] OSX conda CI fixes --- .test-conda-env-py3-macos.yml | 51 +++++++++++++++++------------------ .test-conda-env-py3.yml | 1 - 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/.test-conda-env-py3-macos.yml b/.test-conda-env-py3-macos.yml index 0f24403..1a0edde 100644 --- a/.test-conda-env-py3-macos.yml +++ b/.test-conda-env-py3-macos.yml @@ -4,42 +4,39 @@ channels: - defaults dependencies: - git - - c-compiler - - pytest - - pytest-cov - - binutils - - scipy - - conda-forge::numpy - - conda-forge::sympy + - python>=3.8 + - dealii - pocl - - islpy - pyopencl - - python>=3.8 - - symengine=0.3.0 - - python-symengine=0.3.0 + - pyfmmlib + - scipy + - numpy + - sympy + - symengine + - python-symengine - cython + - cgen + - toml + - py + - pluggy + - packaging + - iniconfig + - attrs + - genpy + - colorama + - islpy + - pyrsistent + - h5py + - pyevtk + - pytest + - pytest-cov - cmake - - tbb-devel - - dealii - - gmsh - - python-gmsh - - pyfmmlib - # for OpenMP support in pyfmmlib - - libgfortran>=3.0.1 - - clangdev - - openmp - # for pypvfmm - - openmpi-mpicxx - - fftw - - autoconf - - automake - - libtool - pip - pip: - git+https://gitlab.tiker.net/inducer/loopy - git+https://gitlab.tiker.net/inducer/gmsh_interop - - git+https://gitlab.tiker.net/xywei/boxtree + - git+https://gitlab.tiker.net/inducer/boxtree - git+https://gitlab.tiker.net/inducer/modepy - git+https://gitlab.tiker.net/inducer/meshmode - git+https://gitlab.tiker.net/inducer/pymbolic diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index 9d29c63..bbe9d8b 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -21,7 +21,6 @@ dependencies: - packaging - iniconfig - attrs - - pytest - genpy - colorama - islpy -- GitLab From bea84523001c99ca2ea8edc735e1ea7e9e51b4b5 Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 17 Mar 2021 19:13:15 -0500 Subject: [PATCH 10/11] Add openmp --- .test-conda-env-py3-macos.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.test-conda-env-py3-macos.yml b/.test-conda-env-py3-macos.yml index 1a0edde..ca4b7c1 100644 --- a/.test-conda-env-py3-macos.yml +++ b/.test-conda-env-py3-macos.yml @@ -31,6 +31,7 @@ dependencies: - pytest - pytest-cov - cmake + - openmp - pip - pip: -- GitLab From b68a293f22e8f2ae1b4bf8328ce5575a069fc704 Mon Sep 17 00:00:00 2001 From: xywei Date: Wed, 17 Mar 2021 19:39:49 -0500 Subject: [PATCH 11/11] Enable openmp --- .test-conda-env-py3-macos.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.test-conda-env-py3-macos.yml b/.test-conda-env-py3-macos.yml index ca4b7c1..cca9d5b 100644 --- a/.test-conda-env-py3-macos.yml +++ b/.test-conda-env-py3-macos.yml @@ -31,7 +31,9 @@ dependencies: - pytest - pytest-cov - cmake + # enable openmp on osx - openmp + - clangdev - pip - pip: -- GitLab