-
Notifications
You must be signed in to change notification settings - Fork 53
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
Condensing seq blocks #1029
Comments
Very interesting! I like the idea of going for the more general (This would be the opposite of the existing Focusing on this basic version first will let us figure out the dependency issues in a simpler setting—and provide a foundation to build on to deal with fancier |
Just a passing thought: there seems to be some general philosophy here about transforming programs to localize groups to parallel thread that affect subsequent groups. In some ways, all programs can be thought of a bunch to parallel threads running only some of which affect each other. I suspect once we have synchronized parallelism, we can transform all programs to remove nested parallel and synchronize only when needed. |
@calebmkim was this implemented in the last PR you opened? |
No, the most recent PR changes LiveRangeAnalysis and MinimizeRegs so that the MinimizeRegs pass does what the previous MinimizeRegs and ResourceSharing passes both did. |
I meant the one before it |
Oh, sorry. But in that case again answer is no. The pass only dealt with transforming par blocks. |
@calebmkim @paili0628 do you think this would a good pass to show off with the new |
Yeah, I think this could be helpful. |
Got it! It seems to fall into the bucket of various passes that discover parallelism from your program so maybe it should be wrapped in the broader umbrella of a complex |
Subsumed by #1722 |
Discussed this in meeting w/ @rachitnigam today. Was told to tag @sampsyo as well.
The basic idea for this pass is that, for each child C of a Seq, we try to find a safe place in a Par block to insert C that will save time. This will mean looking for a place where you know at least one child of a Par block is "waiting" for another child to finish executing, and inserting C to create a Seq with the "waiting" child. Of course we have to be careful of the dependencies of each child when doing this.
For example:
Suppose that we know that C1 takes 10 cycles, and C2, C3, and C4 all take 2 cycles.
Suppose we have:
Currently, we know C2 will be "waiting" for 8 cycles, since it take 2 cycles versus C1's taking 10 cycles.
If we know that C3 and C4 depend on C2 but not C1, then we can transform this into:
Or, if we know that C4 depends only on C2, C3 depends only on C1, and that C4 does not depend on C3, then we can turn this into:
So, if we want to move a child of a Seq block "back" into a previous Par block, then we have to check which of the previous statements it depends on.
Alternatively, if we have:
And we know C3 only depends on C2, and both C4 and C3 depend on C1, we could transform this into:
In this scenario, we are moving C2 "forward" into a future Par block, so we have to check which of the future statements depend on it.
Thinking about it, even if we had something like
If we knew C1 and C2 did not depend on each other then we could get:
Although I'm not sure if this transformation is already implemented elsewhere.
The advantage of this pass would be to save time. In this example, the number of cycles would go from 14 to 10.
The text was updated successfully, but these errors were encountered: