From c413dd0754a6e27921b9873b0eea2b7526cd1e62 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Fri, 11 May 2018 14:14:47 +0200 Subject: [PATCH 01/11] Introduce custom iname tags This introduces a general mechanism to add arbitrary tags to inames. In detail, the following changes are done: * A base class `InameTag` is added. Any tags attached through the `tag_inames` transformation, that are instances of this base class are added untouched * A class `CustomTag` is provided, which allows adding tags as strings i.e. `custom:foo` will result in a tag `CustomTag(foo)` being added to the iname --- loopy/kernel/data.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/loopy/kernel/data.py b/loopy/kernel/data.py index 35a8e3b1d..c075085fa 100644 --- a/loopy/kernel/data.py +++ b/loopy/kernel/data.py @@ -78,7 +78,7 @@ def filter_iname_tags_by_type(tags, tag_type, max_num=None, min_num=None): return result -class IndexTag(ImmutableRecord): +class InameTag(ImmutableRecord): __slots__ = [] def __hash__(self): @@ -104,6 +104,10 @@ class IndexTag(ImmutableRecord): return type(self).__name__ +class IndexTag(InameTag): + pass + + class ConcurrentTag(IndexTag): pass @@ -198,11 +202,18 @@ class InOrderSequentialSequentialTag(IndexTag): return "ord" +class CustomTag(InameTag): + __slots__ = ["tag"] + + def __init__(self, tag): + return InameTag.__init__(self, tag=tag) + + def parse_tag(tag): if tag is None: return tag - if isinstance(tag, IndexTag): + if isinstance(tag, InameTag): return tag if not isinstance(tag, str): @@ -228,6 +239,8 @@ def parse_tag(tag): return AutoFitLocalIndexTag() else: return LocalIndexTag(int(axis)) + elif tag.startswith("custom"): + return CustomTag(tag[7:]) else: raise ValueError("cannot parse tag: %s" % tag) -- GitLab From b1c6fc55166819649cfc5bccde001a00d4cdde9d Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Mon, 14 May 2018 11:36:58 +0200 Subject: [PATCH 02/11] Implement custom iname tags through a parser registry Second go at custom iname tags. Iname tags are parsed by the kernels parse_iname_tag methods, which uses a list of parser objects from three sources: * Parsers added to the kernel object through the keyword argument `iname_tag_parsers`. * Parsers provided by the target through the `iname_tag_parsers` method * A global parser `default_iname_tag_parser` currently parsing all the existent implementation tags. Parser are expected to return an instance of `loopy.kernel.data.InameTag` or `None`, if the parser does not accept the given tag. This follows the idea of how loopy handles function manglers. --- loopy/kernel/__init__.py | 36 +++++++++++++++- loopy/kernel/data.py | 90 +++++++++++++++++----------------------- loopy/match.py | 17 +++++++- loopy/target/__init__.py | 3 ++ loopy/transform/iname.py | 22 +--------- 5 files changed, 93 insertions(+), 75 deletions(-) diff --git a/loopy/kernel/__init__.py b/loopy/kernel/__init__.py index 429961a71..4f616036a 100644 --- a/loopy/kernel/__init__.py +++ b/loopy/kernel/__init__.py @@ -143,9 +143,19 @@ class LoopKernel(ImmutableRecordWithoutPickling): .. attribute:: iname_to_tags A :class:`dict` mapping inames (as strings) - to set of instances of :class:`loopy.kernel.data.IndexTag`. + to set of instances of :class:`loopy.kernel.data.InameTag`. .. versionadded:: 2018.1 + .. attribute:: iname_tag_parsers + + A list of parsers for iname tags. These are expected to return instances + of `loopy.kernel.data.InameTag` or `None` if the parser does not accept + the tag. A list of parsers for loopy builtin implementation tags is + automatically appended and the kernels target may add additional parsers + to the list as well. + + .. versionadded:: 2018.2 + .. attribute:: function_manglers .. attribute:: symbol_manglers @@ -199,6 +209,7 @@ class LoopKernel(ImmutableRecordWithoutPickling): local_sizes={}, temporary_variables={}, iname_to_tags=defaultdict(set), + iname_tag_parsers=[], substitutions={}, function_manglers=[ default_function_mangler, @@ -296,7 +307,8 @@ class LoopKernel(ImmutableRecordWithoutPickling): target=target, overridden_get_grid_sizes_for_insn_ids=( overridden_get_grid_sizes_for_insn_ids), - _cached_written_variables=_cached_written_variables) + _cached_written_variables=_cached_written_variables, + iname_tag_parsers=iname_tag_parsers) self._kernel_executor_cache = {} @@ -651,6 +663,26 @@ class LoopKernel(ImmutableRecordWithoutPickling): # {{{ iname wrangling + def parse_iname_tag(self, tag): + if tag is None: + return tag + + from loopy.kernel.data import InameTag + if isinstance(tag, InameTag): + return tag + + from loopy.kernel.data import default_iname_tag_parser + parsers = (self.iname_tag_parsers + + self.target.iname_tag_parsers() + + [default_iname_tag_parser(self)]) + + for parser in parsers: + parse = parser(tag) + if parse is not None: + return parse + + raise ValueError("cannot parse tag: %s" % tag) + @memoize_method def all_inames(self): result = set() diff --git a/loopy/kernel/data.py b/loopy/kernel/data.py index c075085fa..0838c1180 100644 --- a/loopy/kernel/data.py +++ b/loopy/kernel/data.py @@ -202,47 +202,44 @@ class InOrderSequentialSequentialTag(IndexTag): return "ord" -class CustomTag(InameTag): - __slots__ = ["tag"] - - def __init__(self, tag): - return InameTag.__init__(self, tag=tag) - - -def parse_tag(tag): - if tag is None: - return tag - - if isinstance(tag, InameTag): - return tag - - if not isinstance(tag, str): - raise ValueError("cannot parse tag: %s" % tag) - - if tag == "for": - return None - elif tag == "ord": - return InOrderSequentialSequentialTag() - elif tag in ["unr"]: - return UnrollTag() - elif tag in ["vec"]: - return VectorizeTag() - elif tag in ["ilp", "ilp.unr"]: - return UnrolledIlpTag() - elif tag == "ilp.seq": - return LoopedIlpTag() - elif tag.startswith("g."): - return GroupIndexTag(int(tag[2:])) - elif tag.startswith("l."): - axis = tag[2:] - if axis == "auto": - return AutoFitLocalIndexTag() - else: - return LocalIndexTag(int(axis)) - elif tag.startswith("custom"): - return CustomTag(tag[7:]) - else: - raise ValueError("cannot parse tag: %s" % tag) +def default_iname_tag_parser(kernel): + def _parser(tag): + if tag == "for": + return None + elif tag == "ord": + return InOrderSequentialSequentialTag() + elif tag in ["unr"]: + return UnrollTag() + elif tag in ["vec"]: + return VectorizeTag() + elif tag in ["ilp", "ilp.unr"]: + return UnrolledIlpTag() + elif tag == "ilp.seq": + return LoopedIlpTag() + elif tag.startswith("g."): + return GroupIndexTag(int(tag[2:])) + elif tag.startswith("l."): + axis = tag[2:] + if axis == "auto": + return AutoFitLocalIndexTag() + else: + return LocalIndexTag(int(axis)) + elif tag.startswith("like."): + tags = kernel.iname_to_tags[tag[5:]] + if len(tags) == 0: + return None + if len(tags) == 1: + return tags[0] + else: + raise LoopyError("cannot use like for multiple tags (for now)") + elif tag == "unused.g": + from loopy.transform.iname import find_unused_axis_tag + return find_unused_axis_tag(kernel, "g") + elif tag == "unused.l": + from loopy.transform.iname import find_unused_axis_tag + return find_unused_axis_tag(kernel, "l") + + return _parser # }}} @@ -599,17 +596,6 @@ class TemporaryVariable(ArrayBase): # }}} -def iname_tag_to_temp_var_scope(iname_tag): - iname_tag = parse_tag(iname_tag) - - if isinstance(iname_tag, GroupIndexTag): - return temp_var_scope.GLOBAL - elif isinstance(iname_tag, LocalIndexTag): - return temp_var_scope.LOCAL - else: - return temp_var_scope.PRIVATE - - # {{{ substitution rule class SubstitutionRule(ImmutableRecord): diff --git a/loopy/match.py b/loopy/match.py index 3c047e463..531b60dc4 100644 --- a/loopy/match.py +++ b/loopy/match.py @@ -50,6 +50,7 @@ Match expressions .. autoclass:: Writes .. autoclass:: Reads .. autoclass:: Iname +.. autoclass:: InameTagged """ @@ -74,6 +75,7 @@ _tag = intern("_tag") _writes = intern("_writes") _reads = intern("_reads") _iname = intern("_iname") +_inametag = intern("_inametag") _whitespace = intern("_whitespace") @@ -93,12 +95,13 @@ _LEX_TABLE = [ (_writes, RE(r"writes:([\w?*]+)")), (_reads, RE(r"reads:([\w?*]+)")), (_iname, RE(r"iname:([\w?*]+)")), + (_inametag, RE(r"inametag:([\w?*]+)")), (_whitespace, RE("[ \t]+")), ] -_TERMINALS = ([_id, _tag, _writes, _reads, _iname]) +_TERMINALS = ([_id, _tag, _writes, _reads, _iname, _inametag]) # {{{ operator precedence @@ -267,6 +270,18 @@ class Iname(GlobMatchExpressionBase): return any(self.re.match(name) for name in matchable.within_inames) + +class InameTagged(MatchExpressionBase): + def __init__(self, tag): + if isinstance(tag, str): + from loopy.kernel.data import parse_tag + tag = parse_tag(tag) + self.tag = tag + + def __call__(self, kernel, matchable): + return any(self.tag in kernel.iname_to_tags[iname] + for iname in matchable.within_inames) + # }}} diff --git a/loopy/target/__init__.py b/loopy/target/__init__.py index a08b406f5..6a0aee404 100644 --- a/loopy/target/__init__.py +++ b/loopy/target/__init__.py @@ -140,6 +140,9 @@ class TargetBase(object): """ raise NotImplementedError() + def iname_tag_parsers(self): + return [] + class ASTBuilderBase(object): """An interface for generating (host or device) ASTs. diff --git a/loopy/transform/iname.py b/loopy/transform/iname.py index 423ccfb55..13e64d61a 100644 --- a/loopy/transform/iname.py +++ b/loopy/transform/iname.py @@ -666,26 +666,8 @@ def tag_inames(kernel, iname_to_tag, force=False, ignore_nonexistent=False): unpack_iname_to_tag.append((iname, tags)) iname_to_tag = unpack_iname_to_tag - from loopy.kernel.data import parse_tag as inner_parse_tag - - def parse_tag(tag): - if isinstance(tag, str): - if tag.startswith("like."): - tags = kernel.iname_to_tags[tag[5:]] - if len(tags) == 0: - return None - if len(tags) == 1: - return tags[0] - else: - raise LoopyError("cannot use like for multiple tags (for now)") - elif tag == "unused.g": - return find_unused_axis_tag(kernel, "g") - elif tag == "unused.l": - return find_unused_axis_tag(kernel, "l") - - return inner_parse_tag(tag) - - iname_to_tag = [(iname, parse_tag(tag)) for iname, tag in iname_to_tag] + iname_to_tag = [(iname, kernel.parse_iname_tag(tag)) + for iname, tag in iname_to_tag] from loopy.kernel.data import (ConcurrentTag, ForceSequentialTag, filter_iname_tags_by_type) -- GitLab From d99483de14221a3559621f72acd15814b2698a4b Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Mon, 14 May 2018 11:54:26 +0200 Subject: [PATCH 03/11] Fix occurence of tag parsing in precompute transformation --- loopy/transform/precompute.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/loopy/transform/precompute.py b/loopy/transform/precompute.py index 1af16f92f..36e791941 100644 --- a/loopy/transform/precompute.py +++ b/loopy/transform/precompute.py @@ -426,8 +426,7 @@ def precompute(kernel, subst_use, sweep_inames=[], within=None, from loopy.match import parse_stack_match within = parse_stack_match(within) - from loopy.kernel.data import parse_tag - default_tag = parse_tag(default_tag) + default_tag = kernel.parse_iname_tag(default_tag) try: subst = kernel.substitutions[subst_name] -- GitLab From 4db14da521bda4552895baba16bc942bc83fe37a Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Mon, 14 May 2018 12:47:18 +0200 Subject: [PATCH 04/11] Remove dummy tag 'for' and pass None instead With the parsing mechanism, parsers cannot accept a tag and return None. Instead, we can directly pass None as the tag, which has the same effect. --- loopy/kernel/data.py | 4 +--- test/test_apps.py | 6 +++--- test/test_numa_diff.py | 2 +- test/test_transform.py | 8 ++++---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/loopy/kernel/data.py b/loopy/kernel/data.py index 0838c1180..3de1e4bd7 100644 --- a/loopy/kernel/data.py +++ b/loopy/kernel/data.py @@ -204,9 +204,7 @@ class InOrderSequentialSequentialTag(IndexTag): def default_iname_tag_parser(kernel): def _parser(tag): - if tag == "for": - return None - elif tag == "ord": + if tag == "ord": return InOrderSequentialSequentialTag() elif tag in ["unr"]: return UnrollTag() diff --git a/test/test_apps.py b/test/test_apps.py index ee3d4ff44..e82243619 100644 --- a/test/test_apps.py +++ b/test/test_apps.py @@ -544,7 +544,7 @@ def test_fd_1d(ctx_factory): knl = lp.split_iname(knl, "i", 16) knl = lp.extract_subst(knl, "u_acc", "u[j]", parameters="j") - knl = lp.precompute(knl, "u_acc", "i_inner", default_tag="for") + knl = lp.precompute(knl, "u_acc", "i_inner", default_tag=None) knl = lp.assume(knl, "n mod 16 = 0") lp.auto_test_vs_ref( @@ -584,12 +584,12 @@ def test_poisson_fem(ctx_factory): knl = lp.prioritize_loops(knl, ["c", "j", "i", "k"]) def variant_1(knl): - knl = lp.precompute(knl, "dpsi", "i,k,ell", default_tag='for') + knl = lp.precompute(knl, "dpsi", "i,k,ell", default_tag=None) knl = lp.prioritize_loops(knl, "c,i,j") return knl def variant_2(knl): - knl = lp.precompute(knl, "dpsi", "i,ell", default_tag='for') + knl = lp.precompute(knl, "dpsi", "i,ell", default_tag=None) knl = lp.prioritize_loops(knl, "c,i,j") return knl diff --git a/test/test_numa_diff.py b/test/test_numa_diff.py index be07b6c31..01c16eb11 100644 --- a/test/test_numa_diff.py +++ b/test/test_numa_diff.py @@ -183,7 +183,7 @@ def test_gnuma_horiz_kernel(ctx_factory, ilp_multiple, Nq, opt_level): # noqa Q_dim_field_outer="unr")) hsv = lp.buffer_array(hsv, "rhsQ", ilp_inames, - fetch_bounding_box=True, default_tag="for", + fetch_bounding_box=True, default_tag=None, init_expression="0", store_expression="base + buffer") if opt_level == 5: diff --git a/test/test_transform.py b/test/test_transform.py index 210984512..77c459823 100644 --- a/test/test_transform.py +++ b/test/test_transform.py @@ -441,9 +441,9 @@ def test_precompute_with_preexisting_inames(ctx_factory): knl = lp.extract_subst(knl, "D1_subst", "D1[ii,jj]", parameters="ii,jj") knl = lp.extract_subst(knl, "D2_subst", "D2[ii,jj]", parameters="ii,jj") - knl = lp.precompute(knl, "D1_subst", "i,j", default_tag="for", + knl = lp.precompute(knl, "D1_subst", "i,j", default_tag=None, precompute_inames="ii,jj") - knl = lp.precompute(knl, "D2_subst", "i,k", default_tag="for", + knl = lp.precompute(knl, "D2_subst", "i,k", default_tag=None, precompute_inames="ii,jj") knl = lp.prioritize_loops(knl, "ii,jj,e,j,k") @@ -472,10 +472,10 @@ def test_precompute_with_preexisting_inames_fail(): knl = lp.extract_subst(knl, "D1_subst", "D1[ii,jj]", parameters="ii,jj") knl = lp.extract_subst(knl, "D2_subst", "D2[ii,jj]", parameters="ii,jj") - knl = lp.precompute(knl, "D1_subst", "i,j", default_tag="for", + knl = lp.precompute(knl, "D1_subst", "i,j", default_tag=None, precompute_inames="ii,jj") with pytest.raises(lp.LoopyError): - lp.precompute(knl, "D2_subst", "i,k", default_tag="for", + lp.precompute(knl, "D2_subst", "i,k", default_tag=None, precompute_inames="ii,jj") -- GitLab From 2152d2c3328d45dc4eb62d44231c4afcfc8921a6 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Mon, 14 May 2018 13:01:24 +0200 Subject: [PATCH 05/11] Remove a few more well-hidden dummy iname tags "for" --- test/test_scan.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_scan.py b/test/test_scan.py index 505967523..29618dceb 100644 --- a/test/test_scan.py +++ b/test/test_scan.py @@ -165,7 +165,7 @@ def test_dependent_domain_scan(ctx_factory): @pytest.mark.parametrize("i_tag, j_tag", [ - ("for", "for") + (None, None) ]) def test_nested_scan(ctx_factory, i_tag, j_tag): ctx = ctx_factory() @@ -266,7 +266,7 @@ def test_scan_extra_constraints_on_domain(): knl, force_scan=True, force_outer_iname_for_scan="i") -@pytest.mark.parametrize("sweep_iname_tag", ["for", "l.1"]) +@pytest.mark.parametrize("sweep_iname_tag", [None, "l.1"]) def test_scan_with_outer_parallel_iname(ctx_factory, sweep_iname_tag): ctx = ctx_factory() queue = cl.CommandQueue(ctx) @@ -338,7 +338,7 @@ def test_scan_unsupported_tags(): pass -@pytest.mark.parametrize("i_tag", ["for", "l.0"]) +@pytest.mark.parametrize("i_tag", [None, "l.0"]) def test_argmax(ctx_factory, i_tag): logging.basicConfig(level=logging.INFO) @@ -398,7 +398,7 @@ def check_segmented_scan_output(arr, segment_boundaries_indices, out): (3, (0, 2)), (3, (0, 1, 2)), (16, (0, 4, 8, 12))]) -@pytest.mark.parametrize("iname_tag", ("for", "l.0")) +@pytest.mark.parametrize("iname_tag", (None, "l.0")) def test_segmented_scan(ctx_factory, n, segment_boundaries_indices, iname_tag): ctx = ctx_factory() queue = cl.CommandQueue(ctx) -- GitLab From ec2c2a9994472fdf900b668f21141c93014a0b20 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Mon, 14 May 2018 13:17:11 +0200 Subject: [PATCH 06/11] Yet another usage of the for tag --- test/test_loopy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_loopy.py b/test/test_loopy.py index 7a6b8c8a6..2851fcb4d 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -860,7 +860,7 @@ def test_slab_decomposition_does_not_double_execute(ctx_factory): ref_knl = knl - for outer_tag in ["for", "g.0"]: + for outer_tag in [None, "g.0"]: knl = ref_knl knl = lp.split_iname(knl, "i", 4, slabs=(0, 1), inner_tag="unr", outer_tag=outer_tag) -- GitLab From 400add99d3339654ad862131d0d39acd4da3c857 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Mon, 14 May 2018 13:23:41 +0200 Subject: [PATCH 07/11] Add an InameTagged match object to the instruction matching mechanism This can be used either directly through `loopy.match.InameTagged(tag)` or in string syntax as `inametag:tag`. In the latter, tag is restricted to being a string parseable into a tag, while the former also allows a tag object. --- loopy/match.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/loopy/match.py b/loopy/match.py index 531b60dc4..7cd7bb862 100644 --- a/loopy/match.py +++ b/loopy/match.py @@ -273,13 +273,14 @@ class Iname(GlobMatchExpressionBase): class InameTagged(MatchExpressionBase): def __init__(self, tag): - if isinstance(tag, str): - from loopy.kernel.data import parse_tag - tag = parse_tag(tag) self.tag = tag def __call__(self, kernel, matchable): - return any(self.tag in kernel.iname_to_tags[iname] + tag = self.tag + if isinstance(tag, str): + tag = kernel.parse_iname_tag(tag) + + return any(tag in kernel.iname_to_tags[iname] for iname in matchable.within_inames) # }}} @@ -318,6 +319,10 @@ def parse_match(expr): result = Iname(pstate.next_match_obj().group(1)) pstate.advance() return result + elif next_tag is _inametag: + result = InameTagged(pstate.next_match_obj().group(1)) + pstate.advance() + return result else: pstate.expected("terminal") -- GitLab From 78ddfc5fdbf32231249bc0e6ee63a98886583224 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Mon, 14 May 2018 13:48:26 +0200 Subject: [PATCH 08/11] Add a check for the return type of iname tag parsers --- loopy/kernel/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/loopy/kernel/__init__.py b/loopy/kernel/__init__.py index 4f616036a..73106483b 100644 --- a/loopy/kernel/__init__.py +++ b/loopy/kernel/__init__.py @@ -679,6 +679,10 @@ class LoopKernel(ImmutableRecordWithoutPickling): for parser in parsers: parse = parser(tag) if parse is not None: + from loopy.kernel.data import InameTag + if not isinstance(parse, InameTag): + raise TypeError("Iname tag parse results are expected to " + "be instances of loopy.kernel.data.InameTag") return parse raise ValueError("cannot parse tag: %s" % tag) -- GitLab From 5c64727e64ef9f7519ef68bdd631ac22a21272fc Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Wed, 16 May 2018 14:37:48 +0200 Subject: [PATCH 09/11] Allow custom tags in scheduling So far, all tags were known to loopy. Now, the scheduler should not error out on tags it does not understand. --- loopy/codegen/control.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/loopy/codegen/control.py b/loopy/codegen/control.py index fcf8ea3b4..6fbe5af7b 100644 --- a/loopy/codegen/control.py +++ b/loopy/codegen/control.py @@ -143,13 +143,8 @@ def generate_code_for_sched_index(codegen_state, sched_index): func = generate_unroll_loop elif filter_iname_tags_by_type(tags, VectorizeTag): func = generate_vectorize_loop - elif len(tags) == 0 or filter_iname_tags_by_type(tags, (LoopedIlpTag, - ForceSequentialTag, InOrderSequentialSequentialTag)): - func = generate_sequential_loop_dim_code else: - raise RuntimeError("encountered (invalid) EnterLoop " - "for '%s', tagged '%s'" - % (sched_item.iname, ", ".join(str(tag) for tag in tags))) + func = generate_sequential_loop_dim_code return func(codegen_state, sched_index) -- GitLab From d937ab8a4f7f14a2d255fc38a24c6361137d1c5d Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Wed, 16 May 2018 15:09:17 +0200 Subject: [PATCH 10/11] pep8 --- loopy/codegen/control.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/loopy/codegen/control.py b/loopy/codegen/control.py index 6fbe5af7b..156dc656a 100644 --- a/loopy/codegen/control.py +++ b/loopy/codegen/control.py @@ -137,8 +137,7 @@ def generate_code_for_sched_index(codegen_state, sched_index): generate_sequential_loop_dim_code) from loopy.kernel.data import (UnrolledIlpTag, UnrollTag, - ForceSequentialTag, LoopedIlpTag, VectorizeTag, - InOrderSequentialSequentialTag, filter_iname_tags_by_type) + VectorizeTag, filter_iname_tags_by_type) if filter_iname_tags_by_type(tags, (UnrollTag, UnrolledIlpTag)): func = generate_unroll_loop elif filter_iname_tags_by_type(tags, VectorizeTag): -- GitLab From 6f8ae7b4d7dfbdd26714cfeb9d625a44328214a6 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Thu, 19 Jul 2018 11:51:06 +0200 Subject: [PATCH 11/11] Deprecate IndexTag in favor of more general InameTag --- loopy/kernel/data.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/loopy/kernel/data.py b/loopy/kernel/data.py index d17cd832b..1e9483939 100644 --- a/loopy/kernel/data.py +++ b/loopy/kernel/data.py @@ -113,10 +113,13 @@ class InameTag(ImmutableRecord): class IndexTag(InameTag): - pass + def __init__(self): + warn("IndexTag is deprecated, use InameTag instead.", + DeprecationWarning, stacklevel=2) + InameTag.__init__(self) -class ConcurrentTag(IndexTag): +class ConcurrentTag(InameTag): pass @@ -129,7 +132,7 @@ ParallelTag = ConcurrentTag HardwareParallelTag = HardwareConcurrentTag -class UniqueTag(IndexTag): +class UniqueTag(InameTag): pass @@ -195,17 +198,17 @@ class VectorizeTag(UniqueTag): return "vec" -class UnrollTag(IndexTag): +class UnrollTag(InameTag): def __str__(self): return "unr" -class ForceSequentialTag(IndexTag): +class ForceSequentialTag(InameTag): def __str__(self): return "forceseq" -class InOrderSequentialSequentialTag(IndexTag): +class InOrderSequentialSequentialTag(InameTag): def __str__(self): return "ord" -- GitLab