-
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
Add state replication and if raising transformations #1639
base: main
Are you sure you want to change the base?
Conversation
return False | ||
|
||
# make sure this is not a loop guard | ||
if len(out_edges) == 2: |
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.
Application on loops results in the addition of useless states (but the SDFG is still correct). This will not get rid of the loop, meaning that apply_transformations_repeated
will never halt.
if if_guard.is_empty(): | ||
return False | ||
|
||
# check that condition does not depend on computations in the state |
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.
might be missing something I do not know about here. Also I don't know if this can result in spurious failures
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, however, this is missing a couple of "negative" tests. Please add tests where the expected behavior is that the transformation is not applied.
Apart from @acalotoiu 's comment, this looks good to me. However, I want to add: I believe that the presence of more and more niche transformations like this should make us prioritize the idea of a 'community transformation repository' a bit more. |
I really see this as a member of a potential set of "transformation building blocks", towards having composable transformations. This also lies in between a utility method (e.g. in the SDFG class) and an actual transformation |
sdfg.apply_transformations_repeated([OTFMapFusion]) | ||
|
||
assert len(sdfg.nodes()) == 4 | ||
assert sdfg.start_state.is_empty() |
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.
the tests fails here but it works on my machine. Is there something specific to the setup in the pipeline?
355af5b
to
109eeba
Compare
109eeba
to
ad097eb
Compare
Added one "negative test" (besides the existing one) where the expected behaviour is that the transformation is not applied. Gave each of the two transformations its own test file. PTAL. |
Thank you for addressing the comments @pratyai! In general, this looks good to me. However, I would prefer if this PR could be part of a brief discussion in the DaCe weekly this week before it is merged. For that reason I am not pressing 'accept' yet. I would prefer to discuss it due to two key points:
|
This PR adds the StateReplication and IfRaising transformations.
StateReplication performs a normalization step. It takes a state with
n
incoming edges and creates an equivalent SDFG withn
replicas of the original state, each with a single incoming edge.IfRaising takes an if guard and 'raises' the evaluation of the conditional. The condition needs to be independent of the computations done in the if guard. The if guard is replicated in each branch and the conditional is evaluated earlier in a new empty state.
The combination of these two transformations unlocks extra dataflow in the case of "diamond" patterns that can be found in some weather codes. In particular, it targets the case where some flag changes what computation is performed.
Example before:
After:
After State, Map, and Tasklet fusion: