From 78ae4ed9ac73d9904f69e0247270e73df3045a51 Mon Sep 17 00:00:00 2001 From: George Rennie Date: Mon, 1 Jul 2024 12:30:35 +0100 Subject: [PATCH] hashlib: Add some more primes * Add some primes as suggested in #4458. This allows larger hashtables to be allocated for very big designs --- kernel/hashlib.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/hashlib.h b/kernel/hashlib.h index e8ddddd33..05b1528f7 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -188,6 +188,7 @@ inline unsigned int mkhash(const T &v) { inline int hashtable_size(int min_size) { + // Primes as generated by https://oeis.org/A175953 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, @@ -196,7 +197,8 @@ inline int hashtable_size(int min_size) 897133, 1121423, 1401791, 1752239, 2190299, 2737937, 3422429, 4278037, 5347553, 6684443, 8355563, 10444457, 13055587, 16319519, 20399411, 25499291, 31874149, 39842687, 49803361, 62254207, 77817767, 97272239, - 121590311, 151987889, 189984863, 237481091, 296851369, 371064217 + 121590311, 151987889, 189984863, 237481091, 296851369, 371064217, + 463830273, 579787849, 724734817, 905918527, 1132398207, 1415497781 }; for (auto p : zero_and_some_primes)