From 0b46e1d1ecae654623a309ef61c53fb8086ec539 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 15 Feb 2017 10:34:40 -0600 Subject: [PATCH 1/6] Instruction construction: Accept strings for depends_on --- loopy/kernel/instruction.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/loopy/kernel/instruction.py b/loopy/kernel/instruction.py index 2e81c2e38..1f1b842a2 100644 --- a/loopy/kernel/instruction.py +++ b/loopy/kernel/instruction.py @@ -222,6 +222,10 @@ class InstructionBase(ImmutableRecord): if within_inames_is_final is None: within_inames_is_final = False + if isinstance(depends_on, str): + depends_on = frozenset( + s.strip() for s in depends_on.split() if s.strip()) + if depends_on_is_final is None: depends_on_is_final = False -- GitLab From b5c01c64792e4a81ae35cbff1d2a7042b11f9698 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 15 Feb 2017 11:17:40 -0600 Subject: [PATCH 2/6] String acceptance for depends_on: split on comma, not space --- loopy/kernel/instruction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopy/kernel/instruction.py b/loopy/kernel/instruction.py index 1f1b842a2..fdd8f1d37 100644 --- a/loopy/kernel/instruction.py +++ b/loopy/kernel/instruction.py @@ -224,7 +224,7 @@ class InstructionBase(ImmutableRecord): if isinstance(depends_on, str): depends_on = frozenset( - s.strip() for s in depends_on.split() if s.strip()) + s.strip() for s in depends_on.split(",") if s.strip()) if depends_on_is_final is None: depends_on_is_final = False -- GitLab From f516e3eb260bd4ead7bb92363963b627a0e35e68 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 15 Feb 2017 11:18:03 -0600 Subject: [PATCH 3/6] Check dependency IDs for resolvability on creation --- loopy/kernel/creation.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/loopy/kernel/creation.py b/loopy/kernel/creation.py index 885ecb576..6eedfcc20 100644 --- a/loopy/kernel/creation.py +++ b/loopy/kernel/creation.py @@ -1624,15 +1624,30 @@ def _resolve_dependencies(knl, insn, deps): new_deps = [] for dep in deps: + found_any = False + if isinstance(dep, MatchExpressionBase): for new_dep in find_instructions(knl, dep): if new_dep.id != insn.id: new_deps.append(new_dep.id) + found_any = True else: from fnmatch import fnmatchcase for other_insn in knl.instructions: if fnmatchcase(other_insn.id, dep): new_deps.append(other_insn.id) + found_any = True + + if not found_any: + raise LoopyError("instruction '%s' declared a depency on '%s', " + "which did not resolve to any instruction present in the " + "kernel '%s'" + % (insn.id, dep, knl.name)) + + for dep_id in new_deps: + if dep_id not in knl.id_to_insn: + raise LoopyError("instruction '%s' depends on instruction id '%s', " + "which was not found" % (insn.id, dep_id)) return frozenset(new_deps) -- GitLab From c2f077881f53abb4cc56ae2d6e3bfc1a281b0e1e Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 15 Feb 2017 11:18:38 -0600 Subject: [PATCH 4/6] Add spaces after dep arrows to improve rendering on 'some' (Mac) terminals --- loopy/kernel/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/loopy/kernel/__init__.py b/loopy/kernel/__init__.py index 1496bf84c..44088ee5f 100644 --- a/loopy/kernel/__init__.py +++ b/loopy/kernel/__init__.py @@ -1273,14 +1273,14 @@ class LoopKernel(ImmutableRecordWithoutPickling): core = Fore.MAGENTA+rhs+Style.RESET_ALL if len(loop_list) > loop_list_width: - lines.append("%s[%s]" % (arrows, loop_list)) - lines.append("%s%s%s # %s" % ( + lines.append("%s [%s]" % (arrows, loop_list)) + lines.append("%s %s%s # %s" % ( extender, (loop_list_width+2)*" ", core, ", ".join(options))) else: - lines.append("%s[%s]%s%s # %s" % ( + lines.append("%s [%s]%s%s # %s" % ( arrows, loop_list, " "*(loop_list_width-len(loop_list)), core, -- GitLab From 2f21dffd36a32dcc019308513856f960be593d1c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 15 Feb 2017 11:41:44 -0600 Subject: [PATCH 5/6] Fix some unresolvable deps --- test/test_apps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_apps.py b/test/test_apps.py index cd225c997..c4844d3a3 100644 --- a/test/test_apps.py +++ b/test/test_apps.py @@ -635,9 +635,9 @@ def test_domain_tree_nesting(): for b_count <>val = vals[offset + b_count] {dep=offset} end - b_sum = exp(b_sum) {id=b_final, dep=b_accum} + b_sum = exp(b_sum) {id=b_final} - out[j,i] = b_sum {dep=a_accum:b_final} + out[j,i] = b_sum {dep=b_final} end end """, -- GitLab From 7bc1305afab0de69f13f04eec0328962d55b3c7b Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 15 Feb 2017 11:56:53 -0600 Subject: [PATCH 6/6] Doctest fix for knl formatting change --- doc/tutorial.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/tutorial.rst b/doc/tutorial.rst index 9e4bd8c91..942c7d56e 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -122,7 +122,7 @@ always see loopy's view of a kernel by printing it. i: None --------------------------------------------------------------------------- INSTRUCTIONS: - [i] out[i] <- 2*a[i] # insn + [i] out[i] <- 2*a[i] # insn --------------------------------------------------------------------------- You'll likely have noticed that there's quite a bit more information here -- GitLab