pleco-rs / Pleco

A Rust-based re-write of the Stockfish Chess Engine
https://crates.io/crates/pleco
GNU General Public License v3.0
358 stars 38 forks source link

Alternate Implementation of Parallel Search Strategy #30

Closed sfleischman105 closed 6 years ago

sfleischman105 commented 6 years ago

Currently, all the parallel algorithms implement Principal Variation Splitting (See section on ChessProgramming Wiki) to utilize mutli-core processing. PVS works by searching a set amount of moves sequentially to find an alpha cut-off, and then the remaining nodes are searched in parallel with that alpha cutoff. Can this be done better?

sfleischman105 commented 6 years ago

Parallel Search Strategies

Here I'm going to outline the Pros and Cons of various Parallel Search Strategies.

1) Young Brothers Wait Concept (YBWC) / Jamboree

Link HERE and HERE for further information.

Pros

Cons

2) Lazy SMP

Link HERE for further information.

Pros

Cons

AnshulMalik commented 6 years ago

Aren't there any other strategies?

sfleischman105 commented 6 years ago

@AnshulMalik Yes, quite a few actually!

The two examples listed above are actually referring to broader, over-arching parallel search implementations rather than specific algorithms. Both the YBWC and Lazy SMP have multiple possible implementation strategies for each.

The main difference between the two (to my knowledge!) is that in a YBWC-like algorithm, threads divide and conquer the possible moves in a list of moves, while in a Lazy SMP implementation the main source of communication / work sharing between threads is through a shared Transposition Table.

These are the two most "popular" strategies for parallel searching, due to decent scalability when the thread count is increased. Obviously some other implementations exist, such as Dynamic Tree Splitting, which could be worth looking into.

There is a fair amount of information available at with ChessWiki page on Parallel Search Strategies.

AnshulMalik commented 6 years ago

Great! @sfleischman105. I'll be doing more research on them.

sfleischman105 commented 6 years ago

As of #57, this library is split into pleco (core functionality) and pleco_engine (the uci searcher).

Currently, we are using the Lazy SMP approach, similar to stockfish. There is a non-negligible startup time for the searcher, but the multi-threading speedup far surpases anything before. Furthermore, we can write "sequential-esq" code with relative ease, allowing stuff like local variables and tables for each thread.