8000 [FIRRTL][InferWidths] Make solveExpr Iterative by prithayan · Pull Request #5305 · llvm/circt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[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

Merged
merged 3 commits into from
Jun 2, 2023

Conversation

prithayan
Copy link
Contributor

The solveExpr implementation of InferWidths 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

@prithayan prithayan force-pushed the dev/seldridge/avoid-recursion-in-inferwidths branch from 744d8b0 to d402260 Compare June 1, 2023 20:54

// indent only used for debug logs.
unsigned indent = 1;
std::vector<Frame> worklist({{expr, indent}});
Copy link
Member

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?

Copy link
Contributor Author

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.

8000
Copy link
Member

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.

@prithayan prithayan force-pushed the dev/seldridge/avoid-recursion-in-inferwidths branch from 67390b9 to 035acfe Compare June 2, 2023 21:29
@prithayan
Copy link
Contributor Author

The pre-merge-ci tests were clean, going to merge this, for the next circt release.

@prithayan prithayan merged commit 5afd784 into main Jun 2, 2023
@prithayan prithayan deleted the dev/seldridge/avoid-recursion-in-inferwidths branch April 11, 2024 16:08
youngar added a commit to youngar/circt that referenced this pull request Oct 9, 2024
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.
youngar added a commit to youngar/circt that referenced this pull request Oct 9, 2024
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.
youngar added a commit that referenced this pull request Oct 12, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0