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

Codegen fixes #1899

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dace/codegen/targets/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,7 @@ def _generate_NestedSDFG(
):
inline = Config.get_bool('compiler', 'inline_sdfgs')
self._dispatcher.defined_vars.enter_scope(sdfg, can_access_parent=inline)
self._dispatcher.declared_arrays.enter_scope(sdfg, can_access_parent=inline)
state_dfg = cfg.nodes()[state_id]

fsyms = self._frame.free_symbols(node.sdfg)
Expand Down
21 changes: 13 additions & 8 deletions dace/codegen/targets/framecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from dace.sdfg import scope as sdscope
from dace.sdfg import utils
from dace.sdfg.analysis import cfg as cfg_analysis
from dace.sdfg.state import ConditionalBlock, ControlFlowBlock, ControlFlowRegion, LoopRegion
from dace.sdfg.state import AbstractControlFlowRegion, ControlFlowBlock, ControlFlowRegion, LoopRegion
from dace.transformation.passes.analysis import StateReachability, loop_analysis


Expand Down Expand Up @@ -578,18 +578,23 @@ def determine_allocation_lifetime(self, top_sdfg: SDFG):
array_names = sdfg.arrays.keys(
) #set(k for k, v in sdfg.arrays.items() if v.lifetime == dtypes.AllocationLifetime.Scope)
# Iterate topologically to get state-order
for state in cfg_analysis.blockorder_topological_sort(sdfg, ignore_nonstate_blocks=True):
for node in state.data_nodes():
if node.data not in array_names:
continue
instances[node.data].append((state, node))
for block in cfg_analysis.blockorder_topological_sort(sdfg, ignore_nonstate_blocks=False):
if isinstance(block, SDFGState):
for node in block.data_nodes():
if node.data not in array_names:
continue
instances[node.data].append((block, node))
elif isinstance(block, AbstractControlFlowRegion):
block_fsyms = block.used_symbols(all_symbols=True, with_contents=False)
for block_array in block_fsyms & array_names:
instances[block_array].append((block, nodes.AccessNode(block_array)))

# Look in the surrounding edges for usage
edge_fsyms: Set[str] = set()
for e in state.parent_graph.all_edges(state):
for e in block.parent_graph.all_edges(block):
edge_fsyms |= e.data.free_symbols
for edge_array in edge_fsyms & array_names:
instances[edge_array].append((state, nodes.AccessNode(edge_array)))
instances[edge_array].append((block, nodes.AccessNode(edge_array)))
#############################################

access_instances[sdfg.cfg_id] = instances
Expand Down
Loading