From b3943b00149e56e1f2d670b7eeccd081b126b45c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 30 Oct 2018 11:01:59 -0500 Subject: [PATCH 1/3] Flake8 fixes --- boxtree/__init__.py | 2 +- boxtree/area_query.py | 30 ++++++++++++++++-------------- boxtree/traversal.py | 4 ++-- boxtree/tree.py | 10 +++++----- boxtree/tree_build.py | 16 +++++++--------- boxtree/tree_build_kernels.py | 8 ++++---- test/test_fmm.py | 3 +-- test/test_tree.py | 31 ++++++++++++++----------------- 8 files changed, 50 insertions(+), 54 deletions(-) diff --git a/boxtree/__init__.py b/boxtree/__init__.py index 1d88ebd..e167a33 100644 --- a/boxtree/__init__.py +++ b/boxtree/__init__.py @@ -29,7 +29,7 @@ __all__ = [ "Tree", "TreeWithLinkedPointSources", "TreeBuilder", "box_flags_enum"] -__doc__ = """ +__doc__ = r""" :mod:`boxtree` can do three main things: * it can sort particles into an adaptively refined quad/octree, diff --git a/boxtree/area_query.py b/boxtree/area_query.py index 42f0ef9..b35d6d9 100644 --- a/boxtree/area_query.py +++ b/boxtree/area_query.py @@ -355,9 +355,9 @@ AREA_QUERY_TEMPLATE = ( void generate(LIST_ARG_DECL USER_ARG_DECL ball_id_t i) { - """ + - AREA_QUERY_WALKER_BODY + """ + + AREA_QUERY_WALKER_BODY + + """ } """) @@ -511,14 +511,16 @@ class AreaQueryElementwiseTemplate(object): coord_t bbox_min_${ax}, %endfor """ + extra_args, - operation="//CL:mako//\n" + - wrap_in_macro("get_ball_center_and_radius(ball_center, ball_radius, i)", - ball_center_and_radius_expr) + - wrap_in_macro("leaf_found_op(leaf_box_id, ball_center, ball_radius)", - leaf_found_op) + - TRAVERSAL_PREAMBLE_MAKO_DEFS + - GUIDING_BOX_FINDER_MACRO + - AREA_QUERY_WALKER_BODY, + operation="//CL:mako//\n" + + wrap_in_macro( + "get_ball_center_and_radius(ball_center, ball_radius, i)", + ball_center_and_radius_expr) + + wrap_in_macro( + "leaf_found_op(leaf_box_id, ball_center, ball_radius)", + leaf_found_op) + + TRAVERSAL_PREAMBLE_MAKO_DEFS + + GUIDING_BOX_FINDER_MACRO + + AREA_QUERY_WALKER_BODY, name=name, preamble=preamble) @@ -554,9 +556,9 @@ class AreaQueryElementwiseTemplate(object): """ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wtypedef-redefinition" - """ + - TRAVERSAL_PREAMBLE_TYPEDEFS_AND_DEFINES + """ + + TRAVERSAL_PREAMBLE_TYPEDEFS_AND_DEFINES + + """ #pragma clang diagnostic pop """, strict_undefined=True).render(**dict(render_vars)) @@ -750,8 +752,8 @@ class AreaQueryBuilder(object): tree.box_child_ids.data, tree.box_flags.data, peer_lists.peer_list_starts.data, peer_lists.peer_lists.data, ball_radii.data, - *(tuple(tree.bounding_box[0]) + - tuple(bc.data for bc in ball_centers)), + *(tuple(tree.bounding_box[0]) + + tuple(bc.data for bc in ball_centers)), wait_for=wait_for) aq_plog.done() diff --git a/boxtree/traversal.py b/boxtree/traversal.py index f7e7045..59624df 100644 --- a/boxtree/traversal.py +++ b/boxtree/traversal.py @@ -190,8 +190,8 @@ typedef ${dtype_to_ctype(vec_types_dict[coord_dtype, dimensions])} coord_vec_t; TRAVERSAL_PREAMBLE_TEMPLATE = ( - TRAVERSAL_PREAMBLE_MAKO_DEFS + - TRAVERSAL_PREAMBLE_TYPEDEFS_AND_DEFINES) + TRAVERSAL_PREAMBLE_MAKO_DEFS + + TRAVERSAL_PREAMBLE_TYPEDEFS_AND_DEFINES) # }}} diff --git a/boxtree/tree.py b/boxtree/tree.py index fa8c438..174286f 100644 --- a/boxtree/tree.py +++ b/boxtree/tree.py @@ -371,8 +371,8 @@ class Tree(DeviceDataRecord): """ crit = ( (self.box_target_starts <= itarget) - & - (itarget < self.box_target_starts + self.box_target_counts_nonchild)) + & (itarget + < self.box_target_starts + self.box_target_counts_nonchild)) return int(np.where(crit)[0]) @@ -382,8 +382,8 @@ class Tree(DeviceDataRecord): """ crit = ( (self.box_source_starts <= isource) - & - (isource < self.box_source_starts + self.box_source_counts_nonchild)) + & (isource + < self.box_source_starts + self.box_source_counts_nonchild)) return int(np.where(crit)[0]) @@ -455,7 +455,7 @@ class TreeWithLinkedPointSources(Tree): def link_point_sources(queue, tree, point_source_starts, point_sources, debug=False): - """ + r""" *Construction:* Requires that :attr:`Tree.sources_have_extent` is *True* on *tree*. diff --git a/boxtree/tree_build.py b/boxtree/tree_build.py index 9670487..ff944c6 100644 --- a/boxtree/tree_build.py +++ b/boxtree/tree_build.py @@ -912,9 +912,9 @@ class TreeBuilder(object): logger.debug("LEVEL %d -> %d boxes" % (level, nboxes_new)) assert ( - level_start_box_nrs[-1] != nboxes_new or - srcntgts_have_extent or - final_level_restrict_iteration) + level_start_box_nrs[-1] != nboxes_new + or srcntgts_have_extent + or final_level_restrict_iteration) if level_start_box_nrs[-1] == nboxes_new: # We haven't created new boxes in this level loop trip. @@ -1153,9 +1153,8 @@ class TreeBuilder(object): if ( h_box_srcntgt_counts_cumul[ibox] - != - h_box_morton_bin_counts[ibox]["nonchild_srcntgts"] - + kid_sum): + != (h_box_morton_bin_counts[ibox]["nonchild_srcntgts"] + + kid_sum)): print("MISMATCH", level, ibox) has_mismatch = True @@ -1428,9 +1427,8 @@ class TreeBuilder(object): if debug: assert ( box_srcntgt_counts_nonchild.get() - == - (box_source_counts_nonchild - + box_target_counts_nonchild).get()).all() + == (box_source_counts_nonchild + + box_target_counts_nonchild).get()).all() if debug: usi_host = user_source_ids.get() diff --git a/boxtree/tree_build_kernels.py b/boxtree/tree_build_kernels.py index a854834..0d900ce 100644 --- a/boxtree/tree_build_kernels.py +++ b/boxtree/tree_build_kernels.py @@ -934,12 +934,12 @@ def build_level_restrict_kernel(context, preamble_with_dtype_decls, operation=LEVEL_RESTRICT_TPL.render(**render_vars), name="level_restrict", preamble=( - str(preamble_with_dtype_decls) + - Template(r""" + str(preamble_with_dtype_decls) + + Template(r""" #define LEVEL_TO_RAD(level) \ (root_extent * 1 / (coord_t) (1 << (level + 1))) - """ + - HELPER_FUNCTION_TEMPLATE) + """ + + HELPER_FUNCTION_TEMPLATE) .render(**render_vars))) # }}} diff --git a/test/test_fmm.py b/test/test_fmm.py index 8041721..d1c0ecb 100644 --- a/test/test_fmm.py +++ b/test/test_fmm.py @@ -492,8 +492,7 @@ def test_pyfmmlib_fmm(ctx_getter, dims, use_dipoles, helmholtz_k): sumpy_rel_err = ( la.norm(pot - sumpy_ref_pot, np.inf) - / - la.norm(sumpy_ref_pot, np.inf)) + / la.norm(sumpy_ref_pot, np.inf)) logger.info("relative l2 error vs sumpy direct: %g" % sumpy_rel_err) assert sumpy_rel_err < 1e-5, sumpy_rel_err diff --git a/test/test_tree.py b/test/test_tree.py index d6fe9f8..e4bc95e 100644 --- a/test/test_tree.py +++ b/test/test_tree.py @@ -165,9 +165,7 @@ def run_build_test(builder, queue, dims, dtype, nparticles, do_plot, start:start+tree.box_source_counts_cumul[ibox]] good = ( (box_particles < extent_high[:, np.newaxis] + scaled_tol) - & - (extent_low[:, np.newaxis] - scaled_tol <= box_particles) - ) + & (extent_low[:, np.newaxis] - scaled_tol <= box_particles)) all_good_here = good.all() if do_plot and not all_good_here and all_good_so_far: @@ -381,10 +379,10 @@ def test_source_target_tree(ctx_getter, dims, do_plot=False): for ibox in range(tree.nboxes): extent_low, extent_high = tree.get_box_extent(ibox) - assert (extent_low >= - tree.bounding_box[0] - 1e-12*tree.root_extent).all(), ibox - assert (extent_high <= - tree.bounding_box[1] + 1e-12*tree.root_extent).all(), ibox + assert (extent_low + >= tree.bounding_box[0] - 1e-12*tree.root_extent).all(), ibox + assert (extent_high + <= tree.bounding_box[1] + 1e-12*tree.root_extent).all(), ibox src_start = tree.box_source_starts[ibox] tgt_start = tree.box_target_starts[ibox] @@ -407,8 +405,7 @@ def test_source_target_tree(ctx_getter, dims, do_plot=False): ]: good = ( (particles < extent_high[:, np.newaxis] + tol) - & - (extent_low[:, np.newaxis] - tol <= particles) + & (extent_low[:, np.newaxis] - tol <= particles) ).all(axis=0) all_good_here = good.all() @@ -544,17 +541,17 @@ def test_extent_tree(ctx_getter, dims, extent_norm, do_plot=False): if ichild_box != 0) assert ( tree.box_target_counts_cumul[ibox] - == - tree.box_target_counts_nonchild[ibox] - + kid_sum), ibox + == ( + tree.box_target_counts_nonchild[ibox] + + kid_sum)), ibox for ibox in range(tree.nboxes): extent_low, extent_high = tree.get_box_extent(ibox) - assert (extent_low >= - tree.bounding_box[0] - 1e-12*tree.root_extent).all(), ibox - assert (extent_high <= - tree.bounding_box[1] + 1e-12*tree.root_extent).all(), ibox + assert (extent_low + >= tree.bounding_box[0] - 1e-12*tree.root_extent).all(), ibox + assert (extent_high + <= tree.bounding_box[1] + 1e-12*tree.root_extent).all(), ibox box_children = tree.box_child_ids[:, ibox] existing_children = box_children[box_children != 0] @@ -594,7 +591,7 @@ def test_extent_tree(ctx_getter, dims, extent_norm, do_plot=False): good = ( (check_particles + check_radii < extent_high[:, np.newaxis] + stick_out_dist) - & + & # noqa: W504 (extent_low[:, np.newaxis] - stick_out_dist <= check_particles - check_radii) ).all(axis=0) -- GitLab From b80ad1ccf824a4f28e66f66785ff25fad1031675 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 30 Oct 2018 11:02:19 -0500 Subject: [PATCH 2/3] Add Titan V CI job, tweak other CIs --- .gitlab-ci.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0b5e7be..9175bff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,15 +14,31 @@ Python 2.7 POCL: reports: junit: test/pytest.xml -#Python 3.5 Titan X: +Python 3.7 Titan V: + script: + - py_version=3.7 + - export PYOPENCL_TEST=nvi:titan + - EXTRA_INSTALL="pybind11 numpy mako" + - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh + - ". ./build-and-test-py-project.sh" + tags: + - python3.7 + - nvidia-titan-v + except: + - tags + artifacts: + reports: + junit: test/pytest.xml + +#Python 3.6 Titan X: # script: -# - py_version=3.5 +# - py_version=3.6 # - export PYOPENCL_TEST=nvi:titan # - EXTRA_INSTALL="pybind11 numpy mako" # - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh # - ". ./build-and-test-py-project.sh" # tags: -# - python3.5 +# - python3.6 # - nvidia-titan-x # except: # - tags @@ -30,16 +46,16 @@ Python 2.7 POCL: # reports: # junit: test/pytest.xml -Python 3.5 K40: +Python 3.6 K40: script: - - export PY_EXE=python3.5 + - export PY_EXE=python3.6 - export PYOPENCL_TEST=nvi:k40 - export EXTRA_INSTALL="pybind11 numpy mako" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh - ". ./build-and-test-py-project.sh" allow_failure: true tags: - - python3.5 + - python3.6 - nvidia-k40 except: - tags -- GitLab From 8e9bbc57ea4141d2b73c5ce0a3f68853e3574789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Tue, 30 Oct 2018 12:33:41 -0400 Subject: [PATCH 3/3] Allow Titan V to fail (but keep it) --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9175bff..1abab4a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,6 +24,7 @@ Python 3.7 Titan V: tags: - python3.7 - nvidia-titan-v + allow_failure: true except: - tags artifacts: -- GitLab