Diminishing returns and hyperthreading
Posted: Tue Dec 27, 2016 4:21 pm
From this thread of Andreas Strangmüller on Stockfish 8 parallelization:
http://www.talkchess.com/forum/viewtopic.php?t=62146
Amdahl's law:
Effective Speed-Up = 1 / (1 - 0.955 + 0.955/n_cores)
Which describes very accurately the results.
From this each doubling in physical cores is worth in effective speed-up:
1 ---> 2 cores: 1.91
2 ---> 4 cores: 1.84
4 ---> 8 cores: 1.73
8 ---> 16 cores: 1.57
16 ---> 32 cores: 1.40
32 ---> 64 cores: 1.25
Hyperthreading on 4 physical, 8 logical cores i7-4790 (affinities set each time), 150 positions:
NPS 1 core 1 thread:
n/s: 1.708.948
NPS 1 core 2 threads:
n/s: 2.132.251
NPS speed-up: 1.25
NPS 4 cores 4 threads:
n/s: 6.828.883
NPS 4 cores 8 threads:
n/s: 8.563.755
NPS speed-up: 1.25
So, we can assume that hyperthreading gives 25% boost in NPS (0.32 doubling in NPS) pretty much independently of the number of cores.
Doubling of physical cores, which gives diminishing returns, will give diminishing to negative results with doubling of logical cores (hyperthreading):
So, hyperthreading using 8 or more physical cores is already useless strength-wise. With many cores, it becomes very harmful strength-wise. There is commentary on 8 physical cores, using 10 or 12 (not full 16) hyperthreads might help a bit. The prediction I can test on my i7-4790 is that gain 1 --> 2 threads on one same physical core is worth more than double the gain 4 --> 8 threads on 4 physical cores:
10'' + 0.1''
The test confirms the above on low number of cores.
http://www.talkchess.com/forum/viewtopic.php?t=62146
Amdahl's law:
Effective Speed-Up = 1 / (1 - 0.955 + 0.955/n_cores)
Which describes very accurately the results.
From this each doubling in physical cores is worth in effective speed-up:
1 ---> 2 cores: 1.91
2 ---> 4 cores: 1.84
4 ---> 8 cores: 1.73
8 ---> 16 cores: 1.57
16 ---> 32 cores: 1.40
32 ---> 64 cores: 1.25
Hyperthreading on 4 physical, 8 logical cores i7-4790 (affinities set each time), 150 positions:
NPS 1 core 1 thread:
n/s: 1.708.948
NPS 1 core 2 threads:
n/s: 2.132.251
NPS speed-up: 1.25
NPS 4 cores 4 threads:
n/s: 6.828.883
NPS 4 cores 8 threads:
n/s: 8.563.755
NPS speed-up: 1.25
So, we can assume that hyperthreading gives 25% boost in NPS (0.32 doubling in NPS) pretty much independently of the number of cores.
Doubling of physical cores, which gives diminishing returns, will give diminishing to negative results with doubling of logical cores (hyperthreading):
Code: Select all
Threads Diminished return NPS boost with hyperthrd Total hyperthrd benefit
in doubling in doubling in doubling
1 to 2 -0.066 0.32 0.25
2 to 4 -0.12 0.32 0.20
4 to 8 -0.21 0.32 0.11
8 to 16 -0.35 0.32 -0.03
16 to 32 -0.51 0.32 -0.19
32 to 64 -0.68 0.32 -0.36
10'' + 0.1''
Code: Select all
Score of SF8 2 threads vs SF8 1 thread: 1073 - 871 - 3056 [0.520] 5000
ELO difference: 14.04 +/- 5.99
Finished match
Code: Select all
Score of SF8 8 threads vs SF8 4 threads: 851 - 751 - 3398 [0.510] 5000
ELO difference: 6.95 +/- 5.44
Finished match