diff --git a/doc/misc.rst b/doc/misc.rst index cd6fe102cb9c97a619d8b6512f103c9dcabe65b5..2c9c9a92bbc903e6eadc458ea7a197fef54c65d4 100644 --- a/doc/misc.rst +++ b/doc/misc.rst @@ -90,7 +90,9 @@ regarding OpenCL drivers. User-visible Changes ==================== -Version 2017.2 +See also :ref:`language-versioning`. + +Version 2018.1 -------------- .. note:: diff --git a/doc/ref_creation.rst b/doc/ref_creation.rst index 92eff09c9e3ecacfd8bb9030a9e4b9f002fefc71..6b715033cce60fa3a369f2abc4edbecbf4c9a0d3 100644 --- a/doc/ref_creation.rst +++ b/doc/ref_creation.rst @@ -30,4 +30,6 @@ To Copy between Data Formats .. autofunction:: make_copy_kernel +.. automodule:: loopy.version + .. vim: tw=75:spell:fdm=marker diff --git a/examples/python/hello-loopy.py b/examples/python/hello-loopy.py index 7c5de5a1b1d7042498a12204959a59021ac5e0d8..e7ab13c1649ef42241fdb2826ab88655b307f969 100644 --- a/examples/python/hello-loopy.py +++ b/examples/python/hello-loopy.py @@ -15,7 +15,8 @@ a = cl.array.arange(queue, n, dtype=np.float32) # ------ knl = lp.make_kernel( "{ [i]: 0<=i= (2018, 1): + options = options.copy(enforce_check_variable_access_ordered=True) + if isinstance(silenced_warnings, str): silenced_warnings = silenced_warnings.split(";") diff --git a/loopy/options.py b/loopy/options.py index 13d0b752dfcfa0f0da233880f27f09a963ab4c81..4277d999a8e23db6751c19b8d27d63ab3847772c 100644 --- a/loopy/options.py +++ b/loopy/options.py @@ -162,6 +162,14 @@ class Options(ImmutableRecord): .. rubric:: Features .. attribute:: disable_global_barriers + + .. attribute:: enforce_check_variable_access_ordered + + If *True*, require that + :func:`loopy.check.check_variable_access_ordered` passes. + Required for language versions 2018.1 and above. This check + helps find and eliminate unintentionally unordered access + to variables. """ _legacy_options_map = { @@ -216,6 +224,9 @@ class Options(ImmutableRecord): disable_global_barriers=kwargs.get("disable_global_barriers", False), check_dep_resolution=kwargs.get("check_dep_resolution", True), + + enforce_check_variable_access_ordered=kwargs.get( + "enforce_check_variable_access_ordered", False), ) # {{{ legacy compatibility diff --git a/loopy/version.py b/loopy/version.py index 7141a678297ded5e0d6e2f16f065f035a034d540..21c920ce49074573a8597a09ee8f2407dfdd7b8b 100644 --- a/loopy/version.py +++ b/loopy/version.py @@ -33,3 +33,55 @@ else: _islpy_version = islpy.version.VERSION_TEXT DATA_MODEL_VERSION = "v76-islpy%s" % _islpy_version + + +FALLBACK_LANGUAGE_VERSION = (2017, 2, 1) +MOST_RECENT_LANGUAGE_VERSION = (2018, 1) + +__doc__ = """ + +.. currentmodule:: loopy +.. data:: VERSION + + A tuple representing the current version number of loopy, for example + **(2017, 2, 1)**. Direct comparison of these tuples will always yield + valid version comparisons. + +.. _language-versioning: + +Loopy Language Versioning +------------------------- + +At version 2018.1, :mod:`loopy` introduced a language versioning scheme to make +it easier to evolve the language while retaining backward compatibility. What +prompted this is the addition of +:attr:`loopy.Options.enforce_check_variable_access_ordered`, which (despite +its name) serves to enable a new check that helps ensure that all variable +access in a kernel is ordered as intended. Since that has the potential to +break existing programs, kernels now have to declare support for a given +language version to let them take advantage of this check. + +As a result, :mod:`loopy` will now issue a warning when a call to +:func:`loopy.make_kernel` does not declare a language version. Such kernels will +(indefinitely) default to language version 2017.2.1. + +Language versions will generally reflect the version number of :mod:`loopy` in +which they were introduced, though it is possible that some versions of +:mod:`loopy` do not introduce new user-visible language features. In such +situations, the previous language version number remains. + + +.. data:: MOST_RECENT_LANGUAGE_VERSION + + A tuple representing the most recent language version number of loopy, for + example **(2018, 1)**. Direct comparison of these tuples will always + yield valid version comparisons. + +History of Language Versions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* ``(2018, 1)``: :attr:`loopy.Options.enforce_check_variable_access_ordered` + is turned on by default. + +* ``(2017, 2, 1)``: Initial legacy language version. +""" diff --git a/test/test_dg.py b/test/test_dg.py index d65c68ed4c729582d511064d6495535efcf7a9a4..ef4a3137324f012d8ad64939d0bf1ab8f00040fb 100644 --- a/test/test_dg.py +++ b/test/test_dg.py @@ -72,7 +72,8 @@ def test_dg_volume(ctx_factory): order=order), lp.ValueArg("K", np.int32, approximately=1000), ], - name="dg_volume", assumptions="K>=1") + name="dg_volume", assumptions="K>=1", + lang_version=(2018, 1)) knl = lp.fix_parameters(knl, Np=Np) diff --git a/test/test_loopy.py b/test/test_loopy.py index e36a4c2c3cb3f7e70a5b039ea631bbce20923be8..02002c5cd844131ee82812c12763e37269373bd9 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -67,7 +67,8 @@ def test_globals_decl_once_with_multi_subprogram(ctx_factory): [lp.TemporaryVariable( 'cnst', shape=('n'), initializer=cnst, scope=lp.temp_var_scope.GLOBAL, - read_only=True), '...']) + read_only=True), '...'], + lang_version=(2018, 1)) knl = lp.fix_parameters(knl, n=16) knl = lp.add_barrier(knl, "id:first", "id:second") @@ -88,7 +89,8 @@ def test_complicated_subst(ctx_factory): h(x) := 1 + g(x) + 20*g$two(x) a[i] = h$one(i) * h$two(i) - """) + """, + lang_version=(2018, 1)) knl = lp.expand_subst(knl, "... > id:h and tag:two > id:g and tag:two") @@ -119,7 +121,8 @@ def test_type_inference_no_artificial_doubles(ctx_factory): lp.GlobalArg("c", np.float32, shape=("n",)), lp.ValueArg("n", np.int32), ], - assumptions="n>=1") + assumptions="n>=1", + lang_version=(2018, 1)) knl = lp.preprocess_kernel(knl, ctx.devices[0]) for k in lp.generate_loop_schedules(knl): @@ -139,7 +142,9 @@ def test_type_inference_with_type_dependencies(): c = b + c <>d = b + 2 + 1j """, - "...") + "...", + lang_version=(2018, 1)) + knl = lp.infer_unknown_types(knl) from loopy.types import to_loopy_type