loopy/schedule/__init__.py
def find_loop_insn_dep_map(kernel, loop_nest_with_map, loop_nest_around_map):
    """Returns a dictionary mapping inames to other instruction ids that need to
    be scheduled before the iname should be eligible for scheduling.
    """

    result = {}

    from loopy.kernel.data import ParallelTag, IlpBaseTag, VectorizeTag
    for insn in kernel.instructions:
        for iname in kernel.insn_inames(insn):
            if isinstance(kernel.iname_to_tag.get(iname), ParallelTag):
                continue

            iname_dep = result.setdefault(iname, set())

            for dep_insn_id in insn.depends_on:
                if dep_insn_id in iname_dep:
                    # already depending, nothing to check
                    continue

                dep_insn = kernel.id_to_insn[dep_insn_id]
                dep_insn_inames = kernel.insn_inames(dep_insn)

                if iname in dep_insn_inames:
                    # Nothing to be learned, dependency is in loop over iname
                    # already.
                    continue

                # To make sure dep_insn belongs outside of iname, we must prove
                # that all inames that dep_insn will be executed in nest
                # outside of the loop over *iname*. (i.e. nested around, or
                # before).

                may_add_to_loop_dep_map = True
                for dep_insn_iname in dep_insn_inames:
                    if dep_insn_iname in loop_nest_around_map[iname]:
                        # dep_insn_iname is guaranteed to nest outside of iname
                        # -> safe.
                        continue

                    tag = kernel.iname_to_tag.get(dep_insn_iname)
                    if isinstance(tag, (ParallelTag, IlpBaseTag, VectorizeTag)):
                        # Parallel tags don't really nest, so we'll disregard
                        # them here.
                        continue

                    if dep_insn_iname not in loop_nest_with_map.get(iname, []):
                        # dep_insn_iname does not nest with iname, so its nest
                        # must occur outside.
                        continue

                    may_add_to_loop_dep_map = False
                    break

                if not may_add_to_loop_dep_map:
                    continue

                logger.debug("{knl}: loop dependency map: iname '{iname}' "
                        "depends on '{dep_insn}' via '{insn}'"
                        .format(
                            knl=kernel.name,
                            iname=iname,
                            dep_insn=dep_insn_id,
                            insn=insn.id))

                iname_dep.add(dep_insn_id)

    return result
Returns a dictionary mapping inames to other instruction ids that need to
    be scheduled before the iname should be eligible for scheduling.
    
Returns a dictionary mapping inames to other instruction ids that need to
be scheduled before the iname should be eligible for scheduling.
Returns a dictionary mapping inames to other instruction ids that need to be scheduled before the iname should be eligible for scheduling .
def find_loop_insn_dep_map(kernel, loop_nest_with_map, loop_nest_around_map):
    result = {}
    from loopy.kernel.data import ParallelTag, IlpBaseTag, VectorizeTag
    for insn in kernel.instructions:
        for iname in kernel.insn_inames(insn):
            if isinstance(kernel.iname_to_tag.get(iname), ParallelTag):
                continue
            iname_dep = result.setdefault(iname, set())
            for dep_insn_id in insn.depends_on:
                if dep_insn_id in iname_dep:
                    continue
                dep_insn = kernel.id_to_insn[dep_insn_id]
                dep_insn_inames = kernel.insn_inames(dep_insn)
                if iname in dep_insn_inames:
                    continue
                may_add_to_loop_dep_map = True
                for dep_insn_iname in dep_insn_inames:
                    if dep_insn_iname in loop_nest_around_map[iname]:
                        continue
                    tag = kernel.iname_to_tag.get(dep_insn_iname)
                    if isinstance(tag, (ParallelTag, IlpBaseTag, VectorizeTag)):
                        continue
                    if dep_insn_iname not in loop_nest_with_map.get(iname, []):
                        continue
                    may_add_to_loop_dep_map = False
                    break
                if not may_add_to_loop_dep_map:
                    continue
                logger.debug("{knl}: loop dependency map: iname '{iname}' "
                        "depends on '{dep_insn}' via '{insn}'"
                        .format(
                            knl=kernel.name,
                            iname=iname,
                            dep_insn=dep_insn_id,
                            insn=insn.id))
                iname_dep.add(dep_insn_id)
    return result
def find_loop_insn_dep_map ( kernel , loop_nest_with_map , loop_nest_around_map ) : result = { } from loopy . kernel . data import ParallelTag , IlpBaseTag , VectorizeTag for insn in kernel . instructions : for iname in kernel . insn_inames ( insn ) : if isinstance ( kernel . iname_to_tag . get ( iname ) , ParallelTag ) : continue iname_dep = result . setdefault ( iname , set ( ) ) for dep_insn_id in insn . depends_on : if dep_insn_id in iname_dep : continue dep_insn = kernel . id_to_insn [ dep_insn_id ] dep_insn_inames = kernel . insn_inames ( dep_insn ) if iname in dep_insn_inames : continue may_add_to_loop_dep_map = True for dep_insn_iname in dep_insn_inames : if dep_insn_iname in loop_nest_around_map [ iname ] : continue tag = kernel . iname_to_tag . get ( dep_insn_iname ) if isinstance ( tag , ( ParallelTag , IlpBaseTag , VectorizeTag ) ) : continue if dep_insn_iname not in loop_nest_with_map . get ( iname , [ ] ) : continue may_add_to_loop_dep_map = False break if not may_add_to_loop_dep_map : continue logger . debug ( "{knl}: loop dependency map: iname '{iname}' " "depends on '{dep_insn}' via '{insn}'" . format ( knl = kernel . name , iname = iname , dep_insn = dep_insn_id , insn = insn . id ) ) iname_dep . add ( dep_insn_id ) return result
Returns a dictionary mapping inames to other instruction ids that need to
be scheduled before the iname should be eligible for scheduling.
Returns a dictionary mapping inames to other instruction ids that need to be scheduled before the iname should be eligible for scheduling .
"""Returns a dictionary mapping inames to other instruction ids that need to
    be scheduled before the iname should be eligible for scheduling.
    """ # already depending, nothing to check # Nothing to be learned, dependency is in loop over iname # already. # To make sure dep_insn belongs outside of iname, we must prove # that all inames that dep_insn will be executed in nest # outside of the loop over *iname*. (i.e. nested around, or # before). # dep_insn_iname is guaranteed to nest outside of iname # -> safe. # Parallel tags don't really nest, so we'll disregard # them here. # dep_insn_iname does not nest with iname, so its nest # must occur outside.
kernel
loop_nest_with_map
loop_nest_around_map