use sleeping threads

Discussion of anything and everything relating to chess playing software and machines.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 2:27 pm

use sleeping threads

Post by Don » Wed Jul 10, 2013 6:31 pm

What does the option "use sleeping threads" in Stockfish mean? If I set Stockfish to use 4 threads does it mean it will try to use more than 4 threads if they are not being used by other processes?

Don
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.

Joerg Oster
Posts: 689
Joined: Fri Mar 10, 2006 3:29 pm
Location: Germany

Re: use sleeping threads

Post by Joerg Oster » Wed Jul 10, 2013 7:05 pm

No.
Afaik, it means, threads without work should sleep and not keep spinning. See http://talkchess.com/forum/viewtopic.ph ... 14&t=37574
Jörg Oster

User avatar
Graham Banks
Posts: 33145
Joined: Sun Feb 26, 2006 9:52 am
Location: Auckland, NZ

Re: use sleeping threads

Post by Graham Banks » Wed Jul 10, 2013 7:38 pm

Joerg Oster wrote:No.
Afaik, it means, threads without work should sleep and not keep spinning. See http://talkchess.com/forum/viewtopic.ph ... 14&t=37574
Confusing use of language.
Should be changed to Non-use of sleeping threads or something that more correctly indicates what is meant.
My email addresses:
gbanksnz at gmail.com
gbanksnz at yahoo.co.nz

bob
Posts: 20555
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: use sleeping threads

Post by bob » Wed Jul 10, 2013 8:03 pm

I think we had this discussion a while back. The question is, when a thread has no work, what does it do? If you do a spin-wait, the instant the pointer to the work is updated, the thread can get to work with no delay. If you somehow block (whether it be waiting on a semaphore, a condition variable, or even a mutex) when work becomes available it takes time to wake the thread, get its context restored (registers, memory management stuff, etc) and actually start executing the thing, introducing a little "lag" between when work is available and the thread gets busy on that work.

I do busy spins in Crafty, period, since I know that the length of time between when a thread goes idle and it starts to help another thread is very short.

The only exception I make is at the end of an iteration when pondering is disabled. In normal mode, Crafty keeps the threads spinning waiting for work. Not good if you want to do an 8 core vs 8 core game, without pondering. There's an "smpnice" variable that can be set to 1 which tells it to terminate threads while waiting on an opponent's move.

I believe the stockfish option is backward in terminology. That is, if you prefer threads to sleep when not busy, you want that off... and vice-versa...

User avatar
michiguel
Posts: 6388
Joined: Thu Mar 09, 2006 7:30 pm
Location: Chicago, Illinois, USA
Contact:

Re: use sleeping threads

Post by michiguel » Wed Jul 10, 2013 8:39 pm

Graham Banks wrote:
Joerg Oster wrote:No.
Afaik, it means, threads without work should sleep and not keep spinning. See http://talkchess.com/forum/viewtopic.ph ... 14&t=37574
Confusing use of language.
Should be changed to Non-use of sleeping threads or something that more correctly indicates what is meant.
I do not think it is confusing, but to have a very straightforward dialog,
I would suggest a UCI variable "threads wait" = sleeping/spinning

Miguel

zullil
Posts: 5668
Joined: Mon Jan 08, 2007 11:31 pm
Location: PA USA
Full name: Louis Zulli

Re: use sleeping threads

Post by zullil » Wed Jul 10, 2013 9:32 pm

Don wrote:What does the option "use sleeping threads" in Stockfish mean? If I set Stockfish to use 4 threads does it mean it will try to use more than 4 threads if they are not being used by other processes?

Don
Whatever it means, apparently the default choice is Use Sleeping Threads = true.

Code: Select all

/// init() initializes the UCI options to their hard coded default values
/// and initializes the default value of "Threads" and "Min Split Depth"
/// parameters according to the number of CPU cores detected.

void init(OptionsMap& o) {

  int cpus = std::min(cpu_count(), MAX_THREADS);
  int msd = cpus < 8 ? 4 &#58; 7;

  o&#91;"Use Debug Log"&#93;               = Option&#40;false, on_logger&#41;;
  o&#91;"Use Search Log"&#93;              = Option&#40;false&#41;;
  o&#91;"Search Log Filename"&#93;         = Option&#40;"SearchLog.txt");
  o&#91;"Book File"&#93;                   = Option&#40;"book.bin");
  o&#91;"Best Book Move"&#93;              = Option&#40;false&#41;;
  o&#91;"Contempt Factor"&#93;             = Option&#40;0, -50,  50&#41;;
  o&#91;"Mobility &#40;Midgame&#41;"&#93;          = Option&#40;100, 0, 200, on_eval&#41;;
  o&#91;"Mobility &#40;Endgame&#41;"&#93;          = Option&#40;100, 0, 200, on_eval&#41;;
  o&#91;"Pawn Structure &#40;Midgame&#41;"&#93;    = Option&#40;100, 0, 200, on_eval&#41;;
  o&#91;"Pawn Structure &#40;Endgame&#41;"&#93;    = Option&#40;100, 0, 200, on_eval&#41;;
  o&#91;"Passed Pawns &#40;Midgame&#41;"&#93;      = Option&#40;100, 0, 200, on_eval&#41;;
  o&#91;"Passed Pawns &#40;Endgame&#41;"&#93;      = Option&#40;100, 0, 200, on_eval&#41;;
  o&#91;"Space"&#93;                       = Option&#40;100, 0, 200, on_eval&#41;;
  o&#91;"Aggressiveness"&#93;              = Option&#40;100, 0, 200, on_eval&#41;;
  o&#91;"Cowardice"&#93;                   = Option&#40;100, 0, 200, on_eval&#41;;
  o&#91;"Min Split Depth"&#93;             = Option&#40;msd, 4, 12, on_threads&#41;;
  o&#91;"Max Threads per Split Point"&#93; = Option&#40;5, 4, 8, on_threads&#41;;
  o&#91;"Threads"&#93;                     = Option&#40;cpus, 1, MAX_THREADS, on_threads&#41;;
  o&#91;"Use Sleeping Threads"&#93;        = Option&#40;true&#41;;
See https://github.com/mcostalba/Stockfish/ ... option.cpp

gladius
Posts: 538
Joined: Tue Dec 12, 2006 9:10 am

Re: use sleeping threads

Post by gladius » Wed Jul 10, 2013 9:40 pm

zullil wrote:
Don wrote:What does the option "use sleeping threads" in Stockfish mean? If I set Stockfish to use 4 threads does it mean it will try to use more than 4 threads if they are not being used by other processes?

Don
Whatever it means, apparently the default choice is Use Sleeping Threads = true.
This is only true for development versions of SF. For release versions, it is set to false by default. This commit did that for SF3 https://github.com/mcostalba/Stockfish/ ... de3dfe22be

carldaman
Posts: 1719
Joined: Sat Jun 02, 2012 12:13 am

Re: use sleeping threads?

Post by carldaman » Wed Jul 10, 2013 9:55 pm

gladius wrote:
zullil wrote:
Don wrote:What does the option "use sleeping threads" in Stockfish mean? If I set Stockfish to use 4 threads does it mean it will try to use more than 4 threads if they are not being used by other processes?

Don
Whatever it means, apparently the default choice is Use Sleeping Threads = true.
This is only true for development versions of SF. For release versions, it is set to false by default. This commit did that for SF3 https://github.com/mcostalba/Stockfish/ ... de3dfe22be
So then which setting should we use? Is there any guideline?
If testing a newer developmental version, should we leave the default setting alone (=true), even though Stockfish v3 has it the other way around (=false)?

Thanks,
CL

bob
Posts: 20555
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: use sleeping threads?

Post by bob » Wed Jul 10, 2013 10:53 pm

carldaman wrote:
gladius wrote:
zullil wrote:
Don wrote:What does the option "use sleeping threads" in Stockfish mean? If I set Stockfish to use 4 threads does it mean it will try to use more than 4 threads if they are not being used by other processes?

Don
Whatever it means, apparently the default choice is Use Sleeping Threads = true.
This is only true for development versions of SF. For release versions, it is set to false by default. This commit did that for SF3 https://github.com/mcostalba/Stockfish/ ... de3dfe22be
So then which setting should we use? Is there any guideline?
If testing a newer developmental version, should we leave the default setting alone (=true), even though Stockfish v3 has it the other way around (=false)?

Thanks,
CL
Unless Marco says otherwise, I believe you want it "false". It sounds like a good idea (use sleeping threads) but I believe he stated that the term doesn't really mean what it says (he is not a native English speaker)...

User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 2:27 pm

Re: use sleeping threads?

Post by Don » Wed Jul 10, 2013 10:55 pm

carldaman wrote:
gladius wrote:
zullil wrote:
Don wrote:What does the option "use sleeping threads" in Stockfish mean? If I set Stockfish to use 4 threads does it mean it will try to use more than 4 threads if they are not being used by other processes?

Don
Whatever it means, apparently the default choice is Use Sleeping Threads = true.
This is only true for development versions of SF. For release versions, it is set to false by default. This commit did that for SF3 https://github.com/mcostalba/Stockfish/ ... de3dfe22be
So then which setting should we use? Is there any guideline?
If testing a newer developmental version, should we leave the default setting alone (=true), even though Stockfish v3 has it the other way around (=false)?

Thanks,
CL

If you don't use all your threads it should be a minor benefit to the other programs using the same machine. So for competition testing on the same machine the fairest thing to do is to use all the resources that are rightfully yours, even if they are not of much benefit to you. Here is why:

Even though the ideal with modern processors is for them to act completely independent, the reality is that this is not the case. If you let some processors go idle it will benefit (at least slightly) other processes. I don't know if that is a big deal or not but the issue does exist.
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.

Post Reply