Planning & Search in Rust
Esc

Loading…

↑↓ move ↵ open Esc close
Colour theme
All algorithms

Lazy SMP

Also known as Shared hash table parallel search

adversarial game-tree-search

Lazy SMP runs iterative deepening of the same root on several threads that share one transposition table. The threads do not split the work: what one thread stores answers or orders the others' searches, every other helper starts one ply ahead, and each helper keeps the move the game orders first but rotates the others by its own index, so the threads try the best guess first and the alternatives in different orders. The search ends when the main thread has spent its budget, or when any thread reaches the maximum depth or proves the score; the result is a finished thread's, else the deepest thread's, ties going to the main thread, and with the default satisfices its score equals a single-threaded search's at the same depth. The table is SharedTable, with locked shards for any move and score, or the lockless PackedTable for moves and scores that pack into a few bits; the search is deepen_shared, or deepen_shared_with with a Deepening hook, behind the parallel feature. Use it when a node costs about a microsecond or more: with nodes of a few dozen nanoseconds, the shared table's synchronisation eats the gain, so measure on the game at hand.

Pseudocode

algorithm Lazy-SMP(p, D, k, budget, TT)input: root position p, maximum depth D, threads k, budget, shared transposition table TToutput: a finished thread's result, else the deepest thread's, ties going to the main threadfor h in 1, …, k − 1 in parallel do          ▷ helpersd₀ ← 2 if h is odd, else 1                 ▷ every other helper starts one ply aheaddeepen p from depth d₀ to D with TT, at every position keeping the first move and rotating the rest by hdeepen p from depth 1 to D with TT, within budget   ▷ the main threadstop every thread once the main thread is done, or any thread reaches D or proves the scorereturn the finished thread's result, else the deepest thread's

In the crates

  • game-tree-search feature parallel

    Several threads deepen the same root through one shared transposition table (SharedTable or the lockless PackedTable); helpers keep the game's first move and rotate the rest, and the furthest thread's result wins.

    deepen_shareddeepen_shared_withSharedTable

Lineage

Led to

Nothing on this site.