From 1ae0d8432f306edf9f05fc960794046e3d397f88 Mon Sep 17 00:00:00 2001 From: mikesinouye Date: Thu, 2 Jan 2025 08:59:11 -0800 Subject: [PATCH 1/2] Approximately double the max hash table size --- kernel/hashlib.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 6927702e1..9aac70f2a 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -324,10 +324,10 @@ template struct hash_ops> { } }; -inline int hashtable_size(int min_size) +inline unsigned int hashtable_size(unsigned int min_size) { // Primes as generated by https://oeis.org/A175953 - static std::vector zero_and_some_primes = { + static std::vector zero_and_some_primes = { 0, 23, 29, 37, 47, 59, 79, 101, 127, 163, 211, 269, 337, 431, 541, 677, 853, 1069, 1361, 1709, 2137, 2677, 3347, 4201, 5261, 6577, 8231, 10289, 12889, 16127, 20161, 25219, 31531, 39419, 49277, 61603, 77017, 96281, @@ -337,13 +337,13 @@ inline int hashtable_size(int min_size) 25499291, 31874149, 39842687, 49803361, 62254207, 77817767, 97272239, 121590311, 151987889, 189984863, 237481091, 296851369, 371064217, 463830313, 579787991, 724735009, 905918777, 1132398479, 1415498113, - 1769372713 + 1769372713, 2211715897, 2764644871, 2764644887, 3455806139 }; for (auto p : zero_and_some_primes) if (p >= min_size) return p; - if (sizeof(int) == 4) + if (sizeof(unsigned int) == 4) throw std::length_error("hash table exceeded maximum size.\nDesign is likely too large for yosys to handle, if possible try not to flatten the design."); for (auto p : zero_and_some_primes) From de9cb5a60c041447e7e85f2cbfb1d8911f0bda44 Mon Sep 17 00:00:00 2001 From: mikesinouye Date: Thu, 2 Jan 2025 11:05:30 -0800 Subject: [PATCH 2/2] Remove spurious prime --- kernel/hashlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 9aac70f2a..188b176b4 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -337,7 +337,7 @@ inline unsigned int hashtable_size(unsigned int min_size) 25499291, 31874149, 39842687, 49803361, 62254207, 77817767, 97272239, 121590311, 151987889, 189984863, 237481091, 296851369, 371064217, 463830313, 579787991, 724735009, 905918777, 1132398479, 1415498113, - 1769372713, 2211715897, 2764644871, 2764644887, 3455806139 + 1769372713, 2211715897, 2764644887, 3455806139 }; for (auto p : zero_and_some_primes)