-
Notifications
You must be signed in to change notification settings - Fork 129
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
Complete Transition to Control Flow Regions #1676
Conversation
- StateFusionExtended - ArrayElimination - OptionalArrayInference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, clearly a lot of work went into this! I think we can do better with future-proofing the code to other control flow regions with some methods that could be implemented, and I have some other open questions in the comments.
Co-authored-by: Tal Ben-Nun <tbennun@users.noreply.github.com>
…to users/phschaad/adapt_passes
f1cb99f
to
3a2b342
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking much better now! Minor comments only. See unresolved comments for future PR tasks.
dace/frontend/python/interface.py
Outdated
@@ -69,8 +69,7 @@ def program(f: F, | |||
not depend on internal variables are constant. | |||
This will hardcode their return values into the | |||
resulting program. | |||
:param use_experimental_cfg_blocks: If True, makes use of experimental CFG blocks susch as loop and conditional | |||
regions. | |||
:param use_explicit_cfl: If True, makes use of explicit control flow constructs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:param use_explicit_cfl: If True, makes use of explicit control flow constructs. | |
:param use_explicit_cf: If True, makes use of explicit control flow constructs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
@@ -2578,6 +2583,17 @@ def sdfg(self) -> 'SDFG': | |||
@make_properties | |||
class AbstractControlFlowRegion(OrderedDiGraph[ControlFlowBlock, 'dace.sdfg.InterstateEdge'], ControlGraphView, | |||
ControlFlowBlock, abc.ABC): | |||
""" | |||
Abstract superclass to represent all kinds of control flow regions in an SDFG. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstrings should use double backticks (``) for inline code in Sphinx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
dace/sdfg/state.py
Outdated
@@ -2711,6 +2753,12 @@ def inline(self) -> Tuple[bool, Any]: | |||
|
|||
return False, None | |||
|
|||
def new_symbols(self, symbols: dict) -> Dict[str, dtypes.typeclass]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def new_symbols(self, symbols: dict) -> Dict[str, dtypes.typeclass]: | |
def new_symbols(self, symbols: Dict[str, dtypes.typeclass]) -> Dict[str, dtypes.typeclass]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
yield from node.sdfg.all_control_flow_regions(recursive=recursive, load_ext=load_ext, | ||
parent_first=parent_first) | ||
elif load_ext: | ||
node.load_external(block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remnant from another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must be due to a missed rebase, this is already in main: https://github.com/spcl/dace/blob/main/dace/sdfg/state.py#L2838
dace/sdfg/state.py
Outdated
@@ -3042,6 +3098,11 @@ def start_block(self, block_id): | |||
|
|||
@make_properties | |||
class ControlFlowRegion(AbstractControlFlowRegion): | |||
""" | |||
A `ControlFlowRegion` represents a control flow graph node that itself contains a control flow graph. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A `ControlFlowRegion` represents a control flow graph node that itself contains a control flow graph. | |
A ``ControlFlowRegion`` represents a control flow graph node that itself contains a control flow graph. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Congrats Phil, that's a push ;) I logged the |
This PR completes the transition to hierarchical control flow regions in DaCe. By nature of the significance in change that is brought through the transition to hierarchical control flow regions, this PR is rather substantial. An exhaustive listing of all adaptations is not feasible, but the most important changes and adaptations are listed below:
ControlFlowRegionPass
: This pass works likeStatePass
orScopePass
, and can be extended to write a pass that applies recursively to each control flow region of an SDFG. An option can be set to either apply bottom-up or top-down.Note: The FV3 integration test fails and will continue to fail with this PR, since GT4Py cartesian, which is used by PyFV3, does not consider experimental blocks in their design. Since DaCe v1.0.0 will be released without this PR in it, my suggestion is to limit the application of the FV3 integration and regression tests to PRs which are made to a specific v1.0.0 maintenance branch, which is used for fixes to v1.0.0.