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

Improve opt_expr performance #4176

Merged
merged 4 commits into from
Jul 15, 2024
Merged

Conversation

povik
Copy link
Member

@povik povik commented Feb 1, 2024

See the commits. This avoids having to populate dict<RTLIL::Cell*, std::set<RTLIL::SigBit>> cell_to_inbit;, and it saves repeated conversions of type IDs to strings (36 times per cell for one iteration of the loop in opt_expr). Allocating a string for the IDs was significant enough to stand out when watching where opt_expr spends its time.

@povik povik added the status-paused Status: Unfinished, not actively worked on, PR author intends to continue PR in the future label Apr 13, 2024
@widlarizer widlarizer force-pushed the opt_expr-performance branch from 1bdb80d to 06c4b21 Compare June 24, 2024 16:04
povik added 2 commits June 24, 2024 18:32
Avoid building a cell-to-inbit map when sorting the cells, add a warning
if we are unable to sort, and move the code treating non-combinational
cells ahead of the rest (this means we don't need to pass
non-combinational cells to the TopoSort object at all).
Each call to `handle_clkpol_celltype_swap` has a conversion of the
cell's type ID to an allocated string. This can sum up to a
non-negligible time being spent in the clkpol code even for a design
which doesn't have any flip-flop gates.
@widlarizer widlarizer force-pushed the opt_expr-performance branch from 06c4b21 to fa4a2b6 Compare June 24, 2024 16:32
@widlarizer
Copy link
Collaborator

With -noopt hacked into proc as called by techmap in the first part of the failing test, before opt_expr would be called check can be called instead and it does reveal a logic loop

@widlarizer
Copy link
Collaborator

Since

and

and Pd is constructed from expressions that combinationally depend on Z, a comb loop is apparently generated. However, it is unreachable, since one of the two statements I linked depends on different values of the parameter PREG. The inactive statements only get resolved by opt, which is what the failing test actually tests for

@widlarizer
Copy link
Collaborator

I think if you're okay with it we should just supress the warning with -expect. See commit de79978 for how we got to the current version of techlibs/xilinx/cells_sim.v

@povik
Copy link
Member Author

povik commented Jun 25, 2024

Ah so it was the new warning which was tripping up the tests. I am fine with suppressing it to pass the test, but I think we should discuss whether we want the warning in the first place.

In the meantime we have changed check to allow coarse loops, and those would trigger the warning too. So we need to account for that in the wording.

@widlarizer widlarizer self-assigned this Jul 8, 2024
@widlarizer widlarizer added merge-after-jf Merge: PR will be merged after the next Dev JF unless concerns are raised and removed status-paused Status: Unfinished, not actively worked on, PR author intends to continue PR in the future labels Jul 8, 2024
@widlarizer widlarizer force-pushed the opt_expr-performance branch from c4b65d4 to 532188f Compare July 15, 2024 09:15
@widlarizer widlarizer merged commit 1166238 into YosysHQ:main Jul 15, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-after-jf Merge: PR will be merged after the next Dev JF unless concerns are raised
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants