-
Notifications
You must be signed in to change notification settings - Fork 347
[FIRRTL][InferWidths] Make solveExpr Iterative #5305
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
Conversation
744d8b0
to
d402260
Compare
|
||
// indent only used for debug logs. | ||
unsigned indent = 1; | ||
std::vector<Frame> worklist({{expr, indent}}); |
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.
nit: Is there a specific reason to use std::vector over SmallVector?
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.
I don't think so, the worklist can grow pretty large, we can switch to smallvector, how does the logic for reserve
look to you ? I reserved the number of exprs/2 size for this.
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.
I don't have good intuition for the constraint but exprs/2 sounds reasonable.
This is not working. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
67390b9
to
035acfe
Compare
The pre-merge-ci tests were clean, going to merge this, for the next circt release. |
We would allocate a new workstack each time we solve a var, and reserve a size of 1/2 of the total number of expressions. The number of expressions in a ciruit is absolutely massive, making this not a good default. Instead, we just allocate the workstack from outside of the method and reuse the memory allocation for each solve. As an aside, this fixes the indentation for debug printing which was broken in llvm#5305.
We would allocate a new workstack each time we solve a var, and reserve a size of 1/2 of the total number of expressions. The number of expressions in a ciruit is absolutely massive, making this not a good default. Instead, we just allocate the workstack from outside of the method and reuse the memory allocation for each solve. As an aside, this fixes the indentation for debug printing which was broken in llvm#5305.
We would allocate a new workstack each time we solve a var, and reserve a size of 1/2 of the total number of expressions. The number of expressions in a ciruit is absolutely massive, making this not a good default. Instead, we just allocate the workstack from outside of the method and reuse the memory allocation for each solve. As an aside, this fixes the indentation for debug printing which was broken in #5305.
The
solveExpr
implementation ofInferWidths
was recursive and causing stack overflow issues on some designs.This PR implements an iterative version of the algorithm.
Co-authored-by: Schuyler Eldridge schuyler.eldridge@sifive.com