From 652a8874b523360a3b19c5003c8ba9894ac54d0f Mon Sep 17 00:00:00 2001 From: "Robert Nurnberg @ elitebook" Date: Fri, 14 Mar 2025 20:32:38 +0100 Subject: [PATCH] Allow more than 1024 threads on high-end machines closes https://github.com/official-stockfish/Stockfish/pull/5929 No functional change --- src/engine.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/engine.cpp b/src/engine.cpp index 6c8799a1..a4c0bb1e 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -18,6 +18,7 @@ #include "engine.h" +#include #include #include #include @@ -32,6 +33,7 @@ #include "misc.h" #include "nnue/network.h" #include "nnue/nnue_common.h" +#include "numa.h" #include "perft.h" #include "position.h" #include "search.h" @@ -44,8 +46,9 @@ namespace Stockfish { namespace NN = Eval::NNUE; -constexpr auto StartFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; -constexpr int MaxHashMB = Is64Bit ? 33554432 : 2048; +constexpr auto StartFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; +constexpr int MaxHashMB = Is64Bit ? 33554432 : 2048; +int MaxThreads = std::max(1024, 4 * int(get_hardware_concurrency())); Engine::Engine(std::optional path) : binaryDirectory(path ? CommandLine::get_binary_directory(*path) : ""), @@ -74,7 +77,7 @@ Engine::Engine(std::optional path) : })); options.add( // - "Threads", Option(1, 1, 1024, [this](const Option&) { + "Threads", Option(1, 1, MaxThreads, [this](const Option&) { resize_threads(); return thread_allocation_information_as_string(); }));