Skip to content

Commit 652a887

Browse files
robertnurnbergDisservin
authored andcommitted
Allow more than 1024 threads on high-end machines
closes #5929 No functional change
1 parent 4afd7f1 commit 652a887

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/engine.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "engine.h"
2020

21+
#include <algorithm>
2122
#include <cassert>
2223
#include <deque>
2324
#include <iosfwd>
@@ -32,6 +33,7 @@
3233
#include "misc.h"
3334
#include "nnue/network.h"
3435
#include "nnue/nnue_common.h"
36+
#include "numa.h"
3537
#include "perft.h"
3638
#include "position.h"
3739
#include "search.h"
@@ -44,8 +46,9 @@ namespace Stockfish {
4446

4547
namespace NN = Eval::NNUE;
4648

47-
constexpr auto StartFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
48-
constexpr int MaxHashMB = Is64Bit ? 33554432 : 2048;
49+
constexpr auto StartFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
50+
constexpr int MaxHashMB = Is64Bit ? 33554432 : 2048;
51+
int MaxThreads = std::max(1024, 4 * int(get_hardware_concurrency()));
4952

5053
Engine::Engine(std::optional<std::string> path) :
5154
binaryDirectory(path ? CommandLine::get_binary_directory(*path) : ""),
@@ -74,7 +77,7 @@ Engine::Engine(std::optional<std::string> path) :
7477
}));
7578

7679
options.add( //
77-
"Threads", Option(1, 1, 1024, [this](const Option&) {
80+
"Threads", Option(1, 1, MaxThreads, [this](const Option&) {
7881
resize_threads();
7982
return thread_allocation_information_as_string();
8083
}));

0 commit comments

Comments
 (0)