Skip to content

Commit

Permalink
Retire "Idle Threads Sleep" UCI option
Browse files Browse the repository at this point in the history
After last Joona's patch there is no measurable
difference between the option set or unset.

Tested by Andreas Strangmüller with 16 threads
on his Dual Opteron 6376.

After 5000 games at 15+0.05 the result is:

1 Stockfish_14050822_T16_on   : 3003  5000 (+849,=3396,-755), 50.9 %
2 Stockfish_14050822_T16_off  : 2997  5000 (+755,=3396,-849), 49.1 %

bench: 880215
  • Loading branch information
mcostalba committed May 11, 2014
1 parent bfd8704 commit 9f843ad
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion polyglot.ini
Expand Up @@ -31,7 +31,6 @@ Aggressiveness = 100
Cowardice = 100
Min Split Depth = 0
Threads = 1
Idle Threads Sleep = true
Hash = 128
Ponder = true
OwnBook = false
Expand Down
7 changes: 2 additions & 5 deletions src/search.cpp
Expand Up @@ -226,14 +226,12 @@ void Search::think() {
for (size_t i = 0; i < Threads.size(); ++i)
Threads[i]->maxPly = 0;

Threads.sleepWhileIdle = Options["Idle Threads Sleep"];
Threads.timer->run = true;
Threads.timer->notify_one(); // Wake up the recurring timer

id_loop(RootPos); // Let's start searching !

Threads.timer->run = false; // Stop the timer
Threads.sleepWhileIdle = true; // Send idle threads to sleep

if (Options["Write Search Log"])
{
Expand Down Expand Up @@ -1462,7 +1460,7 @@ void Thread::idle_loop() {
{
// If we are not searching, wait for a condition to be signaled instead of
// wasting CPU time polling for work.
while ((!searching && Threads.sleepWhileIdle) || exit)
while (!searching || exit)
{
if (exit)
{
Expand Down Expand Up @@ -1537,8 +1535,7 @@ void Thread::idle_loop() {

// Wake up the master thread so to allow it to return from the idle
// loop in case we are the last slave of the split point.
if ( Threads.sleepWhileIdle
&& this != sp->masterThread
if ( this != sp->masterThread
&& sp->slavesMask.none())
{
assert(!sp->masterThread->searching);
Expand Down
7 changes: 3 additions & 4 deletions src/thread.cpp
Expand Up @@ -181,13 +181,12 @@ void MainThread::idle_loop() {


// init() is called at startup to create and launch requested threads, that will
// go immediately to sleep due to 'sleepWhileIdle' set to true. We cannot use
// a c'tor because Threads is a static object and we need a fully initialized
// engine at this point due to allocation of Endgames in Thread c'tor.
// go immediately to sleep. We cannot use a c'tor because Threads is a static
// object and we need a fully initialized engine at this point due to allocation
// of Endgames in Thread c'tor.

void ThreadPool::init() {

sleepWhileIdle = true;
timer = new_thread<TimerThread>();
push_back(new_thread<MainThread>());
read_uci_options();
Expand Down
1 change: 0 additions & 1 deletion src/thread.h
Expand Up @@ -166,7 +166,6 @@ struct ThreadPool : public std::vector<Thread*> {
void wait_for_think_finished();
void start_thinking(const Position&, const Search::LimitsType&, Search::StateStackPtr&);

bool sleepWhileIdle;
Depth minimumSplitDepth;
Mutex mutex;
ConditionVariable sleepCondition;
Expand Down
1 change: 0 additions & 1 deletion src/ucioption.cpp
Expand Up @@ -71,7 +71,6 @@ void init(OptionsMap& o) {
o["Cowardice"] << Option(100, 0, 200, on_eval);
o["Min Split Depth"] << Option(0, 0, 12, on_threads);
o["Threads"] << Option(1, 1, MAX_THREADS, on_threads);
o["Idle Threads Sleep"] << Option(true);
o["Hash"] << Option(32, 1, 16384, on_hash_size);
o["Clear Hash"] << Option(on_clear_hash);
o["Ponder"] << Option(true);
Expand Down

0 comments on commit 9f843ad

Please sign in to comment.