-
Notifications
You must be signed in to change notification settings - Fork 312
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
[SCFToCalyx] Issue with lowering scf::parallel
to Calyx when there is scf::if
in it
#8086
Comments
Can't we just simplify |
We could, I just thought that it should already exist in a canonicalization pass for the SCF dialect. I didn't want to introduce duplicated code into the codebase; but on the other hand, I felt like that we have to. So I wanted to bring this up. |
This looks like it is simplified after canonicalization: https://godbolt.org/z/j833qxMEh |
Indeed, the issue actually has to do with the way we are lowering
(source: https://mlir.llvm.org/docs/Dialects/SCFDialect/#scfparallel-scfparallelop) So as a result of running the canonicalization, all blocks except the first block within the region of |
I found a potential work out to avoid the pass to erase the blocks within the newly created |
No it doesn't work very well - the |
This seems to be a different issue than you originally stated in the first comment. Checking my understanding, at some point in SCFToCalyx, an If so, I'm surprised this doesn't throw an error instead of just blindly deleting blocks. Is it to possible to keep a single block when lowering |
Your understanding is totally correct. I'm also surprised by that.
Yes, I just had it locally and I plan to make a PR to wrap the blocks inside Apart from that, I just found out that I can run an op-specific canonicalization pass. That is, the |
We lower
scf::parallel
in SCFToCalyx by assuming constant loop bounds and strides, which enables us to unroll the parallel loop manually: #7830The issue is that, if
scf::parallel
containsscf::if
, whose condition variable depends on some constants andscf::parallel
's loop induction variables, those condition variables will be eventually evaluated to constanttrue/false
automatically even if we never implement this sort of "canonicalization" pass manually inSCFToCalyx.cpp
(I guess it's done by some underling MLIR mechanisms?).For example, if we begin with:
will turn into:
And in each basic block:
will be folded to constants automatically, turning the
scf::if
op to:If they were to be lowered to Calyx, it'll become:
but it's not allowed by Calyx' grammar: https://github.com/calyxir/calyx/blob/2e18d555ff00339f46c99cc9d8b698ee27ce25ad/calyx-frontend/src/syntax.pest#L348
Any idea on how to tackle this? @rachitnigam @cgyurgyik @andrewb1999 @mikeurbach Thanks!
The text was updated successfully, but these errors were encountered: