Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
0
def test_prune_k_cache_flushes():
    testee = StencilFactory(
        vertical_loops=[
            VerticalLoopFactory(
                loop_order=LoopOrder.FORWARD,
                sections__0__horizontal_executions__0__body=[
                    AssignStmtFactory(left__name="foo",
                                      right__name="foo",
                                      right__offset__k=1),
                    AssignStmtFactory(left__name="bar",
                                      right__name="baz",
                                      right__offset__k=1),
                    AssignStmtFactory(left__name="tmp1",
                                      right__name="tmp1",
                                      right__offset__k=1),
                    AssignStmtFactory(left__name="tmp2",
                                      right__name="tmp2",
                                      right__offset__k=1),
                ],
                caches=[
                    KCacheFactory(name="foo", flush=True),
                    KCacheFactory(name="bar", flush=True),
                    KCacheFactory(name="baz", flush=True),
                    KCacheFactory(name="tmp1", flush=True),
                    KCacheFactory(name="tmp2", flush=True),
                ],
            ),
            VerticalLoopFactory(
                loop_order=LoopOrder.FORWARD,
                sections__0__horizontal_executions__0__body=[
                    AssignStmtFactory(left__name="bar",
                                      right__name="bar",
                                      right__offset__k=1),
                    AssignStmtFactory(left__name="tmp1",
                                      right__name="tmp1",
                                      right__offset__k=1),
                ],
            ),
        ],
        declarations=[
            TemporaryFactory(name="tmp1"),
            TemporaryFactory(name="tmp2"),
        ],
    )
    transformed = PruneKCacheFlushes().visit(testee)
    cache_dict = {c.name: c for c in transformed.vertical_loops[0].caches}
    assert cache_dict["foo"].flush
    assert cache_dict["bar"].flush
    assert not cache_dict["baz"].flush
    assert cache_dict["tmp1"].flush
    assert not cache_dict["tmp2"].flush