Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hierarchical Control Flow / Control Flow Regions #1404

Merged
merged 23 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
73616ee
Adds just the framework for integral loops
phschaad Oct 18, 2023
a4139f6
Fix duplicate collapsed property on states
phschaad Oct 19, 2023
e0c8553
Fix inorrect parent class initialization
phschaad Oct 19, 2023
3d20f80
Add deprecation warning to is_start_state kwarg
phschaad Oct 19, 2023
909f032
Symbols and start block fixes
phschaad Oct 19, 2023
9099017
More symbol fixes
phschaad Oct 19, 2023
4cc0b86
label and state list fix
phschaad Oct 19, 2023
921f1ee
Remove loop scope for now
phschaad Oct 19, 2023
2f3568b
Merge branch 'master' into first_class_loops
phschaad Oct 20, 2023
a935fe5
Renaming
phschaad Oct 20, 2023
d84d0e3
Merge branch 'first_class_loops' of github.com:spcl/dace into first_c…
phschaad Oct 20, 2023
12a09c0
revert to traditional nodes-based iteration for now
phschaad Oct 20, 2023
be67317
Merge branch 'master' into first_class_loops
phschaad Oct 20, 2023
c165c85
Merge branch 'master' into first_class_loops
phschaad Oct 23, 2023
8792390
Update docs
phschaad Oct 23, 2023
471d1dd
Add test for deprecation
phschaad Oct 23, 2023
b3d3784
Merge branch 'master' into first_class_loops
phschaad Oct 27, 2023
1fd2f57
Merge branch 'master' into first_class_loops
phschaad Oct 30, 2023
c9ddcd8
Improve iteration function names
phschaad Oct 31, 2023
a971b5a
Remove obsolete property
phschaad Oct 31, 2023
8a32851
Improve type naming
phschaad Oct 31, 2023
6d4c95f
Remove obsolete scope_subgraph method
phschaad Oct 31, 2023
cc66744
Merge branch 'master' into first_class_loops
phschaad Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions dace/codegen/instrumentation/papi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dace.sdfg.graph import SubgraphView
from dace.memlet import Memlet
from dace.sdfg import scope_contains_scope
from dace.sdfg.state import StateGraphView
from dace.sdfg.state import DataflowGraphView

import sympy as sp
import os
Expand Down Expand Up @@ -392,7 +392,7 @@ def should_instrument_entry(map_entry: EntryNode) -> bool:
return cond

@staticmethod
def has_surrounding_perfcounters(node, dfg: StateGraphView):
def has_surrounding_perfcounters(node, dfg: DataflowGraphView):
""" Returns true if there is a possibility that this node is part of a
section that is profiled. """
parent = dfg.entry_node(node)
Expand Down Expand Up @@ -605,7 +605,7 @@ def get_memlet_byte_size(sdfg: dace.SDFG, memlet: Memlet):
return memlet.volume * memdata.dtype.bytes

@staticmethod
def get_out_memlet_costs(sdfg: dace.SDFG, state_id: int, node: nodes.Node, dfg: StateGraphView):
def get_out_memlet_costs(sdfg: dace.SDFG, state_id: int, node: nodes.Node, dfg: DataflowGraphView):
scope_dict = sdfg.node(state_id).scope_dict()

out_costs = 0
Expand Down Expand Up @@ -636,7 +636,10 @@ def get_out_memlet_costs(sdfg: dace.SDFG, state_id: int, node: nodes.Node, dfg:
return out_costs

@staticmethod
def get_tasklet_byte_accesses(tasklet: nodes.CodeNode, dfg: StateGraphView, sdfg: dace.SDFG, state_id: int) -> str:
def get_tasklet_byte_accesses(tasklet: nodes.CodeNode,
dfg: DataflowGraphView,
sdfg: dace.SDFG,
state_id: int) -> str:
""" Get the amount of bytes processed by `tasklet`. The formula is
sum(inedges * size) + sum(outedges * size) """
in_accum = []
Expand Down Expand Up @@ -693,7 +696,7 @@ def get_memory_input_size(node, sdfg, state_id) -> str:
return sym2cpp(input_size)

@staticmethod
def accumulate_byte_movement(outermost_node, node, dfg: StateGraphView, sdfg, state_id):
def accumulate_byte_movement(outermost_node, node, dfg: DataflowGraphView, sdfg, state_id):

itvars = dict() # initialize an empty dict

Expand Down
2 changes: 1 addition & 1 deletion dace/sdfg/analysis/schedule_tree/sdfg_to_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def remove_name_collisions(sdfg: SDFG):
# Rename duplicate states
for state in nsdfg.nodes():
if state.label in state_names_seen:
state.set_label(data.find_new_name(state.label, state_names_seen))
state.label = data.find_new_name(state.label, state_names_seen)
state_names_seen.add(state.label)

replacements: Dict[str, str] = {}
Expand Down
5 changes: 2 additions & 3 deletions dace/sdfg/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,8 @@ def label(self):
def __label__(self, sdfg, state):
return self.data

def desc(self, sdfg):
from dace.sdfg import SDFGState, ScopeSubgraphView
if isinstance(sdfg, (SDFGState, ScopeSubgraphView)):
def desc(self, sdfg: Union['dace.sdfg.SDFG', 'dace.sdfg.SDFGState', 'dace.sdfg.ScopeSubgraphView']):
if isinstance(sdfg, (dace.sdfg.SDFGState, dace.sdfg.ScopeSubgraphView)):
sdfg = sdfg.parent
return sdfg.arrays[self.data]

Expand Down
29 changes: 15 additions & 14 deletions dace/sdfg/replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,18 @@ def replace_datadesc_names(sdfg, repl: Dict[str, str]):
sdfg.constants_prop[repl[aname]] = sdfg.constants_prop[aname]
del sdfg.constants_prop[aname]

# Replace in interstate edges
for e in sdfg.edges():
e.data.replace_dict(repl, replace_keys=False)

for state in sdfg.nodes():
# Replace in access nodes
for node in state.data_nodes():
if node.data in repl:
node.data = repl[node.data]

# Replace in memlets
for edge in state.edges():
if edge.data.data in repl:
edge.data.data = repl[edge.data.data]
for cf in sdfg.all_state_scopes_recursive():
# Replace in interstate edges
for e in cf.edges():
phschaad marked this conversation as resolved.
Show resolved Hide resolved
e.data.replace_dict(repl, replace_keys=False)

for block in cf.nodes():
if isinstance(block, dace.SDFGState):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the block is not an SDFGState, don't we also need to call replace on the block itself?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed @phschaad is there a need to replace inside a block? Does it have its own properties? Right now it's only is_collapsed and label, but I imagine loops would have other symbols in them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general yes, it would need such a replacement as well. However, this is only replace_datadesc_names. There are currently no plans of having blocks (other than states) access data descriptors directly. They should all operate on symbols.

# Replace in access nodes
for node in block.data_nodes():
if node.data in repl:
node.data = repl[node.data]
# Replace in memlets
for edge in block.edges():
if edge.data.data in repl:
edge.data.data = repl[edge.data.data]