diff --git a/doc/tutorial.rst b/doc/tutorial.rst index 9e4bd8c913361ad87783dc9220919fc32d8e5e90..942c7d56e01f9d037b0e2b601f88bc8b96dda151 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 diff --git a/loopy/kernel/__init__.py b/loopy/kernel/__init__.py index 1496bf84cc178bbe1f8512b74c2364667b341c96..44088ee5fc16beb4344c8173456d9ed46b83bfe1 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, diff --git a/loopy/kernel/creation.py b/loopy/kernel/creation.py index 885ecb576944c802c407f1fa368b6eb0f8b6ef2e..6eedfcc20e7e59f129c8f19e2d96c07a80714533 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) diff --git a/loopy/kernel/instruction.py b/loopy/kernel/instruction.py index 2e81c2e382561bafd18b49c81fae31905eb10e8e..fdd8f1d3764ec03ca40a8338dc512b8cd2ae38cf 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 diff --git a/test/test_apps.py b/test/test_apps.py index cd225c9974ba9f7c85363bd40a79657622c77eff..c4844d3a3c5d88e0c4eeccf0d67e9b4284fd744f 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 """,