shithub: moonfish

Download patch

ref: ffdde2bbdd4fe1cc45fd340adcc139a1af5e95a0
parent: fcff81ba6dde5e57a19220076d89315007c6c378
author: zamfofex <zamfofex@twdb.moe>
date: Wed Nov 27 13:03:11 EST 2024

add a default thread count

--- a/main.c
+++ b/main.c
@@ -6,6 +6,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <strings.h>
+#include <unistd.h>
 
 #include "moonfish.h"
 #include "threads.h"
@@ -223,6 +224,12 @@
 	info.thread_count = 1;
 	info.searching = 0;
 	
+#ifndef moonfish_no_threads
+	info.thread_count = sysconf(_SC_NPROCESSORS_ONLN);
+	if (info.thread_count > 256) info.thread_count = 256;
+	if (info.thread_count < 1) info.thread_count = 4;
+#endif
+	
 	for (;;) {
 		
 		fflush(stdout);
@@ -276,7 +283,7 @@
 			printf("id name moonfish\n");
 			printf("id author zamfofex\n");
 #ifndef moonfish_no_threads
-			printf("option name Threads type spin default 1 min 1 max 256\n");
+			printf("option name Threads type spin default %d min 1 max 256\n", info.thread_count);
 #endif
 			printf("uciok\n");
 			continue;
--