From 6bc5997a9c7bd4e1b35d04a368880c315d189b3e Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Sat, 7 Dec 2019 18:50:54 -0600 Subject: [PATCH 1/2] Misc warning fixes Fixes a few: - loopy language version warnings - PyOpenCL ctx_getter warnings - Sumpy timing data collection warnings - qbx_forced_limit warnings --- pytential/qbx/direct.py | 5 +++-- pytential/unregularized.py | 3 +-- test/test_cost_model.py | 22 +++++++++++----------- test/test_target_specific_qbx.py | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pytential/qbx/direct.py b/pytential/qbx/direct.py index 496259c9..eac3c7fc 100644 --- a/pytential/qbx/direct.py +++ b/pytential/qbx/direct.py @@ -25,8 +25,8 @@ THE SOFTWARE. import loopy as lp import numpy as np +from loopy.version import MOST_RECENT_LANGUAGE_VERSION from sumpy.qbx import LayerPotentialBase - from pytential.version import PYTENTIAL_KERNEL_VERSION @@ -98,7 +98,8 @@ class LayerPotentialOnTargetAndCenterSubset(LayerPotentialBase): arguments, name=self.name, assumptions="ntargets>=1 and nsources>=1", - fixed_parameters=dict(dim=self.dim)) + fixed_parameters=dict(dim=self.dim), + lang_version=MOST_RECENT_LANGUAGE_VERSION) loopy_knl = lp.tag_inames(loopy_knl, "idim*:unr") for expn in self.expansions: diff --git a/pytential/unregularized.py b/pytential/unregularized.py index fc39217e..c2432486 100644 --- a/pytential/unregularized.py +++ b/pytential/unregularized.py @@ -255,9 +255,8 @@ class UnregularizedLayerPotentialSource(LayerPotentialSourceBase): # }}} from boxtree.fmm import drive_fmm - timing_data = {} all_potentials_on_every_tgt = drive_fmm( - geo_data.traversal(), wrangler, strengths, timing_data) + geo_data.traversal(), wrangler, strengths, timing_data=None) # {{{ postprocess fmm diff --git a/test/test_cost_model.py b/test/test_cost_model.py index 7b24f567..55bf804f 100644 --- a/test/test_cost_model.py +++ b/test/test_cost_model.py @@ -101,12 +101,12 @@ def get_density(queue, lpot_source): # {{{ test that timing data gathering can execute succesfully -def test_timing_data_gathering(ctx_getter): +def test_timing_data_gathering(ctx_factory): """Test that timing data gathering can execute succesfully.""" pytest.importorskip("pyfmmlib") - cl_ctx = ctx_getter() + cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) @@ -133,9 +133,9 @@ def test_timing_data_gathering(ctx_getter): (2, False), (3, False), (3, True))) -def test_cost_model(ctx_getter, dim, use_target_specific_qbx): +def test_cost_model(ctx_factory, dim, use_target_specific_qbx): """Test that cost model gathering can execute successfully.""" - cl_ctx = ctx_getter() + cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) lpot_source = ( @@ -156,7 +156,7 @@ def test_cost_model(ctx_getter, dim, use_target_specific_qbx): sym_op_S_plus_D = ( sym.S(k_sym, sigma_sym, qbx_forced_limit=+1) - + sym.D(k_sym, sigma_sym)) + + sym.D(k_sym, sigma_sym, qbx_forced_limit="avg")) op_S_plus_D = bind(lpot_source, sym_op_S_plus_D) cost_S_plus_D = op_S_plus_D.get_modeled_cost(queue, sigma=sigma) assert len(cost_S_plus_D) == 2 @@ -166,9 +166,9 @@ def test_cost_model(ctx_getter, dim, use_target_specific_qbx): # {{{ test cost model metadata gathering -def test_cost_model_metadata_gathering(ctx_getter): +def test_cost_model_metadata_gathering(ctx_factory): """Test that the cost model correctly gathers metadata.""" - cl_ctx = ctx_getter() + cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) from sumpy.expansion.level_to_order import SimpleExpansionOrderFinder @@ -425,10 +425,10 @@ class OpCountingTranslationCostModel(object): (3, False, True), (3, True, False), (3, True, True))) -def test_cost_model_correctness(ctx_getter, dim, off_surface, +def test_cost_model_correctness(ctx_factory, dim, off_surface, use_target_specific_qbx): """Check that computed cost matches that of a constant-one FMM.""" - cl_ctx = ctx_getter() + cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) cost_model = ( @@ -516,12 +516,12 @@ CONSTANT_ONE_PARAMS = dict( ) -def test_cost_model_order_varying_by_level(ctx_getter): +def test_cost_model_order_varying_by_level(ctx_factory): """For FMM order varying by level, this checks to ensure that the costs are different. The varying-level case should have larger cost. """ - cl_ctx = ctx_getter() + cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) # {{{ constant level to order diff --git a/test/test_target_specific_qbx.py b/test/test_target_specific_qbx.py index 34091af9..258a4d75 100644 --- a/test/test_target_specific_qbx.py +++ b/test/test_target_specific_qbx.py @@ -133,10 +133,10 @@ def test_spherical_hankel_functions(): @pytest.mark.parametrize("op", ["S", "D", "Sp"]) @pytest.mark.parametrize("helmholtz_k", [0, 1.2, 12 + 1.2j]) @pytest.mark.parametrize("qbx_order", [0, 1, 5]) -def test_target_specific_qbx(ctx_getter, op, helmholtz_k, qbx_order): +def test_target_specific_qbx(ctx_factory, op, helmholtz_k, qbx_order): logging.basicConfig(level=logging.INFO) - cl_ctx = ctx_getter() + cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) target_order = 4 -- GitLab From 5efc56ebaa7d7cbbc98cbffe4f176bf22884fd42 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Sat, 7 Dec 2019 18:53:55 -0600 Subject: [PATCH 2/2] Fix a flake8 error --- pytential/unregularized.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pytential/unregularized.py b/pytential/unregularized.py index c2432486..4e8e3098 100644 --- a/pytential/unregularized.py +++ b/pytential/unregularized.py @@ -273,6 +273,7 @@ class UnregularizedLayerPotentialSource(LayerPotentialSourceBase): # }}} + timing_data = {} return result, timing_data # }}} -- GitLab