1
0
Fork 0
Commit Graph

1689 Commits (36a93d90f76d32e16a5f2acb09b7de2d67225021)

Author SHA1 Message Date
Joost VandeVondele 36a93d90f7 Move stop signal to Threads
Instead of having Signals in the search namespace,
make the stop variables part of the Threads structure.
This moves more of the shared (atomic) variables towards
the thread-related structures, making their role more clear.

No functional change

Closes #1149
2017-07-13 16:08:37 -07:00
Marco Costalba 802fca6fdd Don't uselessy share rootDepth
It is not needed becuase the only case is a real special
one (bench on depth with many threads) and can be easily
rewritten to avoid sharing rootDepth.

Verified with ThreadSanitizer.

No functional change.

Closes #1159
2017-07-02 22:06:47 -07:00
Marco Costalba 05513a6641 Only main thread checks time
The main change of the patch is that now time check
is done only by main thread. In the past, before lazy
SMP, we needed all the threds to check for available
time because main thread could have been blocked on
a split point, now this is no more the case and main
thread can do the job alone, greatly simplifying the logic.

Verified for regression testing on STC with 7 threads:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 11895 W: 1741 L: 1608 D: 8546

No functional change.

Closes #1152
2017-06-28 17:03:35 -07:00
VoyagerOne 77342126d8 Increase reduction if tt-move is a capture
The idea is that chances are the tt-move is best and will be difficult to raise alpha when playing a quiet move.

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 7582 W: 1415 L: 1259 D: 4908

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 59553 W: 7885 L: 7573 D: 44095

Bench: 5725676

Closes #1147
2017-06-21 14:06:05 -07:00
Joona Kiiski 336901fdb0 Revert "Prefetch earlier in qsearch()"
This reverts commit b73016bb41.

No functional change

Closes #1144
2017-06-21 13:45:03 -07:00
Joost VandeVondele 3cb0200459 Fix four data races.
the nodes, tbHits, rootDepth and lastInfoTime variables are read by multiple threads, but not declared atomic, leading to data races as found by -fsanitize=thread. This patch fixes this issue. It is based on top of the CI-threading branch (PR #1129), and should fix the corresponding CI error messages.

The patch passed an STC check for no regression:

http://tests.stockfishchess.org/tests/view/5925d5590ebc59035df34b9f
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 169597 W: 29938 L: 30066 D: 109593

Whereas rootDepth and lastInfoTime are not performance critical, nodes and tbHits are. Indeed, an earlier version using relaxed atomic updates on the latter two variables failed STC testing (http://tests.stockfishchess.org/tests/view/592001700ebc59035df34924), which can be shown to be due to x86-32 (http://tests.stockfishchess.org/tests/view/592330ac0ebc59035df34a89). Indeed, the latter have no instruction to atomically update a 64bit variable. The proposed solution thus uses a variable in Position that is accessed only by one thread, which is copied every few thousand nodes to the shared variable in Thread.

No functional change.

Closes #1130
Closes #1129
2017-06-21 13:37:58 -07:00
Alain SAVARD 2c237da546 Misc coding style fixes
a few comment and blank fixes.

No functional change

Closes #1141
2017-06-16 19:55:30 -07:00
snicolet b73016bb41 Prefetch earlier in qsearch()
Closes #1139
2017-06-16 19:52:38 -07:00
Marco Costalba 27ba611a3d Better naming in endgame code
And small clean-up of magic bitboards code.

No functional change.

Closes #1138
2017-06-16 19:33:44 -07:00
Brian Sheppard f907d5b7d9 Move depth calculation in probCut
The change passed an STC regression:

LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 59350 W: 10793 L: 10738 D: 37819

I verified that there was no change in performance on my machine, but of course YMMV:

Results for 40 tests for each version:

                Base      Test      Diff
        Mean    2014338   2016121   -1783
        StDev   62655     63441     3860

p-value: 0.678
speedup: 0.001

No functional change.

Closes #1137
2017-06-16 19:30:19 -07:00
Joost VandeVondele ebc563059c Call TT.new_search() earlier.
TT.new_search() was being called by mainThread in Thread::search(). However, mainThread is the last to start searching, and helper threads could reach a measured rootDepth 10 (on 64 cores) before mainThread increments the TT generation. Fixed by moving the call to MaintThread::search() before helper threads start searching.

No functional change.

Closes #1134
2017-06-16 19:20:01 -07:00
Marco Costalba ecd3218b6b History code rewrite (#1122)
Rearrange and rename all history heuristic code. Naming
is now based on chessprogramming.wikispaces.com conventions
and the relations among the various heuristics are now more
clear and consistent.

No functional change.
2017-05-26 08:42:50 +02:00
VoyagerOne 1d31065e1d Evasion Pruning Tweak
Use moveCount to decide when to prune for evasion pruning

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 24476 W: 4518 L: 4289 D: 15669

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 18362 W: 2476 L: 2298 D: 13588

Bench: 6469989

Closes #1120
2017-05-21 18:27:57 -07:00
Joost VandeVondele 732aa34e3d Fix memory access in Search::clear()
Fixes a bug in Search::clear, where the filling of CounterMoveStats&, overwrote (currently presumably unused) memory because sizeof(cm) returns the size in bytes, whereas elements was needed.

No functional change

Closes #1119
2017-05-17 18:15:01 -07:00
Joost VandeVondele 7edd1f7ccd Execute an implied ucinewgame at startup
execute an implied ucinewgame upon entering the UCI::loop,
to make sure that searches starting with and without an (optional) ucinewgame
command yield the same search.

This is needed now that seach::clear() initializes tables to non-zero default values.

No functional change

Closes #1101
Closes #1104
2017-05-15 18:54:13 -07:00
Marco Costalba 0c1f119069 Default argument for see_ge()
No functional change.

Closes #1111
2017-05-10 18:20:45 +02:00
joergoster 8b15961349 Fix multiPV issue #502
In general, this patch handles the cases where we don't have a valid score for each PV line in a multiPV search. This can happen if the search has been stopped in an unfortunate moment while still in the aspiration loop. The patch consists of two parts.

Part 1: The new PVIdx was already part of the k-best pv's in the last iteration, and we therefore have a valid pv and score to output from the last iteration. This is taken care of with:

      bool updated = (i <= PVIdx && rootMoves[i].score != -VALUE_INFINITE);

Case 2: The new PVIdx was NOT part of the k-best pv's in the last iteration, and we have no valid pv and score to output. Not from the current nor from the previous iteration. To avoid this, we are now also considering the previous score when sorting, so that the PV lines with no actual but with a valid previous score are pushed up again, and the previous score can be displayed.

  bool operator<(const RootMove& m) const {
    return m.score != score ? m.score < score : m.previousScore < previousScore; } // Descending sort

I also added an assertion in UCI::value() to possibly catch similar issues earlier.

No functional change.

Closes #502
Closes #1074
2017-05-03 19:46:40 -07:00
VoyagerOne a18c2c2c3f Don't do InCheck Pruning at the root of QS
STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 34603 W: 6441 L: 6167 D: 21995

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 24474 W: 3274 L: 3076 D: 18124

Bench: 5934421

Closes #1089
2017-04-28 20:40:45 -07:00
Joost VandeVondele d06a8d0c18 Zero unused constant
No functional change

Closes #1081
2017-04-25 17:21:36 -07:00
Marco Costalba b48439e906 Assorted code style issues
I have removed the check for

 pieceCount[PAWN] > FILE_NB

because totally useless.

No functional change.
2017-04-24 09:49:44 +02:00
Joost VandeVondele 9da3b44ddc Use int instead of Value for history related stats.
history related scores are not related to evaluation based scores.
For example, can easily exceed the range -VALUE_INFINITE,VALUE_INFINITE.
As such the current type is confusing, and a plain int is a better match.

tested for no regression:

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 43693 W: 7909 L: 7827 D: 27957

No functional change.

Closes #1070
2017-04-23 07:59:28 -07:00
Joost VandeVondele ced29248c9 simplify logic for history based pruning
STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 34255 W: 6292 L: 6194 D: 21769

LTC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 89914 W: 11769 L: 11739 D: 66406

Bench: 6581936

Closes #1066
2017-04-20 11:28:11 -07:00
VoyagerOne 9d3ed9ed2e Move-Count Formula Tweak
STC:
LLR: 3.18 (-2.94,2.94) [0.00,4.00]
Total: 55004 W: 10289 L: 9930 D: 34785

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 48184 W: 6401 L: 6128 D: 35655

Bench: 5960754
2017-04-17 09:22:10 -07:00
joergoster 72a501c6fe Fix zugzwang pruning issues
By adding pos.non_pawn_material(pos.side_to_move()) as a precondition in step 13,
which is already in use in Futility Pruning (child node) and Null Move Pruning for similar reasons.

Pawn endgames, especially those with only 1 or 2 pawns, are simply heavily influenced by zugzwang situations.

Since we are using a bitbase for KPK endgames, I see no reason to accept buggy evals as shown in #760

Patch looks neutral at STC
LLR: 2.32 (-2.94,2.94) [-3.00,1.00]
Total: 79580 W: 10789 L: 10780 D: 58011

and LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 27071 W: 3502 L: 3390 D: 20179

Bench: 6259071

Closes #1051
Closes #760
2017-04-07 17:15:00 -07:00
VoyagerOne 35b77b120e Standardize stat penalty
STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 90631 W: 16325 L: 16323 D: 57983

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 97679 W: 12779 L: 12759 D: 72141

Bench: 6340591

Closes #1053
2017-04-07 17:02:31 -07:00
VoyagerOne ebe021f6a5 Don't update TT at excluded move ply
STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 38906 W: 7125 L: 6835 D: 24946

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 28600 W: 3752 L: 3543 D: 21305

Bench:  6861050

Closes #1048
2017-04-02 20:32:54 -07:00
VoyagerOne 30c583204f Singular extension and check extension tweak
If singular extension fails to trigger extension then don't consider check extension.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 69428 W: 12663 L: 12271 D: 44494

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 44023 W: 5875 L: 5612 D: 32536

Bench: 6170444

Closes #1043
2017-03-25 10:13:25 -07:00
VoyagerOne 352bd6f5aa Skip quiet moves based on moveCount pruning threshold and history stats
If we can moveCountPrune and next quiet move has negative stats,
then go directly to the next move stage (Bad_Captures).

Reduction formula is tweaked to compensate for the decrease in move count that is used in LMR.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 6847 W: 1276 L: 1123 D: 4448

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 48687 W: 6503 L: 6226 D: 35958

Bench: 5919519

Closes #1036
2017-03-18 15:44:49 -07:00
Joost VandeVondele c80d52c845 History stat bonus: Move condition to bonus calculation
about 0.5% speedup.

No functional change

Closes #1034
2017-03-17 14:46:47 -07:00
Marco Costalba a6d6a2c2fa Assorted code style fixes
No functional change

Closes #1029
2017-03-14 21:02:21 -07:00
snicolet c3d2e6aba9 Helper functions to count material for both sides
Syntactic sugar: helper functions to count material or pieces for both sides.

No functional change

Closes #1025
2017-03-08 18:45:38 -08:00
Joost VandeVondele d490bb9973 Always have counterMoves associated
Simplifies away all associated checks, leading to a ~0.5% speedup.
The code now explicitly checks if moves are OK, rather than using nullptr checks.

Verified for no regression:

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 32218 W: 5762 L: 5660 D: 20796

No functional change

Closes #1021
2017-03-08 18:35:23 -08:00
pb00068 cc76524c2e Further simplify skipping of plies with threads
No functional change

Closes #1020
2017-03-08 18:03:01 -08:00
VoyagerOne 3627348e2b Allow pruning advance pawn pushes if not near endgame
STC:
LLR: -2.95 (-2.94,2.94) [0.00,5.00]
Total: 101088 W: 18016 L: 17717 D: 65355

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 61194 W: 8108 L: 7791 D: 45295

Bench: 5803228

Closes #1023
2017-03-05 18:58:06 -08:00
Joost VandeVondele 1810c4d758 Simplify skipping of plies with helper threads
Replaces the HalfDensity array with an equivalent, compact implementation.
Includes suggestions by mcostalba & snicolet.

No functional change

Closes #1004
2017-02-26 16:41:58 -08:00
VoyagerOne 05cf45f2d1 Razor Simplification
Remove code that restrict using tt-moves for razoring.

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 67442 W: 12039 L: 11997 D: 43406

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 38541 W: 5044 L: 4947 D: 28550

Bench: 5667216

Closes #1002
2017-02-18 22:50:37 -08:00
VoyagerOne 83fb4547f6 search(): Move nullValue variable into local scope
No functional change

Closes #1003
2017-02-14 21:22:58 -08:00
Joona Kiiski a753e20bd4 A small tweak in doEasyMove()
Time.elapsed() > Time.optimum() * 5 / 44
instaed of:
Time.elapsed() > Time.optimum() * 5 / 42

This was yellow on STC:
LLR: -2.96 (-2.94,2.94) [0.00,4.00]
Total: 156856 W: 28317 L: 27942 D: 100597

Passed on LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 36909 W: 4926 L: 4682 D: 27301

Note: Patch was originally submitted by user GuardianRM.
However his repo was deleted before merge.

No functional change

Closes #995
2017-02-10 16:44:13 -08:00
VoyagerOne fa24cc25a4 Simplify TT penalty stat (#980)
STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 20251 W: 3692 L: 3570 D: 12989

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 16432 W: 2155 L: 2029 D: 12248

Bench: 5941174
2017-01-29 08:54:58 +01:00
VoyagerOne 5254a6040c Penalty for a quiet ttMove that fails low
Also the penalty/bonus function is misleading, we
should simply change it to stat_bonus(depth) for
bonus and -stat_bonus(depth+ ONE_PLY) for extra
penalty.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 11656 W: 2183 L: 2008 D: 7465

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 11152 W: 1531 L: 1377 D: 8244

Bench: 6101931
2017-01-28 09:32:07 +01:00
Stéphane Nicolet 9f8f093fd6 Update some comments (#973)
Use somewhat more precise comments in a couple of places.

No functional change.
2017-01-17 14:50:03 +01:00
Joost VandeVondele d8f683760c Adjust copyright headers to 2017 (#965)
No functional change.
2017-01-11 08:46:29 +01:00
lucasart 34e47ca87d Rename FromTo -> History (#963)
Previously, we had duplicated History:

- one with (piece,to) called History
- one with (from,to) called FromTo

Now that we have only one, rename it to History, which is the generally accepted
name in the chess programming litterature for this technique.

Also correct some comments that had not been updated since the introduction of CMH.

No functional change.
2017-01-10 08:47:56 +01:00
lucasart e0504ab876 Remove HistoryStats
STC:
LLR: 3.44 (-2.94,2.94) [-3.00,1.00]
Total: 120831 W: 21572 L: 21594 D: 77665

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 26565 W: 3519 L: 3406 D: 19640

bench 5920493
2017-01-09 15:50:12 +01:00
ElbertoOne d39ffbeea6 Simplified select best thread (#958)
Only select best thread if score is better and depth equal or larger.

STC (7 threads): http://tests.stockfishchess.org/tests/view/586a4d090ebc5903140c64b2
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 120297 W: 18652 L: 18682 D: 82963

LTC (7 threads): http://tests.stockfishchess.org/tests/view/586e31b30ebc5903140c663d
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 57187 W: 7035 L: 6959 D: 43193

bench: 4940355
2017-01-09 10:26:50 +01:00
pb00068 8b2c81d3ea Rejoin lines that belong to HalfDensity map (#952)
No functional change.
2017-01-05 09:00:41 +01:00
Jonathan Calovski 1052ce74f6 Tweak best thread selection logic
STC 7 threads:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 26881 W: 4161 L: 3941 D: 18779
http://tests.stockfishchess.org/tests/view/58667a830ebc5903140c632f

LTC 7 threads:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 22988 W: 2767 L: 2583 D: 17638
http://tests.stockfishchess.org/tests/view/586722690ebc5903140c636d

bench: 5468995
2017-01-01 11:28:50 +01:00
Aram Tumanian b7b9d7c9c7 Don't clear EasyMove in search()
EasyMove is cleared after every iteration of the
search if the 3rd move in the PV of the main thread
changes from the previous iteration. Therefore,
clearing EasyMove during a search iteration may be
excessive. The tests show that this is indeed unnecessary.
In the new version the EasyMove variable is used only in
the Thread::search function.

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 47719 W: 8438 L: 8362 D: 30919

LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 122841 W: 15448 L: 15457 D: 91936

bench: 5468995
2017-01-01 11:04:24 +01:00
Sergei Antonov 881a9dfb0a Threefold repetition detection
Implement a threefold repetition detection. Below are the examples of
problems fixed by this change.

    Loosing move in a drawn position.
    position fen 8/k7/3p4/p2P1p2/P2P1P2/8/8/K7 w - - 0 1 moves a1a2 a7a8 a2a1
    The old code suggested a loosing move "bestmove a8a7", the new code suggests "bestmove a8b7" leading to a draw.

    Incorrect evaluation (happened in a real game in TCEC Season 9).
    position fen 4rbkr/1q3pp1/b3pn2/7p/1pN5/1P1BBP1P/P1R2QP1/3R2K1 w - - 5 31 moves e3d4 h8h6 d4e3
    The old code evaluated it as "cp 0", the new code evaluation is around "cp -50" which is adequate.

Brings 0.5-1 ELO gain. Passes [-3.00,1.00].

STC: http://tests.stockfishchess.org/tests/view/584ece040ebc5903140c5aea
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 47744 W: 8537 L: 8461 D: 30746

LTC: http://tests.stockfishchess.org/tests/view/584f134d0ebc5903140c5b37
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 36775 W: 4739 L: 4639 D: 27397

Patch has been rewritten into current form for simplification and
logic slightly changed so that return a draw score if the position
repeats once earlier but after or at the root, or repeats twice
strictly before the root. In its original form, repetition at root
was not returned as an immediate draw.

After retestimng testing both version with SPRT[-3, 1], both passed
succesfully, but this version was chosen becuase more natural. There is
an argument about MultiPV in which an extended draw at root may be sensible.
See discussion here:

   https://github.com/official-stockfish/Stockfish/pull/925

For documentation, current version passed both at STC and LTC:

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 51562 W: 9314 L: 9245 D: 33003

LTC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 115663 W: 14904 L: 14906 D: 85853

bench: 5468995
2017-01-01 10:56:46 +01:00
Joost VandeVondele af7412e58a Explicitly use alpha+1 for beta in NonPV search (#939)
Fixes the only exception, in razoring.

The code already does assert(PvNode || (alpha == beta - 1)), and it can be verified by studying the program flow that this is indeed the case, also for the modified line.

No functional change.
2016-12-25 10:34:48 +01:00