-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds support for a scheduling-oriented view of SDFGs. Upon conversion, the SDFG and its nested SDFGs keep the same array names and are organized in one tree, where each node corresponds to a schedulable concept (map scope, copy, tasklet, for-loop scope, etc.). The graph structure can be converted to sequential text with `as_string`. Useful for inspecting and analyzing schedules. --------- Co-authored-by: Alexandros Nikolaos Ziogas <[email protected]>
- Loading branch information
1 parent
f6263b5
commit a582261
Showing
27 changed files
with
2,354 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2019-2023 ETH Zurich and the DaCe authors. All rights reserved. | ||
""" | ||
Assortment of passes for schedule trees. | ||
""" | ||
|
||
from dace.sdfg.analysis.schedule_tree import treenodes as tn | ||
from typing import Set | ||
|
||
|
||
def remove_unused_and_duplicate_labels(stree: tn.ScheduleTreeScope): | ||
""" | ||
Removes unused and duplicate labels from the schedule tree. | ||
:param stree: The schedule tree to remove labels from. | ||
""" | ||
|
||
class FindGotos(tn.ScheduleNodeVisitor): | ||
|
||
def __init__(self): | ||
self.gotos: Set[str] = set() | ||
|
||
def visit_GotoNode(self, node: tn.GotoNode): | ||
if node.target is not None: | ||
self.gotos.add(node.target) | ||
|
||
class RemoveLabels(tn.ScheduleNodeTransformer): | ||
|
||
def __init__(self, labels_to_keep: Set[str]) -> None: | ||
self.labels_to_keep = labels_to_keep | ||
self.labels_seen = set() | ||
|
||
def visit_StateLabel(self, node: tn.StateLabel): | ||
if node.state.name not in self.labels_to_keep: | ||
return None | ||
if node.state.name in self.labels_seen: | ||
return None | ||
self.labels_seen.add(node.state.name) | ||
return node | ||
|
||
fg = FindGotos() | ||
fg.visit(stree) | ||
return RemoveLabels(fg.gotos).visit(stree) | ||
|
||
|
||
def remove_empty_scopes(stree: tn.ScheduleTreeScope): | ||
""" | ||
Removes empty scopes from the schedule tree. | ||
:warning: This pass is not safe to use for for-loops, as it will remove indices that may be used after the loop. | ||
""" | ||
|
||
class RemoveEmptyScopes(tn.ScheduleNodeTransformer): | ||
|
||
def visit_scope(self, node: tn.ScheduleTreeScope): | ||
if len(node.children) == 0: | ||
return None | ||
|
||
return self.generic_visit(node) | ||
|
||
return RemoveEmptyScopes().visit(stree) |
Oops, something went wrong.