-
Notifications
You must be signed in to change notification settings - Fork 299
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] Mark cf
operations illegal
#5031
Comments
Hey @asraa, thanks for opening an issue! Could generate the Calyx program for this and export it as a file or a gist in the calyx native syntax? information on that: https://docs.calyxir.org/fud/circt.html#mlir-to-native-representation My guess is that scf to calyx is lowering it naively and allocating a lot of resources for the design. Also, are you using the native compiler to generate Verilog or CIRCT passes? The Circt flow for calyx does not have many optimizations. |
I think the issue here is the CIRCT scf to calyx pass doesn't complete or takes until the heat death of the universe--the resources being exhausted are on the host running the CIRCT compiler 😬 . |
Ahh, I thought the problem was the FPGA resource limit was reached when compiling the design from Verilog.
I guess it would be interesting to figure out what part of the compilation pipeline is keeling over. |
What happens if you run the model with the SCF operations still intact (by not running |
I took a very quick look. A couple observations: The suggestion from @matth2k is a good idea, and would probably work here since the control flow seems fairly straightforward (see below). This recursion in handling circt/lib/Conversion/SCFToCalyx/SCFToCalyx.cpp Lines 1058 to 1068 in 4a2ae91
We should fix the above regardless. I also noticed if you run the |
Neat! Actually this is what the operations were originally, before I rewrote them to use |
EDIT: Actually ignore me, I see that it's pretty obviously needed to iterate through the common return statements. @mikeurbach is the reason it's causing exponential behavior because both the true branch and false branch are iterating through their successor blocks, which they may have many in common of (e.g. the statements after return)? If so, how come tracking path doesn't detect this behavior? I'd expect if a successor was added to the path during the if branch, it would end up failing on this line during the else branch (although it doesn't seem to) circt/lib/Conversion/SCFToCalyx/SCFToCalyx.cpp Line 1021 in 4a2ae91
It does seem to process the common successors, although their paths aren't shared. |
I will try to take a deeper look and figure out what's going on, and if there's a better way to rewrite it. @mortbopet do you have any recollection on this? I see some comments about naively elaborating the CFG, which mention a simplification pass that doesn't seem to exist. Any previous thoughts you might be able to page back in on how to implement this more efficiently? If not, I might have some time to re-implement this. @asraa I think adding |
Thanks for the pointer to handshake! We are interested in exporting verilog so we can use this for an existing optimizer we have. I was able to lower it to handshake by removing the TF attributes like you say, and then lower to HW, but ended up with a crash when exporting to verilog. The crash here is a little opaque to me... https://gist.github.com/asraa/a9fb964e51c835f2c2904d3a007b29ff In the meantime I think I'm confident enough-ish to add some support for |
There are quite a few passes to go through the Handshake flow successfully, and they are all wrapped up in the
That would be great! If you take a stab at it, let us know if you have any questions. |
Not much - but it does seem like the possible culprit (some profiling here would probably clear the fog a bit). If i'd rewrite this now, i'd probably do it in the style that CalyxToFSM does it - i.e. a very functional style. Wherein instead of the "pre" block always being passed around, we pass the (possibly predeclared/stand-in) "next" block around, and specialize lowering on branching, such that each branch is handled independently, and then control is transferred to the lowering of the "next" block afterward:
|
Yeah I did a quick profile and there were stacks with hundreds of alternating buildCFGControl and schedulePath in this test case. Thanks for the pointer, that makes sense. |
Hey! I'm just back from an extended vacation and have been looking at this again. On one hand I've built
I think some of the docs are outdated here, but I've tried (with a handshake model as well):
Both create the hls checkpoint file, but do not print out any useful error:
Any pointers? It seems like Regarding |
Hmm looking at your output, it seems like you're using With that tool, the example I showed before of just |
cf.cond_br
Renamed the issue to more appropriately point to the problem. Hopefully that's okay! |
Thank you everyone!
Yes!! It was successful, thank you so much for the help - this brought us closer to a proof of concept that we're working on :) |
@mikeurbach would it make sense to mark Does this seem reasonable or am I missing something? |
@rachitnigam that makes sense to me If structured control flow is the only sensible thing, then let's enforce that. Given that https://reviews.llvm.org/D156889 has now merged upstream (thank you @Dinistro for making me aware), there's no excuse to not have this restriction. |
Awesome! I've renamed the issue to reflect this. We can add |
cf.cond_br
cf
operations illegal
Hi! I just posted on the #circt channel on discord about a model I had that I tried to pass to CIRCT to lower to Calyx via
-lower-scf-to-calyx
. It seems like it takes a few hours at least, and sometime just crashes my machine - which is very strange, since the model is pretty simple with mostly arithmetic operations and 163 if statements that are represented with conditional branches (they werescf.if
statements, but converted tocf
with convert-scf-to-cf.This is the model: https://gist.github.com/asraa/93f10e86abcc3fe386eec172cb918e5c
I'll be poking around the conversion code near the conditional branch handling, just in case, and if I see something suspicious I'll update this thread.
circt/lib/Conversion/SCFToCalyx/SCFToCalyx.cpp
Line 1016 in 4a2ae91
Thank you!
@mikeurbach for CC, thank you for responding in the chat!
The text was updated successfully, but these errors were encountered: