Skip to content
Snippets Groups Projects
Commit 94190ef2 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Allow wilcards in insn_deps

parent 3e77edce
No related branches found
No related tags found
No related merge requests found
......@@ -183,6 +183,9 @@ These are usually key-value pairs. The following attributes are recognized:
code generated for this instruction appears textually after both of these
instructions' generated code.
Identifiers here are allowed to be wildcards as defined by
:mod:`fnmatchcase`.
.. note::
If this is not specified, :mod:`loopy` will automatically add
......
......@@ -849,6 +849,35 @@ def apply_default_order_to_args(kernel, default_order):
# }}}
# {{{ resolve wildcard insn dependencies
def resolve_wildcard_deps(knl):
new_insns = []
from fnmatch import fnmatchcase
for insn in knl.instructions:
if insn.insn_deps is not None:
new_deps = set()
for dep in insn.insn_deps:
match_count = 0
for other_insn in knl.instructions:
if fnmatchcase(other_insn.id, dep):
new_deps.add(other_insn.id)
match_count += 1
if match_count == 0:
# Uh, best we can do
new_deps.append(dep)
insn = insn.copy(insn_deps=frozenset(new_deps))
new_insns.append(insn)
return knl.copy(instructions=new_insns)
# }}}
# {{{ kernel creation top-level
def make_kernel(device, domains, instructions, kernel_data=["..."], **kwargs):
......@@ -1001,6 +1030,7 @@ def make_kernel(device, domains, instructions, kernel_data=["..."], **kwargs):
knl = expand_defines_in_shapes(knl, defines)
knl = guess_arg_shape_if_requested(knl, default_order)
knl = apply_default_order_to_args(knl, default_order)
knl = resolve_wildcard_deps(knl)
# -------------------------------------------------------------------------
# Ordering dependency:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment