summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 5ece480..61a3850 100644
--- a/src/main.c
+++ b/src/main.c
@@ -30,6 +30,14 @@ int main(int argc, char** argv) {
threads_init(&engine_threads, ipc_state.uci_state.threads);
threads_link(&engine_threads, &ipc_state);
+ // initialise the transposition table from the UCI "Hash" option (in MiB).
+ // pick the smallest power of two (>= 2^4) that fills at least that much memory.
+ size_t hash_mb = (size_t)ipc_state.uci_state.hash;
+ u64 buckets = (hash_mb * 1024 * 1024) / sizeof(tbucket_t);
+ int hash_log2 = 4;
+ while ((1ULL << (hash_log2 + 1)) <= buckets && hash_log2 < 30) hash_log2++;
+ ttable_init(&engine_threads.ttable, hash_log2);
+
engine_messages_init(&ipc_state.engine_messages);
goto skip_refresh;
waiting_for_go: