(actually I just found a bug where minimum qs depth is not copied to helpers before the start of new iteration so right now min qs depth is for helpers now actually depends on maximum depth reached in previous search, I'm not sure if/what impact this may have)
Code: Select all
IterativeDeepening:
synchronize smp threads (copy age, board, history, repetition list, multipv => helpers)
depth 1 with full width window on 1 thread
loop (depth=2 .. max)
AspirationLoop:
(as usual)
start helper threads( depth, alpha, beta )
root( depth, alpha, beta)
stop helper threads
(rest as usual)
end aspiration loop
end id loop
Code: Select all
starting helper threads:
clear smp abort flag
for each helper thread:
copy rootmoves and minimum qs depth => helper
signal helper to start root search at current depth (add 1 for each even helper (assuming 0-based indexing) with aspiration alpha, beta bounds and wait until helper starts searching
Code: Select all
aborting helper threads:
set abort flag for each helper and wait for each to stop searching
helpers hold ref pointer to master (if it's 0 it's master) - actually a pointer to abort smp flag would do.
At the end of root search helpers simply set a special flag (abort smp flag) in master.
When master detects abort (smp) flag coming from the helpers (different from typical abort flag),
it scans through helpers and copies score/bestmove/PV from the first helper that finished root.
Pondering doesn't require any special handling (handled by master search thread).
I hope I didn't forget something important, perhaps it even makes sense
