From b664fd300bf70805d906116f90ce0db4b455db44 Mon Sep 17 00:00:00 2001 From: Hao Gao Date: Sun, 4 Mar 2018 16:27:15 -0600 Subject: [PATCH 01/13] Use sumpy and boxtree with compressed list 3 --- pytential/qbx/fmm.py | 52 +++++++++++++++++++++++++++++------ pytential/qbx/interactions.py | 50 +++++++++++++++++---------------- requirements.txt | 4 +-- 3 files changed, 71 insertions(+), 35 deletions(-) diff --git a/pytential/qbx/fmm.py b/pytential/qbx/fmm.py index a5292fde..ca03407c 100644 --- a/pytential/qbx/fmm.py +++ b/pytential/qbx/fmm.py @@ -247,8 +247,26 @@ QBXFMMGeometryData.non_qbx_box_target_lists`), source_level_start_ibox, source_mpoles_view = \ self.multipole_expansions_view(multipole_exps, isrc_level) + qbx_center_to_target_box = geo_data.qbx_center_to_target_box() + target_box_to_target_box_source_level = cl.array.empty( + self.queue, len(traversal.target_boxes), + dtype=traversal.tree.box_id_dtype + ) + target_box_to_target_box_source_level.fill(-1) + target_box_to_target_box_source_level[ssn.nonempty_indices] = ( + cl.array.arange(self.queue, ssn.num_nonempty_lists, + dtype=traversal.tree.box_id_dtype) + ) + qbx_center_to_target_box_source_level = ( + target_box_to_target_box_source_level[ + qbx_center_to_target_box + ] + ) + evt, (qbx_expansions_res,) = m2qbxl(self.queue, - qbx_center_to_target_box=geo_data.qbx_center_to_target_box(), + qbx_center_to_target_box_source_level=( + qbx_center_to_target_box_source_level + ), centers=self.tree.box_centers, qbx_centers=geo_data.centers(), @@ -438,7 +456,7 @@ def drive_fmm(expansion_wrangler, src_weights): non_qbx_potentials = non_qbx_potentials + wrangler.eval_multipoles( traversal.level_start_target_box_nrs, - traversal.target_boxes, + traversal.target_boxes_sep_smaller_by_source_level, traversal.from_sep_smaller_by_level, mpole_exps) @@ -717,13 +735,15 @@ def assemble_performance_data(geo_data, uses_pde_expansions, assert tree.nlevels == len(traversal.from_sep_smaller_by_level) - for itgt_box, tgt_ibox in enumerate(traversal.target_boxes): - ntargets = box_target_counts_nonchild[tgt_ibox] - - for ilevel, sep_smaller_list in enumerate( - traversal.from_sep_smaller_by_level): + for ilevel, sep_smaller_list in enumerate( + traversal.from_sep_smaller_by_level): + for itgt_box, tgt_ibox in enumerate( + traversal.target_boxes_by_source_level[ilevel]): + ntargets = box_target_counts_nonchild[tgt_ibox] start, end = sep_smaller_list.starts[itgt_box:itgt_box+2] - nmp_eval[ilevel, itgt_box] += ntargets * (end-start) + nmp_eval[ilevel, + traversal.from_sep_smaller_by_level.nonempty_indices[ + itgt_box]] = ntargets * (end-start) result["mp_eval"] = summarize_parallel(nmp_eval, ncoeffs_fmm) @@ -856,8 +876,22 @@ def assemble_performance_data(geo_data, uses_pde_expansions, assert tree.nlevels == len(traversal.from_sep_smaller_by_level) for isrc_level, ssn in enumerate(traversal.from_sep_smaller_by_level): + target_box_to_target_box_source_level = np.empty( + (len(traversal.target_boxes),), + dtype=traversal.tree.box_id_dtype + ) + target_box_to_target_box_source_level[:] = -1 + target_box_to_target_box_source_level[ssn.nonempty_indices] = ( + np.arange(ssn.num_nonempty_lists, dtype=traversal.tree.box_id_dtype) + ) + for itgt_center, tgt_icenter in enumerate(global_qbx_centers): - icontaining_tgt_box = qbx_center_to_target_box[tgt_icenter] + icontaining_tgt_box = target_box_to_target_box_source_level[ + qbx_center_to_target_box[tgt_icenter] + ] + + if icontaining_tgt_box == -1: + continue start, stop = ( ssn.starts[icontaining_tgt_box], diff --git a/pytential/qbx/interactions.py b/pytential/qbx/interactions.py index 0cca9f17..3ac242ce 100644 --- a/pytential/qbx/interactions.py +++ b/pytential/qbx/interactions.py @@ -160,38 +160,40 @@ class M2QBXL(E2EBase): ], [""" for icenter - <> icontaining_tgt_box = qbx_center_to_target_box[icenter] + <> icontaining_tgt_box = \ + qbx_center_to_target_box_source_level[icenter] - <> tgt_center[idim] = qbx_centers[idim, icenter] \ - {id=fetch_tgt_center} - <> tgt_rscale = qbx_expansion_radii[icenter] + if icontaining_tgt_box != -1 + <> tgt_center[idim] = qbx_centers[idim, icenter] \ + {id=fetch_tgt_center} + <> tgt_rscale = qbx_expansion_radii[icenter] - <> isrc_start = src_box_starts[icontaining_tgt_box] - <> isrc_stop = src_box_starts[icontaining_tgt_box+1] + <> isrc_start = src_box_starts[icontaining_tgt_box] + <> isrc_stop = src_box_starts[icontaining_tgt_box+1] - for isrc_box - <> src_ibox = src_box_lists[isrc_box] \ - {id=read_src_ibox} - <> src_center[idim] = centers[idim, src_ibox] {dup=idim} - <> d[idim] = tgt_center[idim] - src_center[idim] {dup=idim} - """] + [""" + for isrc_box + <> src_ibox = src_box_lists[isrc_box] \ + {id=read_src_ibox} + <> src_center[idim] = centers[idim, src_ibox] {dup=idim} + <> d[idim] = tgt_center[idim] - src_center[idim] {dup=idim} + """] + [""" - <> src_coeff{i} = \ - src_expansions[src_ibox - src_base_ibox, {i}] \ - {{dep=read_src_ibox}} + <> src_coeff{i} = \ + src_expansions[src_ibox - src_base_ibox, {i}] \ + {{dep=read_src_ibox}} - """.format(i=i) for i in range(ncoeff_src)] + [ + """.format(i=i) for i in range(ncoeff_src)] + [ - ] + self.get_translation_loopy_insns() + [""" + ] + self.get_translation_loopy_insns() + [""" + end + """] + [""" + qbx_expansions[icenter, {i}] = qbx_expansions[icenter, {i}] + \ + simul_reduce(sum, isrc_box, coeff{i}) \ + {{id_prefix=write_expn}} + """.format(i=i) + for i in range(ncoeff_tgt)] + [""" end - """] + [""" - qbx_expansions[icenter, {i}] = qbx_expansions[icenter, {i}] + \ - simul_reduce(sum, isrc_box, coeff{i}) \ - {{id_prefix=write_expn}} - """.format(i=i) - for i in range(ncoeff_tgt)] + [""" - end """], [ diff --git a/requirements.txt b/requirements.txt index 8925c34e..130b783e 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@compress-list-3-new git+https://github.com/inducer/meshmode -git+https://gitlab.tiker.net/inducer/sumpy +git+https://gitlab.tiker.net/inducer/sumpy@compress-list-3 git+https://github.com/inducer/pyfmmlib -- GitLab From f64b670326b6063412baa35e0aa6b69aadf71c6b Mon Sep 17 00:00:00 2001 From: Hao Gao Date: Sun, 4 Mar 2018 16:31:00 -0600 Subject: [PATCH 02/13] Fix flake8 --- pytential/qbx/fmm.py | 4 ++-- pytential/qbx/interactions.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pytential/qbx/fmm.py b/pytential/qbx/fmm.py index ca03407c..8af1fa88 100644 --- a/pytential/qbx/fmm.py +++ b/pytential/qbx/fmm.py @@ -249,8 +249,8 @@ QBXFMMGeometryData.non_qbx_box_target_lists`), qbx_center_to_target_box = geo_data.qbx_center_to_target_box() target_box_to_target_box_source_level = cl.array.empty( - self.queue, len(traversal.target_boxes), - dtype=traversal.tree.box_id_dtype + self.queue, len(traversal.target_boxes), + dtype=traversal.tree.box_id_dtype ) target_box_to_target_box_source_level.fill(-1) target_box_to_target_box_source_level[ssn.nonempty_indices] = ( diff --git a/pytential/qbx/interactions.py b/pytential/qbx/interactions.py index 3ac242ce..dad4db1f 100644 --- a/pytential/qbx/interactions.py +++ b/pytential/qbx/interactions.py @@ -175,7 +175,8 @@ class M2QBXL(E2EBase): <> src_ibox = src_box_lists[isrc_box] \ {id=read_src_ibox} <> src_center[idim] = centers[idim, src_ibox] {dup=idim} - <> d[idim] = tgt_center[idim] - src_center[idim] {dup=idim} + <> d[idim] = tgt_center[idim] - src_center[idim] \ + {dup=idim} """] + [""" <> src_coeff{i} = \ @@ -188,7 +189,8 @@ class M2QBXL(E2EBase): end """] + [""" - qbx_expansions[icenter, {i}] = qbx_expansions[icenter, {i}] + \ + qbx_expansions[icenter, {i}] = \ + qbx_expansions[icenter, {i}] + \ simul_reduce(sum, isrc_box, coeff{i}) \ {{id_prefix=write_expn}} """.format(i=i) -- GitLab From 946913b44d0595c7a4bd7cad171eff076dcfdc4e Mon Sep 17 00:00:00 2001 From: Hao Gao Date: Sun, 4 Mar 2018 22:11:13 -0600 Subject: [PATCH 03/13] Adapt more code to compressed list 3 --- pytential/qbx/fmm.py | 8 ++++---- pytential/qbx/fmmlib.py | 31 ++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/pytential/qbx/fmm.py b/pytential/qbx/fmm.py index 8af1fa88..2b43917f 100644 --- a/pytential/qbx/fmm.py +++ b/pytential/qbx/fmm.py @@ -738,12 +738,12 @@ def assemble_performance_data(geo_data, uses_pde_expansions, for ilevel, sep_smaller_list in enumerate( traversal.from_sep_smaller_by_level): for itgt_box, tgt_ibox in enumerate( - traversal.target_boxes_by_source_level[ilevel]): + traversal.target_boxes_sep_smaller_by_source_level[ilevel]): ntargets = box_target_counts_nonchild[tgt_ibox] start, end = sep_smaller_list.starts[itgt_box:itgt_box+2] - nmp_eval[ilevel, - traversal.from_sep_smaller_by_level.nonempty_indices[ - itgt_box]] = ntargets * (end-start) + nmp_eval[ilevel, sep_smaller_list.nonempty_indices[itgt_box]] = ( + ntargets * (end-start) + ) result["mp_eval"] = summarize_parallel(nmp_eval, ncoeffs_fmm) diff --git a/pytential/qbx/fmmlib.py b/pytential/qbx/fmmlib.py index 887b3049..7ae75abb 100644 --- a/pytential/qbx/fmmlib.py +++ b/pytential/qbx/fmmlib.py @@ -351,19 +351,30 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): qbx_centers = geo_data.centers() centers = self.tree.box_centers ngqbx_centers = len(geo_data.global_qbx_centers()) + traversal = geo_data.traversal() if ngqbx_centers == 0: return qbx_exps mploc = self.get_translation_routine("%ddmploc", vec_suffix="_imany") - for isrc_level, ssn in enumerate( - geo_data.traversal().from_sep_smaller_by_level): + for isrc_level, ssn in enumerate(traversal.from_sep_smaller_by_level): source_level_start_ibox, source_mpoles_view = \ self.multipole_expansions_view(multipole_exps, isrc_level) + target_box_to_target_box_source_level = np.empty( + (len(traversal.target_boxes),), + dtype=traversal.tree.box_id_dtype + ) + target_box_to_target_box_source_level[:] = -1 + target_box_to_target_box_source_level[ssn.nonempty_indices] = ( + np.arange(ssn.num_nonempty_lists, dtype=traversal.tree.box_id_dtype) + ) + tgt_icenter_vec = geo_data.global_qbx_centers() - icontaining_tgt_box_vec = qbx_center_to_target_box[tgt_icenter_vec] + icontaining_tgt_box_vec = target_box_to_target_box_source_level[ + qbx_center_to_target_box[tgt_icenter_vec] + ] rscale2 = geo_data.expansion_radii()[geo_data.global_qbx_centers()] @@ -372,9 +383,13 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): kwargs["radius"] = (0.5 * geo_data.expansion_radii()[geo_data.global_qbx_centers()]) - nsrc_boxes_per_gqbx_center = ( - ssn.starts[icontaining_tgt_box_vec+1] - - ssn.starts[icontaining_tgt_box_vec]) + nsrc_boxes_per_gqbx_center = np.zeros(icontaining_tgt_box_vec.shape, + dtype=traversal.tree.box_id_dtype) + mask = (icontaining_tgt_box_vec != -1) + nsrc_boxes_per_gqbx_center[mask] = ( + ssn.starts[icontaining_tgt_box_vec[mask] + 1] - + ssn.starts[icontaining_tgt_box_vec[mask]] + ) nsrc_boxes = np.sum(nsrc_boxes_per_gqbx_center) src_boxes_starts = np.empty(ngqbx_centers+1, dtype=np.int32) @@ -387,7 +402,9 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): src_ibox = np.empty(nsrc_boxes, dtype=np.int32) for itgt_center, tgt_icenter in enumerate( geo_data.global_qbx_centers()): - icontaining_tgt_box = qbx_center_to_target_box[tgt_icenter] + icontaining_tgt_box = target_box_to_target_box_source_level[ + qbx_center_to_target_box[tgt_icenter] + ] src_ibox[ src_boxes_starts[itgt_center]: src_boxes_starts[itgt_center+1]] = ( -- GitLab From 4b42eb9bc588cee0274c523da6275e9406f7cc14 Mon Sep 17 00:00:00 2001 From: Hao Gao Date: Mon, 5 Mar 2018 08:27:08 -0600 Subject: [PATCH 04/13] Remove the first arg in eval_multipoles --- pytential/qbx/fmm.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pytential/qbx/fmm.py b/pytential/qbx/fmm.py index 2b43917f..13684459 100644 --- a/pytential/qbx/fmm.py +++ b/pytential/qbx/fmm.py @@ -455,7 +455,6 @@ def drive_fmm(expansion_wrangler, src_weights): # contribution *out* of the downward-propagating local expansions) non_qbx_potentials = non_qbx_potentials + wrangler.eval_multipoles( - traversal.level_start_target_box_nrs, traversal.target_boxes_sep_smaller_by_source_level, traversal.from_sep_smaller_by_level, mpole_exps) -- GitLab From ab6de721bbd8d1ed40fd0e7f009c2ce24ae44a2f Mon Sep 17 00:00:00 2001 From: Hao Gao Date: Mon, 5 Mar 2018 08:53:08 -0600 Subject: [PATCH 05/13] Use updated boxtree and sumpy for conda --- .test-conda-env-py3-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.test-conda-env-py3-requirements.txt b/.test-conda-env-py3-requirements.txt index fa6c0426..b5cf0413 100644 --- a/.test-conda-env-py3-requirements.txt +++ b/.test-conda-env-py3-requirements.txt @@ -1,5 +1,5 @@ -git+https://gitlab.tiker.net/inducer/boxtree +git+https://gitlab.tiker.net/inducer/boxtree@compress-list-3-new git+https://github.com/inducer/pymbolic git+https://github.com/inducer/loopy -git+https://gitlab.tiker.net/inducer/sumpy +git+https://gitlab.tiker.net/inducer/sumpy@compress-list-3 git+https://github.com/inducer/meshmode -- GitLab From e55940e3d45130889fad1a198ce54b21ff3833e5 Mon Sep 17 00:00:00 2001 From: Hao Gao Date: Wed, 7 Mar 2018 12:30:58 -0600 Subject: [PATCH 06/13] Cache qbx_center_to_target_box_source_level --- pytential/qbx/fmm.py | 31 +++++-------------------------- pytential/qbx/fmmlib.py | 21 +++++++-------------- pytential/qbx/geometry.py | 27 +++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/pytential/qbx/fmm.py b/pytential/qbx/fmm.py index 13684459..18a34d57 100644 --- a/pytential/qbx/fmm.py +++ b/pytential/qbx/fmm.py @@ -247,25 +247,9 @@ QBXFMMGeometryData.non_qbx_box_target_lists`), source_level_start_ibox, source_mpoles_view = \ self.multipole_expansions_view(multipole_exps, isrc_level) - qbx_center_to_target_box = geo_data.qbx_center_to_target_box() - target_box_to_target_box_source_level = cl.array.empty( - self.queue, len(traversal.target_boxes), - dtype=traversal.tree.box_id_dtype - ) - target_box_to_target_box_source_level.fill(-1) - target_box_to_target_box_source_level[ssn.nonempty_indices] = ( - cl.array.arange(self.queue, ssn.num_nonempty_lists, - dtype=traversal.tree.box_id_dtype) - ) - qbx_center_to_target_box_source_level = ( - target_box_to_target_box_source_level[ - qbx_center_to_target_box - ] - ) - evt, (qbx_expansions_res,) = m2qbxl(self.queue, qbx_center_to_target_box_source_level=( - qbx_center_to_target_box_source_level + geo_data.qbx_center_to_target_box_source_level(isrc_level) ), centers=self.tree.box_centers, @@ -875,18 +859,13 @@ def assemble_performance_data(geo_data, uses_pde_expansions, assert tree.nlevels == len(traversal.from_sep_smaller_by_level) for isrc_level, ssn in enumerate(traversal.from_sep_smaller_by_level): - target_box_to_target_box_source_level = np.empty( - (len(traversal.target_boxes),), - dtype=traversal.tree.box_id_dtype - ) - target_box_to_target_box_source_level[:] = -1 - target_box_to_target_box_source_level[ssn.nonempty_indices] = ( - np.arange(ssn.num_nonempty_lists, dtype=traversal.tree.box_id_dtype) + qbx_center_to_target_box_source_level = ( + geo_data.qbx_center_to_target_box_source_level(isrc_level).get() ) for itgt_center, tgt_icenter in enumerate(global_qbx_centers): - icontaining_tgt_box = target_box_to_target_box_source_level[ - qbx_center_to_target_box[tgt_icenter] + icontaining_tgt_box = qbx_center_to_target_box_source_level[ + tgt_icenter ] if icontaining_tgt_box == -1: diff --git a/pytential/qbx/fmmlib.py b/pytential/qbx/fmmlib.py index 7ae75abb..d06967a9 100644 --- a/pytential/qbx/fmmlib.py +++ b/pytential/qbx/fmmlib.py @@ -347,7 +347,6 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): qbx_exps = self.qbx_local_expansion_zeros() geo_data = self.geo_data - qbx_center_to_target_box = geo_data.qbx_center_to_target_box() qbx_centers = geo_data.centers() centers = self.tree.box_centers ngqbx_centers = len(geo_data.global_qbx_centers()) @@ -362,18 +361,12 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): source_level_start_ibox, source_mpoles_view = \ self.multipole_expansions_view(multipole_exps, isrc_level) - target_box_to_target_box_source_level = np.empty( - (len(traversal.target_boxes),), - dtype=traversal.tree.box_id_dtype - ) - target_box_to_target_box_source_level[:] = -1 - target_box_to_target_box_source_level[ssn.nonempty_indices] = ( - np.arange(ssn.num_nonempty_lists, dtype=traversal.tree.box_id_dtype) - ) - tgt_icenter_vec = geo_data.global_qbx_centers() - icontaining_tgt_box_vec = target_box_to_target_box_source_level[ - qbx_center_to_target_box[tgt_icenter_vec] + qbx_center_to_target_box_source_level = ( + geo_data.qbx_center_to_target_box_source_level(isrc_level).get() + ) + icontaining_tgt_box_vec = qbx_center_to_target_box_source_level[ + tgt_icenter_vec ] rscale2 = geo_data.expansion_radii()[geo_data.global_qbx_centers()] @@ -402,8 +395,8 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): src_ibox = np.empty(nsrc_boxes, dtype=np.int32) for itgt_center, tgt_icenter in enumerate( geo_data.global_qbx_centers()): - icontaining_tgt_box = target_box_to_target_box_source_level[ - qbx_center_to_target_box[tgt_icenter] + icontaining_tgt_box = qbx_center_to_target_box_source_level[ + tgt_icenter ] src_ibox[ src_boxes_starts[itgt_center]: diff --git a/pytential/qbx/geometry.py b/pytential/qbx/geometry.py index 7cc8e8ea..30fbb8be 100644 --- a/pytential/qbx/geometry.py +++ b/pytential/qbx/geometry.py @@ -614,6 +614,33 @@ class QBXFMMGeometryData(object): return qbx_center_to_target_box.with_queue(None) + @memoize_method + def qbx_center_to_target_box_source_level(self, source_level): + """Return an array for mapping qbx centers to + `traversal.from_sep_smaller_by_level[source_level]`. + """ + traversal = self.traversal() + sep_smaller = traversal.from_sep_smaller_by_level[source_level] + qbx_center_to_target_box = self.qbx_center_to_target_box() + + target_box_to_target_box_source_level = cl.array.empty( + self.queue, len(traversal.target_boxes), + dtype=traversal.tree.box_id_dtype + ) + target_box_to_target_box_source_level.fill(-1) + target_box_to_target_box_source_level[sep_smaller.nonempty_indices] = ( + cl.array.arange(self.queue, sep_smaller.num_nonempty_lists, + dtype=traversal.tree.box_id_dtype) + ) + + qbx_center_to_target_box_source_level = ( + target_box_to_target_box_source_level[ + qbx_center_to_target_box + ] + ) + + return qbx_center_to_target_box_source_level.with_queue(None) + @memoize_method def global_qbx_flags(self): """Return an array of :class:`numpy.int8` of length -- GitLab From ef40ea850265c97e0980d2f0807485d42e51bcea Mon Sep 17 00:00:00 2001 From: Hao Gao Date: Wed, 7 Mar 2018 23:15:54 -0600 Subject: [PATCH 07/13] Bug fix: add command queue for device array operations --- pytential/qbx/fmm.py | 16 +++++++++++----- pytential/qbx/fmmlib.py | 4 +++- pytential/qbx/geometry.py | 35 ++++++++++++++++++----------------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/pytential/qbx/fmm.py b/pytential/qbx/fmm.py index 18a34d57..39fc5385 100644 --- a/pytential/qbx/fmm.py +++ b/pytential/qbx/fmm.py @@ -775,6 +775,13 @@ def assemble_performance_data(geo_data, uses_pde_expansions, global_qbx_centers = geo_data.global_qbx_centers() 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( + (len(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) + ) with cl.CommandQueue(geo_data.cl_context) as queue: global_qbx_centers = global_qbx_centers.get( @@ -783,6 +790,9 @@ def assemble_performance_data(geo_data, uses_pde_expansions, queue=queue) center_to_targets_starts = center_to_targets_starts.get( queue=queue) + for src_level in range(tree.nlevels): + qbx_center_to_target_box_source_level[src_level].get( + queue=queue) def process_form_qbxl(): ncenters = geo_data.ncenters @@ -859,14 +869,10 @@ def assemble_performance_data(geo_data, uses_pde_expansions, assert tree.nlevels == len(traversal.from_sep_smaller_by_level) for isrc_level, ssn in enumerate(traversal.from_sep_smaller_by_level): - qbx_center_to_target_box_source_level = ( - geo_data.qbx_center_to_target_box_source_level(isrc_level).get() - ) for itgt_center, tgt_icenter in enumerate(global_qbx_centers): icontaining_tgt_box = qbx_center_to_target_box_source_level[ - tgt_icenter - ] + isrc_level][tgt_icenter] if icontaining_tgt_box == -1: continue diff --git a/pytential/qbx/fmmlib.py b/pytential/qbx/fmmlib.py index d06967a9..bd4d025f 100644 --- a/pytential/qbx/fmmlib.py +++ b/pytential/qbx/fmmlib.py @@ -363,7 +363,9 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): tgt_icenter_vec = geo_data.global_qbx_centers() qbx_center_to_target_box_source_level = ( - geo_data.qbx_center_to_target_box_source_level(isrc_level).get() + geo_data.qbx_center_to_target_box_source_level(isrc_level).get( + self.queue + ) ) icontaining_tgt_box_vec = qbx_center_to_target_box_source_level[ tgt_icenter_vec diff --git a/pytential/qbx/geometry.py b/pytential/qbx/geometry.py index 30fbb8be..da98eadd 100644 --- a/pytential/qbx/geometry.py +++ b/pytential/qbx/geometry.py @@ -623,23 +623,24 @@ class QBXFMMGeometryData(object): sep_smaller = traversal.from_sep_smaller_by_level[source_level] qbx_center_to_target_box = self.qbx_center_to_target_box() - target_box_to_target_box_source_level = cl.array.empty( - self.queue, len(traversal.target_boxes), - dtype=traversal.tree.box_id_dtype - ) - target_box_to_target_box_source_level.fill(-1) - target_box_to_target_box_source_level[sep_smaller.nonempty_indices] = ( - cl.array.arange(self.queue, sep_smaller.num_nonempty_lists, - dtype=traversal.tree.box_id_dtype) - ) - - qbx_center_to_target_box_source_level = ( - target_box_to_target_box_source_level[ - qbx_center_to_target_box - ] - ) - - return qbx_center_to_target_box_source_level.with_queue(None) + with cl.CommandQueue(self.cl_context) as queue: + target_box_to_target_box_source_level = cl.array.empty( + queue, len(traversal.target_boxes), + dtype=traversal.tree.box_id_dtype + ) + target_box_to_target_box_source_level.fill(-1) + target_box_to_target_box_source_level[sep_smaller.nonempty_indices] = ( + cl.array.arange(queue, sep_smaller.num_nonempty_lists, + dtype=traversal.tree.box_id_dtype) + ) + + qbx_center_to_target_box_source_level = ( + target_box_to_target_box_source_level[ + qbx_center_to_target_box + ] + ) + + return qbx_center_to_target_box_source_level.with_queue(None) @memoize_method def global_qbx_flags(self): -- GitLab From 1a15f5b66e126c7a0313353acf3d6b0f499aae1e Mon Sep 17 00:00:00 2001 From: Hao Gao Date: Wed, 7 Mar 2018 23:57:23 -0600 Subject: [PATCH 08/13] Bug fix --- pytential/qbx/fmm.py | 7 ++++--- pytential/qbx/fmmlib.py | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pytential/qbx/fmm.py b/pytential/qbx/fmm.py index 39fc5385..037f8188 100644 --- a/pytential/qbx/fmm.py +++ b/pytential/qbx/fmm.py @@ -776,7 +776,7 @@ def assemble_performance_data(geo_data, uses_pde_expansions, 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( - (len(tree.nlevels),), dtype=object + (tree.nlevels,), dtype=object ) for src_level in range(tree.nlevels): qbx_center_to_target_box_source_level[src_level] = ( @@ -791,8 +791,9 @@ def assemble_performance_data(geo_data, uses_pde_expansions, center_to_targets_starts = center_to_targets_starts.get( queue=queue) for src_level in range(tree.nlevels): - qbx_center_to_target_box_source_level[src_level].get( - queue=queue) + qbx_center_to_target_box_source_level[src_level] = ( + qbx_center_to_target_box_source_level[src_level].get(queue=queue) + ) def process_form_qbxl(): ncenters = geo_data.ncenters diff --git a/pytential/qbx/fmmlib.py b/pytential/qbx/fmmlib.py index bd4d025f..578dadce 100644 --- a/pytential/qbx/fmmlib.py +++ b/pytential/qbx/fmmlib.py @@ -99,6 +99,11 @@ class ToHostTransferredGeoDataWrapper(object): def qbx_center_to_target_box(self): return self.geo_data.qbx_center_to_target_box().get(queue=self.queue) + @memoize_method + def qbx_center_to_target_box_source_level(self, source_level): + return self.geo_data.qbx_center_to_target_box_source_level( + source_level).get(queue=self.queue) + @memoize_method def non_qbx_box_target_lists(self): return self.geo_data.non_qbx_box_target_lists().get(queue=self.queue) @@ -363,9 +368,7 @@ class QBXFMMLibExpansionWrangler(FMMLibExpansionWrangler): tgt_icenter_vec = geo_data.global_qbx_centers() qbx_center_to_target_box_source_level = ( - geo_data.qbx_center_to_target_box_source_level(isrc_level).get( - self.queue - ) + geo_data.qbx_center_to_target_box_source_level(isrc_level) ) icontaining_tgt_box_vec = qbx_center_to_target_box_source_level[ tgt_icenter_vec -- GitLab From c2ddc150df0904b5990e46d9d647b0c35d454c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Fri, 9 Mar 2018 01:15:02 -0500 Subject: [PATCH 09/13] Improve docs on qbx_center_to_target_box_source_level --- pytential/qbx/geometry.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pytential/qbx/geometry.py b/pytential/qbx/geometry.py index da98eadd..f9cc10e0 100644 --- a/pytential/qbx/geometry.py +++ b/pytential/qbx/geometry.py @@ -616,8 +616,10 @@ class QBXFMMGeometryData(object): @memoize_method def qbx_center_to_target_box_source_level(self, source_level): - """Return an array for mapping qbx centers to - `traversal.from_sep_smaller_by_level[source_level]`. + """Return an array for mapping qbx centers to indices into + interaction lists as found in + ``traversal.from_sep_smaller_by_level[source_level].`` + -1 if no such interaction list exist on *source_level*. """ traversal = self.traversal() sep_smaller = traversal.from_sep_smaller_by_level[source_level] -- GitLab From 81d072b10b11dfd1b2e342a62a42ab7f9d615086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Fri, 9 Mar 2018 01:58:40 -0500 Subject: [PATCH 10/13] Point .test-conda-env-py3-requirements.txt back at master for sumpy, boxtree [ci skip] --- .test-conda-env-py3-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.test-conda-env-py3-requirements.txt b/.test-conda-env-py3-requirements.txt index b5cf0413..fa6c0426 100644 --- a/.test-conda-env-py3-requirements.txt +++ b/.test-conda-env-py3-requirements.txt @@ -1,5 +1,5 @@ -git+https://gitlab.tiker.net/inducer/boxtree@compress-list-3-new +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@compress-list-3 +git+https://gitlab.tiker.net/inducer/sumpy git+https://github.com/inducer/meshmode -- GitLab From 1740ebfd4bbb3cdfc81974eb9a51d406406deb32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Fri, 9 Mar 2018 02:00:56 -0500 Subject: [PATCH 11/13] Point requirements.txt back at sumpy, boxtree master --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 130b783e..8925c34e 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@compress-list-3-new +git+https://gitlab.tiker.net/inducer/boxtree git+https://github.com/inducer/meshmode -git+https://gitlab.tiker.net/inducer/sumpy@compress-list-3 +git+https://gitlab.tiker.net/inducer/sumpy git+https://github.com/inducer/pyfmmlib -- GitLab From ee5ef623eebdfbe93d7076418338564ce3e34d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Fri, 9 Mar 2018 13:06:28 -0500 Subject: [PATCH 12/13] Update .gitlab-ci.yml: Allow two retries of Conda Apple --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 48d7cd3f..750bf6f4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -80,6 +80,7 @@ Python 3.5 Conda Apple: - apple except: - tags + retry: 2 Documentation: script: -- GitLab From 810708837f7f8e0d76ed467d17017e8185b9b704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Fri, 9 Mar 2018 14:01:48 -0500 Subject: [PATCH 13/13] Bump kernel version for https://gitlab.tiker.net/inducer/pytential/merge_requests/91 --- pytential/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytential/version.py b/pytential/version.py index 0118173d..426eafaf 100644 --- a/pytential/version.py +++ b/pytential/version.py @@ -5,4 +5,4 @@ VERSION_TEXT = ".".join(str(i) for i in VERSION) # branch name, so as to avoid conflicts with the master branch. Make sure # to reset this to the next number up with "master" before merging into # master. -PYTENTIAL_KERNEL_VERSION = ("master", 9) +PYTENTIAL_KERNEL_VERSION = ("master", 10) -- GitLab