Exemplo n.º 1
0
def test_write_before_read_temporaries_to_scalars():
    testee = StencilFactory(
        vertical_loops__0__sections__0__horizontal_executions=[
            HorizontalExecutionFactory(body=[
                AssignStmtFactory(left__name="tmp1"),
                AssignStmtFactory(left__name="tmp2", right__name="tmp1"),
                AssignStmtFactory(left__name="tmp3", right__name="tmp2"),
            ]),
            HorizontalExecutionFactory(body=[
                AssignStmtFactory(right__name="tmp2"),
                AssignStmtFactory(left__name="tmp3"),
                AssignStmtFactory(left__name="foo", right__name="tmp3"),
            ]),
        ],
        declarations=[
            TemporaryFactory(name="tmp1"),
            TemporaryFactory(name="tmp2"),
            TemporaryFactory(name="tmp3"),
        ],
    )
    transformed = WriteBeforeReadTemporariesToScalars().visit(testee)
    hexec0 = transformed.vertical_loops[0].sections[0].horizontal_executions[0]
    hexec1 = transformed.vertical_loops[0].sections[0].horizontal_executions[1]
    assert len(hexec0.declarations) == 2
    assert len(hexec1.declarations) == 1
    assert len(transformed.declarations) == 1
    assert isinstance(hexec0.body[0].left, oir.ScalarAccess)
    assert not isinstance(hexec0.body[1].left, oir.ScalarAccess)
    assert isinstance(hexec0.body[1].right, oir.ScalarAccess)
    assert isinstance(hexec0.body[2].left, oir.ScalarAccess)
    assert not isinstance(hexec0.body[2].right, oir.ScalarAccess)
    assert not isinstance(hexec1.body[0].right, oir.ScalarAccess)
    assert isinstance(hexec1.body[1].left, oir.ScalarAccess)
    assert isinstance(hexec1.body[2].right, oir.ScalarAccess)
Exemplo n.º 2
0
 def _optimize_oir(self, oir):
     oir = GreedyMerging().visit(oir)
     oir = AdjacentLoopMerging().visit(oir)
     oir = LocalTemporariesToScalars().visit(oir)
     oir = WriteBeforeReadTemporariesToScalars().visit(oir)
     oir = OnTheFlyMerging().visit(oir)
     oir = NoFieldAccessPruning().visit(oir)
     oir = IJCacheDetection().visit(oir)
     oir = KCacheDetection().visit(oir)
     oir = PruneKCacheFills().visit(oir)
     oir = PruneKCacheFlushes().visit(oir)
     return oir
Exemplo n.º 3
0
 def _optimize_oir(self, oir):
     oir = optimize_horizontal_executions(oir, GraphMerging)
     oir = AdjacentLoopMerging().visit(oir)
     oir = LocalTemporariesToScalars().visit(oir)
     oir = WriteBeforeReadTemporariesToScalars().visit(oir)
     oir = OnTheFlyMerging().visit(oir)
     oir = MaskStmtMerging().visit(oir)
     oir = NoFieldAccessPruning().visit(oir)
     oir = IJCacheDetection().visit(oir)
     oir = KCacheDetection().visit(oir)
     oir = PruneKCacheFills().visit(oir)
     oir = PruneKCacheFlushes().visit(oir)
     return oir