Ejemplo n.º 1
0
 def ta_literal(self, fc, x, y):
     intervals = [Interval(x, 0, 0), Interval(y, 0, 0)]
     intervals_swap = [Interval(y, 0, 0), Interval(x, 0, 0)]
     fwd_ispace = IterationSpace(intervals,
                                 directions={
                                     x: Forward,
                                     y: Forward
                                 })
     fwd_ispace_swap = IterationSpace(intervals_swap,
                                      directions={
                                          x: Forward,
                                          y: Forward
                                      })
     mixed_ispace = IterationSpace(intervals,
                                   directions={
                                       x: Backward,
                                       y: Forward
                                   })
     tcxy_w0 = TimedAccess(fc[x, y], 'W', 0, fwd_ispace)
     tcxy_r0 = TimedAccess(fc[x, y], 'R', 0, fwd_ispace)
     tcx1y1_r1 = TimedAccess(fc[x + 1, y + 1], 'R', 1, fwd_ispace)
     tcx1y_r1 = TimedAccess(fc[x + 1, y], 'R', 1, fwd_ispace)
     rev_tcxy_w0 = TimedAccess(fc[x, y], 'W', 0, mixed_ispace)
     rev_tcx1y1_r1 = TimedAccess(fc[x + 1, y + 1], 'R', 1, mixed_ispace)
     tcyx_irr0 = TimedAccess(fc[y, x], 'R', 0, fwd_ispace)
     tcxx_irr1 = TimedAccess(fc[x, x], 'R', 0, fwd_ispace)
     tcxy_irr2 = TimedAccess(fc[x, y], 'R', 0, fwd_ispace_swap)
     return (tcxy_w0, tcxy_r0, tcx1y1_r1, tcx1y_r1, rev_tcxy_w0,
             rev_tcx1y1_r1, tcyx_irr0, tcxx_irr1, tcxy_irr2)
Ejemplo n.º 2
0
 def ta_literal(self, fc):
     intervals = [Interval(x, 0, 0), Interval(y, 0, 0)]
     fwd_ispace = IterationSpace(intervals, directions={x: Forward, y: Forward})
     mixed_ispace = IterationSpace(intervals, directions={x: Backward, y: Forward})
     tcxy_w0 = TimedAccess(fc[x, y], 'W', 0, fwd_ispace)
     tcxy_r0 = TimedAccess(fc[x, y], 'R', 0, fwd_ispace)
     tcx1y1_r1 = TimedAccess(fc[x + 1, y + 1], 'R', 1, fwd_ispace)
     tcx1y_r1 = TimedAccess(fc[x + 1, y], 'R', 1, fwd_ispace)
     rev_tcxy_w0 = TimedAccess(fc[x, y], 'W', 0, mixed_ispace)
     rev_tcx1y1_r1 = TimedAccess(fc[x + 1, y + 1], 'R', 1, mixed_ispace)
     return tcxy_w0, tcxy_r0, tcx1y1_r1, tcx1y_r1, rev_tcxy_w0, rev_tcx1y1_r1
Ejemplo n.º 3
0
    def __new__(cls, indexed, mode, timestamp, ispace=None):
        assert mode in cls._modes
        assert is_integer(timestamp)

        obj = super(TimedAccess, cls).__new__(cls, indexed)

        obj.indexed = indexed
        obj.function = indexed.function
        obj.mode = mode
        obj.timestamp = timestamp

        obj.ispace = ispace or IterationSpace([])

        return obj
Ejemplo n.º 4
0
    def __new__(cls, access, mode, timestamp, ispace=None):
        assert mode in cls._modes
        assert is_integer(timestamp)

        obj = super().__new__(cls, access)

        obj.access = access
        obj.function = access.function
        obj.mode = mode
        obj.timestamp = timestamp

        obj.ispace = ispace or IterationSpace([])

        return obj
Ejemplo n.º 5
0
def st_schedule(clusters):
    """
    Arrange an iterable of :class:`Cluster`s into a :class:`ScheduleTree`.
    """
    stree = ScheduleTree()

    mapper = OrderedDict()
    for c in clusters:
        pointers = list(mapper)

        # Find out if any of the existing nodes can be reused
        index = 0
        root = stree
        for it0, it1 in zip(c.itintervals, pointers):
            if it0 != it1 or it0.dim in c.atomics:
                break
            root = mapper[it0]
            index += 1
            if it0.dim in c.guards:
                break

        # The reused sub-trees might acquire some new sub-iterators
        for i in pointers[:index]:
            mapper[i].ispace = IterationSpace.merge(mapper[i].ispace, c.ispace)
        # Later sub-trees, instead, will not be used anymore
        for i in pointers[index:]:
            mapper.pop(i)

        # Add in Iterations
        for i in c.itintervals[index:]:
            root = NodeIteration(c.ispace.project([i.dim]), root)
            mapper[i] = root

        # Add in Expressions
        NodeExprs(c.exprs, c.shape, c.ops, c.traffic, root)

        # Add in Conditionals
        for k, v in mapper.items():
            if k.dim in c.guards:
                node = NodeConditional(c.guards[k.dim])
                v.last.parent = node
                node.parent = v

    return stree