-
Notifications
You must be signed in to change notification settings - Fork 298
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
[SCF-to-Calyx] Fix Ordering Bug #5526
Conversation
Great job tracking this down! One question I have is whether the BuildWhileGroups pattern is even necessary anymore. Could you just move all of that code into the BuildOpGroups function and remove the pattern entirely? If we need a BuildOpGroups function for WhileOps anyways I don't see a reason why BuildWhileGroups would be necessary anymore. |
hmm that's a good point. I can try to do that and see if there's any problems that I'm not thinking of. But it does seem like we might be able to get rid of BuildWhileGroups Edit: ok, so after trying this, it's erroring out. There seems to be some dependency issue with the |
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.
Is a similar change needed in LoopScheduleToCalyx? We have tried to share code between these passes, but at the moment, some functionality is duplicated.
Besides that, I left some nitpicky comments, and this looks good to me otherwise. @mortbopet do you have any other thoughts? This seems like a reasonable way to address this.
My only thought is that i'd like to see the whole scheduleable-implementation to be modified to be an association between That is, when we encounter e.g. an It could be cool to see the above, but if you just want to get something working, then i assume this can suffice 👍 (although if you're interested in developing a cool, scalable, reuseable way of doing this stuff, then... 👀). |
Yeah, I'm realizing now that you can create a similar bug in the
Yeah, I definitely see how what I've done is more of a "band-aid" than the more "complete" solution that you mention. Currently I have a decent amount on my plate as it is, so I'd lean towards my quick solution. Although I would be interested in doing something like this (and improving the Calyx CIRCT Dialect in general) in the future. |
Yeah I'm working on a pretty significant rewrite of LoopScheduleToCalyx and this is one of the issues I'm trying solve in a better way.
@mortbopet Could you expand a little bit on what you envision this looking like? I might be interested in implementing something like this as part of my LoopScheduleToCalyx rewrite (which could then end up being used as part of SCFToCalyx too). Overall, I think this bandaid fix is good to merge soon and then we can work towards a better solution later. |
My two cents is to merge this, at least for SCFToCalyx, and probably for LoopScheduleToCalyx as well, depending on how much it will complicate what Andrew has in the works. This change fixes a real bug, and I don't think merging this makes it much harder to re-implement these passes the way we really want them to work. |
That sounds good to me, a similar fix for LoopScheduleToCalyx shouldn't really affect my future changes much. |
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.
Bug fixes are good and sounds like we have more work around here already in the works... approved!
Pseudocode-y: That means that the order of blocks that need to be scheduled when converting said graph must follow the order if which operations appears in S. So whereas we right now have a single vector of "block scheduleables", that could instead be a mapping from operations to a struct that describes which blocks said operation wants to be scheduled, and in what ("intra-op") order.
During conversion of operations, operations will insert their scheduleables into the blockschedulingscope map instead of just pushing them back onto a list.
I then imagine that |
Merging this! @mortbopet can you give @calebmkim write access to the repo? He is one of the main Calyx developers these days |
As CIRCT is part of the LLVM github org, obtaining write access is the same as obtaining write access for LLVM: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access. Basically, you get added to the LLVM org, and then you can merge to CIRCT. |
Fixes #5521.
The main thing was adding the
WhileScheduleable
to theBlockScheduler
during theBuildGroupOps
pattern instead of theBuildWhileGroup
pattern, which means that all the block schedulables are added during the same pattern, preventing the order mismatching that was going on before. To do this, I needed to addinitGroups
(i.e., the groups that execute before the while loop that initialize the loop variables) to theLoopLoweringStateInterface
.I also added a test case in
convert_controlflow.mlir
.