C++11 threads seem to get shafted for cycles
Posted: Tue Mar 18, 2014 12:04 am
An examination of Fabian's new program shows something bad when we examine the time slices we are getting. It almost seems like threads are created with idle time priority, or some awful level like that.
NORMAL PRIORITY
using start senpai-x64-avx.exe we get this:
info depth 23 seldepth 50 currmove e2e4 currmovenumber 1 nodes 149720064 time 475001 nps 315199 hashfull 500 info depth 23 seldepth 50 nodes 149928670 time 475822 score cp 23 pv e2e4 e7e5 g1f3 b8c6 f1b5 a7a6 b5c6 d7c6 e1g1 c8g4 h2h3 g4f3 d1f3 g8e7 f3b3 b7b5 d2d3 e7g6 c1e3 f8e7 b1d2 e8g8 b3c3 d8d7 d2f3 info depth 23 seldepth 50 currmove g1f3 currmovenumber 2 nodes 149972992 time 476000 nps 315069 hashfull 500
ENHANCED PRIORITY
using start /realtime senpai-x64-avx.exe we get this:
info depth 23 seldepth 50 currmove e2e4 currmovenumber 1 nodes 149607424 time 176000 nps 850042 hashfull 500 info depth 23 seldepth 50 nodes 149928670 time 176371 score cp 23 pv e2e4 e7e5 g1f3 b8c6 f1b5 a7a6 b5c6 d7c6 e1g1 c8g4 h2h3 g4f3 d1f3 g8e7 f3b3 b7b5 d2d3 e7g6 c1e3 f8e7 b1d2 e8g8 b3c3 d8d7 d2f3 info depth 23 seldepth 50 currmove g1f3 currmovenumber 2 nodes 150468608 time 177000 nps 850105 hashfull 500
so the program with one thread runs 850105 / 315069 = 2.7 times faster (~270%) under elevated priority.
That's pretty bogus since there should be a small difference for normal threads.
Consider the Stockfish result:
NORMAL PRIORITY
using start /realtime stockfish_14031222_x64_modern_sse42.exe:
Stockfish 120314 64 SSE4.2 by Tord Romstad, Marco Costalba and Joona Kiiski uci id name Stockfish 120314 64 SSE4.2 id author Tord Romstad, Marco Costalba and Joona Kiiski [snip] info depth 23 currmove a2a4 currmovenumber 20 info depth 23 seldepth 29 score cp 27 nodes 18029688 nps 1318730 time 13672 multipv 1 pv e2e4 e7e5 g1f3 g8f6 f3e5 d7d6 e5f3 f6e4 d2d3 e4f6 d3d4 d6d5 f1d3 b8c6 b1c3 f8d6 d1e2 c8e6 c3b5 e8g8 e1g1 c6b4 b5d6 d8d6 f3e5 b4d3 info depth 24 currmove e2e4 currmovenumber 1
ENHANCED PRIORITY
using start stockfish_14031222_x64_modern_sse42.exe:
Stockfish 120314 64 SSE4.2 by Tord Romstad, Marco Costalba and Joona Kiiski uci id name Stockfish 120314 64 SSE4.2 id author Tord Romstad, Marco Costalba and Joona Kiiski
[snip]
info depth 23 currmove a2a4 currmovenumber 20 info depth 23 seldepth 29 score cp 27 nodes 18029688 nps 1145760 time 15736 multipv 1 pv e2e4 e7e5 g1f3 g8f6 f3e5 d7d6 e5f3 f6e4 d2d3 e4f6 d3d4 d6d5 f1d3 b8c6 b1c3 f8d6 d1e2 c8e6 c3b5 e8g8 e1g1 c6b4 b5d6 d8d6 f3e5 b4d3 info depth 24 currmove e2e4 currmovenumber 1
difference is 1318730 / 1145760 = 1.15 times faster (~15%)
Something is entirely bogus with the default thread priority for C++11 threads, I think.
Is there a simple way to change it?
I found this sourceforge project for Boost threads changing priority:
http://sourceforge.net/projects/threadutility/
is there any semi-portable way to do it in C++11 threads?
NORMAL PRIORITY
using start senpai-x64-avx.exe we get this:
info depth 23 seldepth 50 currmove e2e4 currmovenumber 1 nodes 149720064 time 475001 nps 315199 hashfull 500 info depth 23 seldepth 50 nodes 149928670 time 475822 score cp 23 pv e2e4 e7e5 g1f3 b8c6 f1b5 a7a6 b5c6 d7c6 e1g1 c8g4 h2h3 g4f3 d1f3 g8e7 f3b3 b7b5 d2d3 e7g6 c1e3 f8e7 b1d2 e8g8 b3c3 d8d7 d2f3 info depth 23 seldepth 50 currmove g1f3 currmovenumber 2 nodes 149972992 time 476000 nps 315069 hashfull 500
ENHANCED PRIORITY
using start /realtime senpai-x64-avx.exe we get this:
info depth 23 seldepth 50 currmove e2e4 currmovenumber 1 nodes 149607424 time 176000 nps 850042 hashfull 500 info depth 23 seldepth 50 nodes 149928670 time 176371 score cp 23 pv e2e4 e7e5 g1f3 b8c6 f1b5 a7a6 b5c6 d7c6 e1g1 c8g4 h2h3 g4f3 d1f3 g8e7 f3b3 b7b5 d2d3 e7g6 c1e3 f8e7 b1d2 e8g8 b3c3 d8d7 d2f3 info depth 23 seldepth 50 currmove g1f3 currmovenumber 2 nodes 150468608 time 177000 nps 850105 hashfull 500
so the program with one thread runs 850105 / 315069 = 2.7 times faster (~270%) under elevated priority.
That's pretty bogus since there should be a small difference for normal threads.
Consider the Stockfish result:
NORMAL PRIORITY
using start /realtime stockfish_14031222_x64_modern_sse42.exe:
Stockfish 120314 64 SSE4.2 by Tord Romstad, Marco Costalba and Joona Kiiski uci id name Stockfish 120314 64 SSE4.2 id author Tord Romstad, Marco Costalba and Joona Kiiski [snip] info depth 23 currmove a2a4 currmovenumber 20 info depth 23 seldepth 29 score cp 27 nodes 18029688 nps 1318730 time 13672 multipv 1 pv e2e4 e7e5 g1f3 g8f6 f3e5 d7d6 e5f3 f6e4 d2d3 e4f6 d3d4 d6d5 f1d3 b8c6 b1c3 f8d6 d1e2 c8e6 c3b5 e8g8 e1g1 c6b4 b5d6 d8d6 f3e5 b4d3 info depth 24 currmove e2e4 currmovenumber 1
ENHANCED PRIORITY
using start stockfish_14031222_x64_modern_sse42.exe:
Stockfish 120314 64 SSE4.2 by Tord Romstad, Marco Costalba and Joona Kiiski uci id name Stockfish 120314 64 SSE4.2 id author Tord Romstad, Marco Costalba and Joona Kiiski
[snip]
info depth 23 currmove a2a4 currmovenumber 20 info depth 23 seldepth 29 score cp 27 nodes 18029688 nps 1145760 time 15736 multipv 1 pv e2e4 e7e5 g1f3 g8f6 f3e5 d7d6 e5f3 f6e4 d2d3 e4f6 d3d4 d6d5 f1d3 b8c6 b1c3 f8d6 d1e2 c8e6 c3b5 e8g8 e1g1 c6b4 b5d6 d8d6 f3e5 b4d3 info depth 24 currmove e2e4 currmovenumber 1
difference is 1318730 / 1145760 = 1.15 times faster (~15%)
Something is entirely bogus with the default thread priority for C++11 threads, I think.
Is there a simple way to change it?
I found this sourceforge project for Boost threads changing priority:
http://sourceforge.net/projects/threadutility/
is there any semi-portable way to do it in C++11 threads?