Skip to content

Commit 1ae0d84

Browse files
authored
Approximately double the max hash table size
1 parent cbb95cb commit 1ae0d84

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/hashlib.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,10 @@ template<typename T> struct hash_ops<std::optional<T>> {
324324
}
325325
};
326326

327-
inline int hashtable_size(int min_size)
327+
inline unsigned int hashtable_size(unsigned int min_size)
328328
{
329329
// Primes as generated by https://oeis.org/A175953
330-
static std::vector<int> zero_and_some_primes = {
330+
static std::vector<unsigned int> zero_and_some_primes = {
331331
0, 23, 29, 37, 47, 59, 79, 101, 127, 163, 211, 269, 337, 431, 541, 677,
332332
853, 1069, 1361, 1709, 2137, 2677, 3347, 4201, 5261, 6577, 8231, 10289,
333333
12889, 16127, 20161, 25219, 31531, 39419, 49277, 61603, 77017, 96281,
@@ -337,13 +337,13 @@ inline int hashtable_size(int min_size)
337337
25499291, 31874149, 39842687, 49803361, 62254207, 77817767, 97272239,
338338
121590311, 151987889, 189984863, 237481091, 296851369, 371064217,
339339
463830313, 579787991, 724735009, 905918777, 1132398479, 1415498113,
340-
1769372713
340+
1769372713, 2211715897, 2764644871, 2764644887, 3455806139
341341
};
342342

343343
for (auto p : zero_and_some_primes)
344344
if (p >= min_size) return p;
345345

346-
if (sizeof(int) == 4)
346+
if (sizeof(unsigned int) == 4)
347347
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.");
348348

349349
for (auto p : zero_and_some_primes)

0 commit comments

Comments
 (0)