-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new transient to ProgramVisitor.variables. * Added support for (some) Python tasklets. * Added capability to select the iteration variable for the transformation. * `extract_map_dims` should now not fail when the input map has only 1 dimension. * Added StartStateElimination transformation. * InlineSDFG fissions the state if necessary. * Input connectors are not pruned when they appear in symbol mappings. * Try to find an entry node in the parent SDFG if not found in the current SDFG. * Improved search for outer scope. * Added TrivialTaskletEliminiation transformation. * Updated WarpTiling. * Updated map range * Enabled setzero for local transient. * Added init state for thread-local variable. * Don't apply on streams. * Added tutorial * Small refactor for error reporting. * yapf * Made condition more robust to nested SDFGs with more than one WCCs, * Updated tutorial. * Fixed identation error. * Fixed missing code.
- Loading branch information
1 parent
8f3a6c2
commit 7a35b4a
Showing
13 changed files
with
794 additions
and
36 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
74 changes: 74 additions & 0 deletions
74
dace/transformation/dataflow/trivial_tasklet_elimination.py
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,74 @@ | ||
# Copyright 2019-2021 ETH Zurich and the DaCe authors. All rights reserved. | ||
""" Contains classes that implement the trivial-tasklet-elimination transformation. """ | ||
|
||
from dace import data, registry | ||
from dace.sdfg import nodes | ||
from dace.sdfg import utils as sdutil | ||
from dace.transformation import transformation | ||
from dace.properties import make_properties | ||
|
||
|
||
@registry.autoregister_params(singlestate=True) | ||
@make_properties | ||
class TrivialTaskletElimination(transformation.Transformation): | ||
""" Implements the Trivial-Tasklet Elimination pattern. | ||
Trivial-Tasklet Elimination removes tasklets that just copy the input | ||
to the output without WCR. | ||
""" | ||
|
||
read = transformation.PatternNode(nodes.AccessNode) | ||
tasklet = transformation.PatternNode(nodes.Tasklet) | ||
write = transformation.PatternNode(nodes.AccessNode) | ||
|
||
@staticmethod | ||
def expressions(): | ||
return [sdutil.node_path_graph(TrivialTaskletElimination.read, | ||
TrivialTaskletElimination.tasklet, | ||
TrivialTaskletElimination.write)] | ||
|
||
@staticmethod | ||
def can_be_applied(graph, candidate, expr_index, sdfg, strict=False): | ||
read = graph.nodes()[candidate[TrivialTaskletElimination.read]] | ||
tasklet = graph.nodes()[candidate[TrivialTaskletElimination.tasklet]] | ||
write = graph.nodes()[candidate[TrivialTaskletElimination.write]] | ||
# Do not apply on Streams | ||
if isinstance(sdfg.arrays[read.data], data.Stream): | ||
return False | ||
if isinstance(sdfg.arrays[write.data], data.Stream): | ||
return False | ||
if len(graph.in_edges(tasklet)) != 1: | ||
return False | ||
if len(graph.out_edges(tasklet)) != 1: | ||
return False | ||
if graph.edges_between(tasklet, write)[0].data.wcr: | ||
return False | ||
if len(tasklet.in_connectors) != 1: | ||
return False | ||
if len(tasklet.out_connectors) != 1: | ||
return False | ||
in_conn = list(tasklet.in_connectors.keys())[0] | ||
out_conn = list(tasklet.out_connectors.keys())[0] | ||
if tasklet.code.as_string != f'{out_conn} = {in_conn}': | ||
return False | ||
|
||
return True | ||
|
||
@staticmethod | ||
def match_to_str(graph, candidate): | ||
tasklet = graph.nodes()[candidate[TrivialTaskletElimination.tasklet]] | ||
return tasklet.label | ||
|
||
def apply(self, sdfg): | ||
graph = sdfg.nodes()[self.state_id] | ||
read = graph.nodes()[self.subgraph[TrivialTaskletElimination.read]] | ||
tasklet = graph.nodes()[self.subgraph[TrivialTaskletElimination.tasklet]] | ||
write = graph.nodes()[self.subgraph[TrivialTaskletElimination.write]] | ||
|
||
in_edge = graph.edges_between(read, tasklet)[0] | ||
out_edge = graph.edges_between(tasklet, write)[0] | ||
graph.remove_edge(in_edge) | ||
graph.remove_edge(out_edge) | ||
out_edge.data.other_subset = in_edge.data.subset | ||
graph.add_nedge(read, write, out_edge.data) | ||
graph.remove_node(tasklet) |
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
Oops, something went wrong.