Stockfish now benefits from hyperthreading

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Gusev
Posts: 1476
Joined: Mon Jan 28, 2013 2:51 pm

Stockfish now benefits from hyperthreading

Post by Gusev »

I ran a copy of my in-house Stockfish compile (Stockfish, 16 threads) against its copy (Stockfish_2015-11-03_x64_bmi2_MinGW, 8 threads),
no ponder, no Syzygy, 256MB hash, on a Corei7-5960X (8 cores, hyperthreading on), 20"+0.3" TC, on Marijan's Arena-Blitzer, with the following results

-----------------Stockfish-----------------
Stockfish - Stockfish_2015-11-03_x64_bmi2_MinGW : 509.5/1000 148-129-723 (===0==10=0=01==1====1==0====0====101=0===1====1======0=0=0=0==101=1======01=0=0====1=====1=11=10===0==1=====0========0=1======1001=01=======1===1===01=
==0=01==1==11=========0=========1=0=====0========
=0==0==0==10==111====1=====1===0=======0==0=11==1========0======1=======0==01=10======1========1======0======0======0==========1=11=======0=1======0======1100===0==10===0===0===1=0=1=====0=====1=1=0============1=1==110===1==0===1==1=1===11======1=0=00
=======10===1========0=1==1========1========110==
===0==1===1==1=111==10========1====1====1=1====1==1============0==1=0======1====1===0====0===0======10======0==00===011==0=11=110=========1=======11===01===10======1=1==01=====10=0======0=10==01===1==1==1=====0====1==010==1====110====00======0======0==1====1==1=1===1==0==0===0=====1==1=====1======1===0
1===010=01=10=======0=======0======01=================0==1===1====1====0=====1====0==00========0===0
1===0======0====0====1=1=1=0=========1==0====1==0====0==001====01=0==10==10====0010==1===1=1=1000) 51% +7
-----------------Stockfish_2015-11-03_x64_bmi2_MinGW-----------------
Stockfish_2015-11-03_x64_bmi2_MinGW - Stockfish : 490.5/1000 129-148-723 (===1==01=1=10==0====0==1====1====010=1===0====0======1=1=1=1==010=0======10=1=1====0=====0=00=01===1==0=====1========1=0======0110=10=======0===0===10===1=10==0==00=========1=========0=1=====1========
=1==1==1==01==000====0=====0===1=======1==1=00==0========1======0=======1==10=01======0========0======1======1======1==========0=00=======1=0======1=
=====0011===1==01===1===1===0=1=0=====1=====0=0=1============0=0==001===0==1===0==0=0===00======0=1=11
=======01===0========1=0==0========0========001=====1==0===0==0=000==01========0====0====0=0====0==0============1==0=1======0====0===1====1===1======
01======1==11===100==1=00=001=========0=======00===10===01======0=0==10=====01=1======1=01==10===0==0=
=0=====1====0==101==0====001====11======1======1==0====0==0=0===0==1==1===1=====0==0=====0======0===10===101=10=01=======1=======1======10=============
====1==0===0====0====1=====0====1==11========1===10===1======1====1====0=0=0=1=========0==1====0==1====1==110====10=1==01==01====1101==0===0=0=0111) 49% -7

Is the apparent advantage of 16 threads over 8 due to the benefits of LazySMP?
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: Stockfish now benefits from hyperthreading

Post by AlvaroBegue »

I get a LOS of 0.87319, which means your result is not very significant. A p-value of 0.12 is not good enough even for social science. :)
Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Stockfish now benefits from hyperthreading

Post by Dann Corbit »

The thing that is very interesting is that it is not clearly worse.
Gusev
Posts: 1476
Joined: Mon Jan 28, 2013 2:51 pm

Re: Stockfish now benefits from hyperthreading

Post by Gusev »

Whoever is interested is most welcome to run more games. As Dann Corbit pointed out correctly, hyperthreading used to make performance clearly worse in the past, so I am delighted to see that not happen in this one experiment.
ernest
Posts: 2041
Joined: Wed Mar 08, 2006 8:30 pm

Re: Stockfish now benefits from hyperthreading

Post by ernest »

Gusev wrote:Stockfish - Stockfish_2015-11-03_x64_bmi2_MinGW : 509.5/1000 148-129-723
With 95% (2 sigma) error-bar, the result reads as : (509.5 ± 17) / 1000
Gusev
Posts: 1476
Joined: Mon Jan 28, 2013 2:51 pm

Ditto Cheng 4 Re: Stockfish now benefits from hyperthreading

Post by Gusev »

As a follow-up, I ran 1000 games of Cheng 4, 8 threads vs. 4 threads on a 4-core i7-930. The 8-thread Cheng 4 won,
-----------------Cheng4_x64-----------------
Cheng4_x64 - Cheng4_x64 - Copy : 523.0/1000 236-190-574 (1=010=1=0101=00=1==01===010==001=10=0==0=====111=11=100=11=1=01=111001011=0===11==01===10======0=110=1==0=00=10====11=0101====011=01=1====1=1=====110=====10====
==1100====1==1==101====1=1=0=1=11==1========0===0====1111=11=00==0==1====101==0=1====1=1====0=00=====11=000========01===10==0=10=====10===0==1==0==00==1=0
=1===1=01=011===111======1011=0===11====0=1=00010=0001==0=1====0100=====0==0=======0==0=========00==11=1=10=0====1===0=1=10110=110==0=100==0=100=01=1=10=0=11=
=====1==1====1=1=0=1=01======1=01=0=0=01=1=1010====1010==1=1=1==001===11=10==101=01=1=01110=01==0===0===1=0=110===0=1011=01==11==01=00===1==1===11=10=11===1===0=10====0==========1=0==0=1========1==========1=1====0===01=011101=1=0=0=1===01010=======11==1==1=1=0==
101=10=0=00=0===1110==0=================1=0=1=1=01=1=1===1======1=====01=11=0===11=11=1=01=0===========
===0111=00===0==01==========1===1=111===01===0===10===1=0101=1=011======0====1===0===100===1=====0=0======0010=1=00====0==110===010=====1==01==1=1=0==1=00====0=001) 52% +14
-----------------Cheng4_x64 - Copy-----------------
Cheng4_x64 - Copy - Cheng4_x64 : 477.0/1000 190-236-574 (0=101=0=1010=11=0==10===101==110=01=1==1=====000=00=011=00=0=10=000110100=1===00==10===01======1=001=0==1=11=01====00=1010====100=10=0====0=0=====001=====01====
==0011====0==0==010====0=0=1=0=00==0========1===1====0000=00=11==1==0====010==1=0====0=0====1=11=====00=111========10===01==1=01=====01===1==0==1==11==0=1
=0===0=10=100===000======0100=1===00====1=0=11101=1110==1=0====1011=====1==1=======1==1=========11==00=0
=01=1====0===1=0=01001=001==1=011==1=011=10=0=01=1=00======0==0====0=0=1=0=10======0=10=1=1=10=0=0101====0101==0=0=0==110===00=01==010=10=0=10001=10==1===1===0=
1=001===1=0100=10==00==10=11===0==0===00=01=00===0===1=01====1==========0=1==1=0========0==========0=0=
===1===10=100010=0=1=1=0===10101=======00==0==0=0=1==
010=01=1=11=1===0001==1=================0=1=0=0=10=0=0===0======0=====10=00=1===00=00=0=10=1==============1000=11===1==10==========0===0=000===10===1===01===0=1010=0=100======1====0===1===011===0=====1=1==
====1101=0=11====1==001===101=====0==10==0=0=1==0=11====1=110) 48% -14
Gusev
Posts: 1476
Joined: Mon Jan 28, 2013 2:51 pm

Re: Ditto Cheng 4 Re: Stockfish now benefits from hyperthrea

Post by Gusev »

Likewise, Cheng 4 (16 threads) won over Cheng 4 Copy (8 threads) on i7-5960X,
-----------------Cheng4_x64-----------------
Cheng4_x64 - Cheng4_x64_Copy : 519.0/1000 215-177-608 (1===00=====1==0==0=1====0=01==001=0=010==1=0=1111000=1==00===01==0=10========1=00=01==1=11=0==1==1===110====11=0==0==1=101=100====00===11====11===110===1===
0111==0=1======0=01==1===01====0=11==0=0=0=10===110010===1110==1==0===11==1==101==1==========1=0==1=0===1=====1=1==0=1==011=1==0===1==0=0====1==1==01==0=11=
1=0======111=====00=01=0=1=001=====10==0011==1==0=1======1==0=1=======1===01====1====0=10=011010============0=======0=01===0=01===0===101=======1====0===
==1=1==1=0==1=1====11==010========1==01===10==110010====01===01=====10===0===000=0==1=11===1=00===0==1=1===1=0=111===1======0===00=====01=1==1==10=====0==1
01=0=1=0==110====1====0==0====1===0=1010=1==1====1=1001101===========1=00==1==11==1===010=1======1=1==0=====01===1==========0=1=0=10========0011=010==00==1
=0=0=======1==1===1=1===1=1000==1====0=01==11==1=00==1===1=101==1==0===1====11==11=====0=1===0=0=000==10=10==1===0==1=====0====10==01=1==0==11==101==0=====
=0==0=====01======1=00===0=1=1111===1===0=====0=0=1001==00=1=1011=11=1) 52% +14
-----------------Cheng4_x64_Copy-----------------
Cheng4_x64_Copy - Cheng4_x64 : 481.0/1000 177-215-608 (0===11=====0==1==1=0====1=10==110=1=101==0=1=0000111=0==11===10==1=01========0=11=10==0=00=1==0==0===001====00=1==1==0=010=011====11===00====00===001===0===
1000==1=0======1=10==0===10====1=00==1=1=1=01===001101===0001==0==1===00==0==010==0==========0=1==0=1===0=====0=0==1=0==100=0==1===0==1=1====0==0==10==1=00=
0=1======000=====11=10=1=0=110=====01==1100==0==1=0======0==1=0=======0===10====0====1=01=100101============1=======1=10===1=10===1===010=======0====1===
==0=0==0=1==0=0====00==101========0==10===01==001101====10===10=====01===1===111=1==0=00===0=11===1==0=0===0=1=000===0======1===11=====10=0==0==01=====1==0
10=1=0=1==001====0====1==1====0===1=0101=0==0====0=0110010===========0=11==0==00==0===101=0======0=0==1=====10===0==========1=0=1=01========1100=101==11==0
=1=1=======0==0===0=0===0=0111==0====1=10==00==0=11==0===0=010==0==1===0====00==00=====1=0===1=1=111==01=01==0===1==0=====1====01==10=0==1==00==010==1=====
=1==1=====10======0=11===1=0=0000===0===1=====1=1=0110==11=0=0100=00=0) 48% -14
Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Ditto Cheng 4 Re: Stockfish now benefits from hyperthrea

Post by Dann Corbit »

This is a very surprising result.
NPS clearly should not be expected to increase.
With double the threads, there should be greatly increased SMP loss.
There must be some other unaccounted affect here.

I would love to see a logical explanation for it.
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: Ditto Cheng 4 Re: Stockfish now benefits from hyperthrea

Post by AlvaroBegue »

Dann Corbit wrote:This is a very surprising result.
NPS clearly should not be expected to increase.
Why shouldn't NPS increase? The promise of hyper-threading is that you can effectively run up to two threads per core, with some degradation. This degradation has traditionally been too great to compensate for the sub-linear scaling in parallel-search performance with the number of threads. It could be that recent i7 processors are doing hyper-threading so well that it now does compensate. Or perhaps parallel search now scales better with number of threads?
Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Ditto Cheng 4 Re: Stockfish now benefits from hyperthrea

Post by Dann Corbit »

Even if the context switch occurs with zero overhead, it is astonishing to imagine that somehow the single core can do more work by simply switching context. That is all that it is doing.