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

Yosys Synthesis Error: Hash Table Exceeded Maximum Size #4458

Closed
PerryLogic opened this issue Jun 17, 2024 · 8 comments
Closed

Yosys Synthesis Error: Hash Table Exceeded Maximum Size #4458

PerryLogic opened this issue Jun 17, 2024 · 8 comments
Labels
needs-info Issue needs more context/information in order to be resolved

Comments

@PerryLogic
Copy link

Version

yosys 0.41+126

On which OS did this happen?

Linux

Reproduction Steps

Hello,
I encountered another issue while using Yosys to synthesize a Verilog file. The specific details are as follows:
I used the Verilog file rtl.v, and during the Yosys synthesis, a yosys_stderr.log file was generated with the following content:

“terminate called after throwing an instance of 'std::length_error'
what(): hash table exceeded maximum size.”

The synthesis process was interrupted due to this error. I suspect this is because the design file is too large, causing the hash table to exceed its maximum size limit. To rule out issues with the design file itself, I have checked the structure of the Verilog file but did not find any obvious problems. Additionally, I am using the latest version of Yosys.

Attached is the Verilog file (rtl.v) that triggers this issue. I hope to get the community's help and attention.
design_file.zip

Expected Behavior

synthesis success

Actual Behavior

synthesis fail

@PerryLogic PerryLogic added the pending-verification This issue is pending verification and/or reproduction label Jun 17, 2024
@whitequark whitequark added needs-info Issue needs more context/information in order to be resolved and removed pending-verification This issue is pending verification and/or reproduction labels Jun 17, 2024
@whitequark
Copy link
Member

You should minimize the reproducer further.

@mtuomi
Copy link

mtuomi commented Jun 17, 2024

I have previously fixed this locally by adding large prime like 1955854157 at the end of zero_and_some_primes array in hashlib.h (inside hashtable_size function). I couldn't reproduce the problem with your design_file.zip. I've seen this only with really massive designs with hundreds of millions of gates.

@Kmanfi
Copy link

Kmanfi commented Jun 17, 2024

Seen also same error with huge designs. Haven’t made an issue here coz privacy of those designs.
I confirm: By adding additional prime will fix the issue, as explained in previous comment.
I have seen the issue during flattening already compiled huge designs.

@georgerennie
Copy link
Collaborator

georgerennie commented Jun 17, 2024

The reason you are hitting this limit seems to be because of the large structures from your large constant shifts interacting badly with peepopt shiftadd, the same thing that caused issues in #4445. Please minimize and look into whether you are seeing duplicates of this issue yourself first as they have come up a few times.

If you try running with patch #4455, this issue isn't hit as it doesn't generate these massive intermediate nodes.

@PerryLogic
Copy link
Author

@whitequark @georgerennie Thank you for your responses. I have tried using the patch from #4455, but the issue still persists. I have simplified my program and would appreciate your help in analyzing and resolving this problem. Looking forward to your feedback, thank you.

design_file.zip

@whitequark
Copy link
Member

Thanks, the new reproducer is vastly more useful.

@georgerennie
Copy link
Collaborator

georgerennie commented Jun 26, 2024

Could you double check you have the patch from #4455 applied correctly? For me on latest main (1288166) without it I can reproduce your issue still with the new rtl, but when I cherry pick that patch synthesis completes quickly without issue.

I applied the patch by doing something along the lines of

git fetch
git checkout main
git cherry-pick 2f0f10cb871228248c8e012a9d6756c1e1b972c1

I am using yosys -p "read_verilog rtl.v; synth" to test it.

I should also add that I think the hash table error is one worth fixing (it seems by adding another prime), but hopefully applying this patch would allow you to stop hitting these cases with the fuzzing work.

@PerryLogic
Copy link
Author

Could you double check you have the patch from #4455 applied correctly? For me on latest main (1288166) without it I can reproduce your issue still with the new rtl, but when I cherry pick that patch synthesis completes quickly without issue.

I applied the patch by doing something along the lines of

git fetch
git checkout main
git cherry-pick 2f0f10cb871228248c8e012a9d6756c1e1b972c1

I am using yosys -p "read_verilog rtl.v; synth" to test it.

I should also add that I think the hash table error is one worth fixing (it seems by adding another prime), but hopefully applying this patch would allow you to stop hitting these cases with the fuzzing work.

Thanks for your reply. I thought only one file was repaired, but then I noticed that two files were repaired in total. After I recompiled, the problem disappeared.

georgerennie added a commit to georgerennie/yosys that referenced this issue Jul 1, 2024
* Add some primes as suggested in YosysHQ#4458. This allows larger hashtables
  to be allocated for very big designs
georgerennie added a commit to georgerennie/yosys that referenced this issue Jul 1, 2024
* Add some primes as suggested in YosysHQ#4458. This allows larger hashtables
  to be allocated for very big designs
donn pushed a commit to donn/yosys that referenced this issue Aug 27, 2024
* Add some primes as suggested in YosysHQ#4458. This allows larger hashtables
  to be allocated for very big designs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-info Issue needs more context/information in order to be resolved
Projects
None yet
Development

No branches or pull requests

5 participants