예제 #1
0
    def test_assignment_from_literal(self):
        loop, write = make_horizontal_loop_with_init("write")

        result = generate_dependency_graph([loop])

        assert len(result.nodes()) == 1
        assert len(result.edges()) == 0
예제 #2
0
    def test_single_assignment(self):
        loop, write, read = make_horizontal_loop_with_copy(
            "write0", "input", False)

        result = generate_dependency_graph([loop])

        assert len(result.nodes()) == 1
        assert len(result.edges()) == 0
예제 #3
0
    def test_dependent_assignment_with_extent(self):
        loop0, write0 = make_horizontal_loop_with_init("write0")
        loop1, write1, read1 = make_horizontal_loop_with_copy(
            "write1", "write0", True)
        loops = [loop0, loop1]

        result = generate_dependency_graph(loops)

        assert len(result.nodes()) == 2
        assert result.has_edge(write0.id_attr_, write1.id_attr_)
        assert result[write0.id_attr_][write1.id_attr_]["extent"] is True
예제 #4
0
 def visit_HorizontalLoop(self, node: nir.HorizontalLoop, **kwargs):
     if len(self.candidate) == 0:
         self.candidate.append(node)
         return
     elif (self.candidate[-1].location_type == node.location_type
           ):  # same location type as previous
         dependencies = generate_dependency_graph(self.candidate + [node])
         if not self.has_read_with_offset_after_write(dependencies):
             self.candidate.append(node)
             return
     # cannot merge to previous loop:
     if len(self.candidate) > 1:
         self.candidates.append(self.candidate)  # add a new merge set
     self.candidate = [node]