From 2c83fe9b5baa5bb8678d1b7ab9a8dafe167db326 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 16 Apr 2018 18:53:04 -0500 Subject: [PATCH 1/4] Exclude concurrent inames from get_iname_duplication_options because they are never explicitly 'entered' --- loopy/transform/iname.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/loopy/transform/iname.py b/loopy/transform/iname.py index 2347cef3c..743aba5b7 100644 --- a/loopy/transform/iname.py +++ b/loopy/transform/iname.py @@ -956,25 +956,35 @@ def get_iname_duplication_options(knl, use_boostable_into=False): Use :func:`has_schedulable_iname_nesting` to decide whether an iname needs to be duplicated in a given kernel. """ + from loopy.kernel.data import ConcurrentTag + + concurrent_inames = set( + iname + for iname in knl.all_inames() + if isinstance(knl.iname_to_tag.get(iname), ConcurrentTag)) + # First we extract the minimal necessary information from the kernel if use_boostable_into: insn_iname_sets = ( - frozenset(insn.within_inames.union( - insn.boostable_into if insn.boostable_into is not None - else frozenset([])) + frozenset( + (insn.within_inames + | insn.boostable_into if insn.boostable_into is not None + else frozenset([])) + - concurrent_inames for insn in knl.instructions) - frozenset([frozenset([])])) else: insn_iname_sets = ( - frozenset(insn.within_inames for insn in knl.instructions) + frozenset( + insn.within_inames - concurrent_inames + for insn in knl.instructions) - frozenset([frozenset([])])) # Get the duplication options as a tuple of iname and a set for iname, insns in _get_iname_duplication_options(insn_iname_sets): # Check whether this iname has a parallel tag and discard it if so - from loopy.kernel.data import ConcurrentTag if (iname in knl.iname_to_tag and isinstance(knl.iname_to_tag[iname], ConcurrentTag)): continue -- GitLab From d395ca75c286453d9c16e73af2383614067f6aff Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 16 Apr 2018 18:55:25 -0500 Subject: [PATCH 2/4] Ensure that kernels using operation counting have 'ignore_boostable_into' option set to True --- loopy/statistics.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/loopy/statistics.py b/loopy/statistics.py index 5e929b618..7e74ab0a1 100755 --- a/loopy/statistics.py +++ b/loopy/statistics.py @@ -1286,6 +1286,10 @@ def get_op_map(knl, numpy_types=True, count_redundant_work=False, """ + if not knl.options.ignore_boostable_into: + raise LoopyError("Kernel '%s': Using operation counting requires the option " + "ignore_boostable_into to be set." % knl.name) + from loopy.preprocess import preprocess_kernel, infer_unknown_types from loopy.kernel.instruction import ( CallInstruction, CInstruction, Assignment, @@ -1424,6 +1428,10 @@ def get_mem_access_map(knl, numpy_types=True, count_redundant_work=False, """ from loopy.preprocess import preprocess_kernel, infer_unknown_types + if not knl.options.ignore_boostable_into: + raise LoopyError("Kernel '%s': Using operation counting requires the option " + "ignore_boostable_into to be set." % knl.name) + if not isinstance(subgroup_size, int): # try to find subgroup_size subgroup_size_guess = _find_subgroup_size_for_knl(knl) @@ -1615,6 +1623,10 @@ def get_synchronization_map(knl, subgroup_size=None): """ + if not knl.options.ignore_boostable_into: + raise LoopyError("Kernel '%s': Using operation counting requires the option " + "ignore_boostable_into to be set." % knl.name) + from loopy.preprocess import preprocess_kernel, infer_unknown_types from loopy.schedule import (EnterLoop, LeaveLoop, Barrier, CallKernel, ReturnFromKernel, RunInstruction) -- GitLab From 2fd9d7df78fd56e06db7448668f23475d051667c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 16 Apr 2018 18:58:14 -0500 Subject: [PATCH 3/4] Introduce language version 2018.2 to turn on ignore_boostable_into by default --- doc/tutorial.rst | 2 +- loopy/kernel/creation.py | 2 ++ loopy/version.py | 8 +++++++- test/test_statistics.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/tutorial.rst b/doc/tutorial.rst index af8c8281c..3f2cbf5bf 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -25,7 +25,7 @@ import a few modules and set up a :class:`pyopencl.Context` and a >>> import loopy as lp >>> lp.set_caching_enabled(False) - >>> from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 + >>> from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 >>> from warnings import filterwarnings, catch_warnings >>> filterwarnings('error', category=lp.LoopyWarning) diff --git a/loopy/kernel/creation.py b/loopy/kernel/creation.py index bd21a5f39..cd7c4fb22 100644 --- a/loopy/kernel/creation.py +++ b/loopy/kernel/creation.py @@ -2030,6 +2030,8 @@ def make_kernel(domains, instructions, kernel_data=["..."], **kwargs): if lang_version >= (2018, 1): options = options.copy(enforce_variable_access_ordered=True) + if lang_version >= (2018, 2): + options = options.copy(ignore_boostable_into=True) if isinstance(silenced_warnings, str): silenced_warnings = silenced_warnings.split(";") diff --git a/loopy/version.py b/loopy/version.py index 2f29e806e..c731a1b1d 100644 --- a/loopy/version.py +++ b/loopy/version.py @@ -56,12 +56,14 @@ DATA_MODEL_VERSION = "%s-islpy%s-%s-v0" % (VERSION_TEXT, _islpy_version, _git_re FALLBACK_LANGUAGE_VERSION = (2017, 2, 1) -MOST_RECENT_LANGUAGE_VERSION = (2018, 1) +MOST_RECENT_LANGUAGE_VERSION = (2018, 2) +LOOPY_USE_LANGUAGE_VERSION_2018_2 = (2018, 2) LOOPY_USE_LANGUAGE_VERSION_2018_1 = (2018, 1) LOOPY_USE_LANGUAGE_VERSION_2017_2_1 = (2017, 2, 1) LANGUAGE_VERSION_SYMBOLS = [ + "LOOPY_USE_LANGUAGE_VERSION_2018_2", "LOOPY_USE_LANGUAGE_VERSION_2018_1", "LOOPY_USE_LANGUAGE_VERSION_2017_2_1", ] @@ -116,6 +118,10 @@ will work hard to avoid backward-incompatible language changes.) History of Language Versions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. data:: LOOPY_USE_LANGUAGE_VERSION_2018_2 + + :attr:`loopy.Options.ignore_boostable_into` is turned on by default. + .. data:: LOOPY_USE_LANGUAGE_VERSION_2018_1 :attr:`loopy.Options.enforce_variable_access_ordered` diff --git a/test/test_statistics.py b/test/test_statistics.py index e42c43f60..51319bdcf 100644 --- a/test/test_statistics.py +++ b/test/test_statistics.py @@ -36,7 +36,7 @@ from loopy.statistics import CountGranularity as CG from pymbolic.primitives import Variable -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_op_counter_basic(): -- GitLab From 21e44452bcb343445187e2399224d0e22f0eff03 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 16 Apr 2018 19:09:36 -0500 Subject: [PATCH 4/4] Bump language version used throughout tests and examples to 2018.2 --- examples/python/hello-loopy.py | 2 +- loopy/kernel/creation.py | 2 +- loopy/version.py | 2 +- test/test_apps.py | 2 +- test/test_c_execution.py | 2 +- test/test_dg.py | 2 +- test/test_diff.py | 2 +- test/test_domain.py | 2 +- test/test_linalg.py | 2 +- test/test_loopy.py | 2 +- test/test_misc.py | 2 +- test/test_nbody.py | 2 +- test/test_numa_diff.py | 2 +- test/test_reduction.py | 2 +- test/test_scan.py | 2 +- test/test_sem_reagan.py | 2 +- test/test_target.py | 2 +- test/test_transform.py | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/python/hello-loopy.py b/examples/python/hello-loopy.py index 6fa9b5fd3..9098c5444 100644 --- a/examples/python/hello-loopy.py +++ b/examples/python/hello-loopy.py @@ -2,7 +2,7 @@ import numpy as np import loopy as lp import pyopencl as cl import pyopencl.array -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # setup # ----- diff --git a/loopy/kernel/creation.py b/loopy/kernel/creation.py index cd7c4fb22..583f7e7bf 100644 --- a/loopy/kernel/creation.py +++ b/loopy/kernel/creation.py @@ -1925,7 +1925,7 @@ def make_kernel(domains, instructions, kernel_data=["..."], **kwargs): To set the kernel version for all :mod:`loopy` kernels in a (Python) source file, you may simply say:: - from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 + from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 If *lang_version* is not explicitly given, that version value will be used. diff --git a/loopy/version.py b/loopy/version.py index c731a1b1d..2f5006be3 100644 --- a/loopy/version.py +++ b/loopy/version.py @@ -97,7 +97,7 @@ will (indefinitely) default to language version 2017.2.1. If passing a language version to :func:`make_kernel` is impractical, you may also import one of the ``LOOPY_USE_LANGUAGE_VERSION_...`` symbols given below using:: - from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 + from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 in the global namespace of the function calling :func:`make_kernel`. If *lang_version* in that call is not explicitly given, this value will be used. diff --git a/test/test_apps.py b/test/test_apps.py index 279ea4d4a..ee3d4ff44 100644 --- a/test/test_apps.py +++ b/test/test_apps.py @@ -49,7 +49,7 @@ __all__ = [ ] -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa: F401 +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa: F401 # {{{ convolutions diff --git a/test/test_c_execution.py b/test/test_c_execution.py index 01a2cb94f..c355893e4 100644 --- a/test/test_c_execution.py +++ b/test/test_c_execution.py @@ -40,7 +40,7 @@ else: faulthandler.enable() -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_c_target(): diff --git a/test/test_dg.py b/test/test_dg.py index c8623f78d..8de742f27 100644 --- a/test/test_dg.py +++ b/test/test_dg.py @@ -34,7 +34,7 @@ from pyopencl.tools import ( # noqa pytest_generate_tests_for_pyopencl as pytest_generate_tests) -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_dg_volume(ctx_factory): diff --git a/test/test_diff.py b/test/test_diff.py index 054d81f52..b735ab17a 100644 --- a/test/test_diff.py +++ b/test/test_diff.py @@ -48,7 +48,7 @@ __all__ = [ ] -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_diff(ctx_factory): diff --git a/test/test_domain.py b/test/test_domain.py index 20614d510..ebfde8509 100644 --- a/test/test_domain.py +++ b/test/test_domain.py @@ -52,7 +52,7 @@ __all__ = [ ] -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_assume(ctx_factory): diff --git a/test/test_linalg.py b/test/test_linalg.py index 7db6c390f..093fcbf24 100644 --- a/test/test_linalg.py +++ b/test/test_linalg.py @@ -62,7 +62,7 @@ def check_float4(result, ref_result): ref_result[comp], result[comp], rtol=1e-3, atol=1e-3), None -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_axpy(ctx_factory): diff --git a/test/test_loopy.py b/test/test_loopy.py index ef1f491d2..7a6b8c8a6 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -52,7 +52,7 @@ __all__ = [ ] -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_globals_decl_once_with_multi_subprogram(ctx_factory): diff --git a/test/test_misc.py b/test/test_misc.py index c67c66405..05df0317a 100644 --- a/test/test_misc.py +++ b/test/test_misc.py @@ -32,7 +32,7 @@ import logging logger = logging.getLogger(__name__) -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_compute_sccs(): diff --git a/test/test_nbody.py b/test/test_nbody.py index d1a708f72..5b36ed416 100644 --- a/test/test_nbody.py +++ b/test/test_nbody.py @@ -34,7 +34,7 @@ import logging logger = logging.getLogger(__name__) -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_nbody(ctx_factory): diff --git a/test/test_numa_diff.py b/test/test_numa_diff.py index 7479b849b..be07b6c31 100644 --- a/test/test_numa_diff.py +++ b/test/test_numa_diff.py @@ -44,7 +44,7 @@ __all__ = [ ] -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa @pytest.mark.parametrize("Nq", [7]) diff --git a/test/test_reduction.py b/test/test_reduction.py index 866ae9f58..81de627d8 100644 --- a/test/test_reduction.py +++ b/test/test_reduction.py @@ -49,7 +49,7 @@ __all__ = [ ] -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_nonsense_reduction(ctx_factory): diff --git a/test/test_scan.py b/test/test_scan.py index c45afd0d6..505967523 100644 --- a/test/test_scan.py +++ b/test/test_scan.py @@ -56,7 +56,7 @@ __all__ = [ # - scan(a) + scan(b) # - test for badly tagged inames -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa @pytest.mark.parametrize("n", [1, 2, 3, 16]) diff --git a/test/test_sem_reagan.py b/test/test_sem_reagan.py index 450ddeba9..e724a65df 100644 --- a/test/test_sem_reagan.py +++ b/test/test_sem_reagan.py @@ -31,7 +31,7 @@ from pyopencl.tools import ( # noqa pytest_generate_tests_for_pyopencl as pytest_generate_tests) -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_tim2d(ctx_factory): diff --git a/test/test_target.py b/test/test_target.py index 89d72c0ac..eb94bdc81 100644 --- a/test/test_target.py +++ b/test/test_target.py @@ -52,7 +52,7 @@ __all__ = [ ] -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_ispc_target(occa_mode=False): diff --git a/test/test_transform.py b/test/test_transform.py index 2f98fe34d..210984512 100644 --- a/test/test_transform.py +++ b/test/test_transform.py @@ -49,7 +49,7 @@ __all__ = [ ] -from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_1 # noqa +from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa def test_chunk_iname(ctx_factory): -- GitLab