Skip to content
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

[FIRRTL] Improve Layer Merge Performance #7552

Merged
merged 2 commits into from
Aug 24, 2024

Conversation

seldridge
Copy link
Member

Fix a performance issue in the LayerMerge pass [1]. Apparently, repeated use of inlineBlockBefore can be a performance issue. Fix this, by using mergeBlocks which will append at the end of a block as opposed to prepend. This requires an additional move, however, this empirically doesn't matter.

For details of the algorithm, see the updated comments in the pass.

h/t @youngar for algorithmic suggestions.

@youngar
Copy link
Member

youngar commented Aug 24, 2024

To me it might be a bit more natural to do this as a backwards walk and shift everything downward into the first found block, slightly because you never violate the use before def when modifying the code

Copy link
Member

@youngar youngar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@seldridge
Copy link
Member Author

To me it might be a bit more natural to do this as a backwards walk and shift everything downward into the first found block, slightly because you never violate the use before def when modifying the code

I switched to this. Interestingly, this still uses inlineBlockBefore. However, it doesn't have performance issues in my local stress tests. I'm going to make sure that this fixes things on the internal design.

Algorithm is much cleaner now. Nice suggestion.

Fix a performance issue in the `LayerMerge` pass.  Apparently, repeated
use of `inlineBlockBefore` with a forward walk can be a performance issue.
Fix this, by reversing the iteration order.

h/t @youngar for algorithmic suggestions.

Fixes #7551.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Superficial cleanup of LayerMerge to make the variable names make more
sense.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@seldridge seldridge force-pushed the dev/seldridge/issue-7551-layer-merge branch from 55b3706 to 66122eb Compare August 24, 2024 04:34
@seldridge seldridge merged commit 66122eb into main Aug 24, 2024
2 checks passed
@seldridge seldridge deleted the dev/seldridge/issue-7551-layer-merge branch August 24, 2024 04:34
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.

4 participants