1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00
Commit graph

4527 commits

Author SHA1 Message Date
Joost VandeVondele
ac43bef5c5 [Cluster] Improve message passing part.
This rewrites in part the message passing part, using in place gather, and collecting, rather than merging, the data of all threads.

neutral with a single thread per rank:
Score of new-2mpi-1t vs old-2mpi-1t: 789 - 787 - 2615  [0.500] 4191
Elo difference: 0.17 +/- 6.44

likely progress with multiple threads per rank:
Score of new-2mpi-36t vs old-2mpi-36t: 76 - 53 - 471  [0.519] 600
Elo difference: 13.32 +/- 12.85
2019-01-02 11:16:24 +01:00
Joost VandeVondele
7a32d26d5f [cluster] keep track of TB hits cluster-wide. 2018-12-29 15:34:57 +01:00
Joost VandeVondele
fb5c1f5bf5 Fix comment 2018-12-29 15:34:57 +01:00
Joost VandeVondele
87f0fa55a0 [cluster] keep track of node counts cluster-wide.
This generalizes exchange of signals between the ranks using a non-blocking all-reduce. It is now used for the stop signal and the node count, but should be easily generalizable (TB hits, and ponder still missing). It avoids having long-lived outstanding non-blocking collectives (removes an early posted Ibarrier). A bit too short a test, but not worse than before:

Score of new-r4-1t vs old-r4-1t: 459 - 401 - 1505  [0.512] 2365
Elo difference: 8.52 +/- 8.43
2018-12-29 15:34:57 +01:00
Joost VandeVondele
2f882309d5 fixup 2018-12-29 15:34:57 +01:00
Joost VandeVondele
86953b9392 [cluster] Fix non-mpi compile
fix compile of the cluster branch in the non-mpi case.

Add a TODO as a reminder for the new voting scheme.

No functional changes
2018-12-29 15:34:56 +01:00
Joost VandeVondele
ba1c639836 [cluster] fill sendbuffer better
use a counter to track available elements.

Some elo gain, on 4 ranks:

Score of old-r4-1t vs new-r4-1t: 422 - 508 - 1694  [0.484] 2624
Elo difference: -11.39 +/- 7.90
2018-12-29 15:34:56 +01:00
Joost VandeVondele
e526c5aa52 [cluster] Make bench compatible
Fix one TODO.

Takes care of output from bench.
Sum nodes over ranks.
2018-12-29 15:34:56 +01:00
Joost VandeVondele
9cd2c817db Add one more TODO 2018-12-29 15:34:56 +01:00
Joost VandeVondele
54a0a228f6 [cluster] Some formatting cleanup
standarize whitespace a bit.
Also adds two TODOs for follow up work.

No functional change.
2018-12-29 15:34:56 +01:00
Joost VandeVondele
1cd2c7861a [cluster] avoid creating MPI data type.
there is no need to make an MPI data type for the sendbuffer, simpler and faster.

No functional change
2018-12-29 15:34:56 +01:00
Joost VandeVondele
7af3f4da7a [cluster] Avoid TT saving our own TT entries.
avoid saving to TT the part of the receive buffer that actually originates from the same rank.

Now, on 1 mpi rank, we have the same bench as the non-mpi code on 1 thread.
2018-12-29 15:34:56 +01:00
Joost VandeVondele
271181bb31 [cluster] Add depth condition to cluster TT saves.
since the logic for saving moves in the sendbuffer and the associated rehashing is expensive, only do it for TT stores of sufficient depth.

quite some gain in local testing with 4 ranks against the previous version.
Elo difference: 288.84 +/- 21.98

This starts to make the branch useful, but for on-node runs, difference remains to the standard threading.
2018-12-29 15:34:56 +01:00
noobpwnftw
66b2c6b9f1 Implement best move voting system for cluster
This implements the cluster version of d96c1c32a2
2018-12-29 15:34:56 +01:00
Joost VandeVondele
2559c20c6e [cluster] Fix oversight in TT key reuse
In the original code, the position key stored in the TT is used to probe&store TT entries after message passing. Since we only store part of the bits in the TT, this leads to incorrect rehashing. This is fixed in this patch storing also the full key in the send buffers, and using that for hashing after message arrival.

Short testing with 4 ranks (old vs new) shows this is effective:
Score of mpiold vs mpinew: 84 - 275 - 265  [0.347] 624
Elo difference: -109.87 +/- 20.88
2018-12-29 15:34:55 +01:00
Joost VandeVondele
2659c407c4 Fix segfault.
the wrong data type was passed to an MPI call, leading to occasional segfaults. This patch fixes this.

No functional change.
2018-12-29 15:34:55 +01:00
noobpwnftw
3730ae1efb Small simplifications and code cleanup
Non-functional simplifications.
2018-12-29 15:34:55 +01:00
noobpwnftw
0d6cdc0c6d Implement yielding loop while waiting for input
Some MPI implementations use busy-wait pooling, which will turn MPI_Bcast into busy-wait loop, workaround with our own yielding loop.
2018-12-29 15:34:55 +01:00
noobpwnftw
80afeb0d3b Fix consistency between PV and bestmove output
In case that a non-root mainThread on a node is the new best thread in the cluster, it should always output its PV.
2018-12-29 15:34:55 +01:00
noobpwnftw
2405b38165 Fix search result aggregation
This reverts my earlier change that only the root node gets to output best move after fixing problem with MPI_Allreduce by our custom operator(BestMoveOp). This function is not commutable and we must ensure that its output is consistent among all nodes.
2018-12-29 15:34:55 +01:00
noobpwnftw
8a95d269eb Implement proper stop signalling from root node
Previous behavior was to wait on all nodes to finish their search on their own TM and aggregate to root node via a blocking MPI_Allreduce call. This seems to be problematic.

In this commit a proper non-blocking signalling barrier was implemented to use TM from root node to control the cluster search, and disable TM on all non-root nodes.

Also includes some cosmetic fix to the nodes/NPS display.
2018-12-29 15:34:55 +01:00
noobpwnftw
3b7b632aa5 Fix a bug of outputting multiple lines of bestmove 2018-12-29 15:34:55 +01:00
Omri Mor
29c166a072 MPI/Cluster implementation for Stockfish
Based on Peter Österlund's "Lazy Cluster" algorithm,
but with some simplifications.
To compile, point COMPCXX to the MPI C++ compiler wrapper (mpicxx).
2018-12-29 15:34:55 +01:00
erbsenzaehler
800031c94c Improve the Readme
I tried to improve the Readme because many people in my local
chess club do not understand some of the UCO options properly.
Starting point of this was Cfish's Readme by Ronald de Man,
some internet resources and the Stockfish code itself.

Closes https://github.com/official-stockfish/Stockfish/pull/1898

Initial commit by user @erbsenzaehler, with help from users
Adrian Petrescu, @alayan-stk-2 and Elvin Liu.

No functional change

Co-Authored-By: Alayan-stk-2 <alayan-stk-2@users.noreply.github.com>
Co-Authored-By: Adrian Petrescu <apetresc@gmail.com>
Co-Authored-By: Elvin Liu <solarlight2@users.noreply.github.com>
2018-12-29 11:49:16 +01:00
31m059
69dc5568b3 Always initialize and evaluate king safety
Recent tests by @xoto10, @Vizvezdenec, and myself seemed to hint that Elo could
be gained by expanding the number of cases where king safety is applied. Several
users (@Spliffjiffer, @Vizvezdenec) have anticipated benefits specifically in
evaluation of tactics. It appears that we actually do not need to restrict the
cases in which we initialize and evaluate king safety at all: initializing and
evaluating it in every position appears roughly Elo-neutral at STC and possibly
a substantial Elo gain at LTC.

Any explanation for this scaling is, at this point, conjecture. Assuming it is
not due to chance, my hypothesis is that initialization of king safety in all
positions is a mild slowdown, offset by an Elo gain of evaluating king safety
in all positions. At STC this produces Elo gains and losses that offset each
other, while at longer time control the slowdown is much less important, leaving
only the Elo gain. It probably helps SF to explore king attacks much earlier in
search with high numbers of enemy pieces concentrating but not essentially attacking
king ring.

Thanks to @xoto10 and @Vizvezdenec for helping run my LTC!

Closes https://github.com/official-stockfish/Stockfish/pull/1906

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 35432 W: 7815 L: 7721 D: 19896
http://tests.stockfishchess.org/tests/view/5c24779d0ebc5902ba131b26

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 12887 W: 2217 L: 2084 D: 8586
http://tests.stockfishchess.org/tests/view/5c25049a0ebc5902ba132586

Bench: 3163951

------------------

How to continue from there?

* Next step will be to tune all the king danger terms once more after that :-)
2018-12-27 21:38:31 +01:00
noobpwnftw
14c4a40dc7 Simplify SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX loop (#1892)
When iterating through 'SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX' structure, do not use structure member beyond known size.

API is guaranteed to provide us at lease one element upon successful, and no element in the structure can have a zero size.

No functional change.
2018-12-24 11:24:29 +01:00
noobpwnftw
0194da0d80 Fix crash in best_group() (#1891)
This pull request fixes a rare crashing bug on Windows inside our NUMA code, first
reported by Dann Corbit in the following forum thread (thanks!):
https://groups.google.com/forum/?fromgroups=#!topic/fishcooking/gA6aoMEuOwg

The fix is to not use structure member beyond known size when iterating through
'SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX' structure. We note that the Microsoft
API is guaranteed to provide us at least one element upon successful, and no
element in the structure can have a zero size.

No functional change.
2018-12-24 11:20:14 +01:00
Joost VandeVondele
ade87ff8d3 Extend stack to ss-5, and remove conditions
The `&& (ss-1)->killers[0] ` conditions are there seemingly to protect
accessing ss-5.

This is unneeded and not so intuitive (as the killer is checked for equality
with currentMove, and that one is non-zero once we're high enough in the stack,
this protects access to ss-5). We can just extend the stack from ss-4 to ss-5,
so we can call update_continuation_histories(ss-1, ..) always in search.

This goes a bit further than #1881 and addresses a comment in #1878.

passed STC:
http://tests.stockfishchess.org/tests/view/5c1aa8d50ebc5902ba127ad0
LLR: 3.12 (-2.94,2.94) [-3.00,1.00]
Total: 53515 W: 11734 L: 11666 D: 30115

passed LTC:
http://tests.stockfishchess.org/tests/view/5c1b272c0ebc5902ba12858d
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 140176 W: 23123 L: 23192 D: 93861

Bench: 3451321
2018-12-24 11:06:47 +01:00
protonspring
96ac85b319 Improve endgame KBN vs K (#1877)
Even when playing without endgame table bases, this particular endgame should
be a win 100% of the time when Stockfish is given a KRBK position, assuming
there are enough moves remaining in the FEN to finish the game without hitting
the 50 move rule.

PROBLEM: The issue with master here is that the PushClose difference per square
is 20, however, the difference in squares for the PushToCorners array is usually
less. Thus, the engine prefers to move the kings closer together rather than pushing
the weak king to the correct corner.

What happens is if the weak king is in a safe corner, SF still prefers pushing the
kings together. Occasionally, the strong king traps the weak king in the safe corner.
It takes a while for SF to figure it out, but often draws the game by the 50 move rule
(on shorter time controls).

This patch increases the PushToCorners values to correct this problem. We also added
an assert to catch any overflow problem if anybody would want to increase the array
values again in the future.

It was tested in a couple of matches starting with random KRBK positions and showed
increased winning rates, see https://github.com/official-stockfish/Stockfish/pull/1877

No functional change
2018-12-24 10:44:38 +01:00
erbsenzaehler
2089c414da Update our continuous integration machinery (#1889)
* Update our continuous integration machinery

Ubuntu 16.04 can now be used with travis. Updating all the other stuff
when there.
Invoking the lld linker seems to save 5 minutes with clang on linux.

No functional change.

* fix
2018-12-23 18:17:44 +01:00
mstembera
656aad8b0c Use a bit less code to calculate hashfull() (#1830)
* Use a bit less code to calculate hashfull(). Change post increment to preincrement as is more standard
in the rest of stockfish.  Scale result so we report 100% instead of 99.9% when completely full.

No functional change.
2018-12-23 16:10:07 +01:00
mstembera
ae5d2c38e1 Turn on random access for Syzygy files in Windows (#1840)
* This is the Windows version of
https://github.com/official-stockfish/Stockfish/pull/1829

No functional change.
2018-12-23 16:09:03 +01:00
protonspring
59d32f8edd Simplify generate_castling (#1885)
Although this is a compile-time constant, we stick the castlingSide into a CastlingRight, then pull it out again. This seems unecessarily complex.

No functional change.
2018-12-23 16:05:24 +01:00
protonspring
b54bcfddaa Simplify KBNK endgame implementation
We do not need to change the winnerKSq variable, so we can simplify
a little bit the logic of the code by changing only the loserKSq
variable when it is necessary. Also consolidate and clarify comments.

See the pull request thread for a proof that the code is correct:
https://github.com/official-stockfish/Stockfish/pull/1854

No functional change
2018-12-20 10:47:18 +01:00
Guenther Demetz
0f2df4e4af Tweak main killer penalty
Apply refuted main killer penalty also on early TT cut-offs. This
makes penalty logic more consistent with the logic at normal search.

Failed STC:
http://tests.stockfishchess.org/tests/view/5c121e730ebc5902ba11aad8
LLR: -2.95 (-2.94,2.94) [0.00,5.00]
Total: 72193 W: 15848 L: 15625 D: 40720 Elo +1.07

Passed LTC:
http://tests.stockfishchess.org/tests/view/5c17b1b10ebc5902ba123c24
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 35073 W: 5886 L: 5625 D: 23562 Elo +2.59

Closes https://github.com/official-stockfish/Stockfish/pull/1878

bench: 3393939
2018-12-18 09:38:06 +01:00
mstembera
67ae53b020 New voting formula for threads
We now use a quadratic formula during the vote for threads
when deciding on which thread to pick a move from.

time control 5+0.05, with 8 threads:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 20202 W: 4031 L: 3813 D: 12358
http://tests.stockfishchess.org/tests/view/5c16c8e60ebc5902ba1223e2

time control 20+0.2, with 8 threads:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 14330 W: 2290 L: 2115 D: 9925
http://tests.stockfishchess.org/tests/view/5c16efca0ebc5902ba122993

20000 games match at time control 5+0.05, with 31 threads:
ELO: 5.63 +-2.8 (95%) LOS: 100.0%
Total: 20000 W: 3539 L: 3215 D: 13246
http://tests.stockfishchess.org/tests/view/5c16f07a0ebc5902ba122a20

Closes https://github.com/official-stockfish/Stockfish/pull/1876

No functional change (in simple thread mode)
2018-12-18 08:51:25 +01:00
31m059
7240a90bf9 Use stronglyProtected
~stronglyProtected is quite similar to ~attackedBy[Them][PAWN] & ~attackedBy2[Them],
the only difference appears to be that the former includes squares attacked twice
by both sides. The resulting logic is simpler, and the change appears to be at least
Elo-neutral at both STC and LTC.

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 35924 W: 7978 L: 7885 D: 20061
http://tests.stockfishchess.org/tests/view/5c14a5c00ebc5902ba11ed72

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 37078 W: 6125 L: 6030 D: 24923
http://tests.stockfishchess.org/tests/view/5c14ae880ebc5902ba11eed8

Bench: 3646542
2018-12-16 10:04:49 +01:00
Alain SAVARD
64a6138d37 Refactor king ring calculation
Compute the "double protection by pawns" expression only once
in initialize(), instead of once for each piece in the piece loop.

Passed STC
http://tests.stockfishchess.org/tests/view/5c1506380ebc5902ba11f3b4
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 9494 W: 2191 L: 2045 D: 5258

Inspired by Nick Pelling's test
   http://tests.stockfishchess.org/tests/view/5c144d110ebc5902ba11e4af
and an older test of mine
   http://tests.stockfishchess.org/tests/view/5c0402810ebc5902bcee1fc8

Non functional change.
2018-12-16 09:57:43 +01:00
Joost VandeVondele
4e2bb8fa44 Fix a segfault.
this patch fixes a rare but reproducible segfault observed playing a
multi-threaded match, it is discussed somewhat in fishcooking.

From the core file, it could be observed that the issue was in qsearch, namely:

````
   ss->pv[0] = MOVE_NONE;
````

and the backtrace shows the it arrives there via razoring, called from the rootNode:

````
    (gdb) bt
    alpha=-19, beta=682, depth=DEPTH_ZERO) at search.cpp:1247
````

Indeed, ss->pv can indeed by a nullptr at the rootNode. However, why is the
segfault so rare ?

The reason is that the condition that guards razoring:

````
   (depth < 2 * ONE_PLY &&  eval <= alpha - RazorMargin)
````

is almost never true, since at the root alpha for depth < 5 is -VALUE_INFINITE.

Nevertheless with the new failHigh scheme, this is not guaranteed, and rootDepth > 5,
can still result in a depth < 2 search at the rootNode. If now another thread,
via the hash, writes a new low eval to the rootPos qsearch can be entered.
Rare but not unseen... I assume that some of the crashes in fishtest recently
might be due to this.

Closes https://github.com/official-stockfish/Stockfish/pull/1860

No functional change
2018-12-16 09:53:11 +01:00
Joost VandeVondele
fda0161e3a Start a TT resize only after search finished.
As noticed in the forum, a crash in extract_ponder_from_tt could result
if hash size is set before the ponder move is printed. While it is arguably
a GUI issue (but it got me on the cli), it is easy to avoid this issue.

Closes https://github.com/official-stockfish/Stockfish/pull/1856

No functional change.
2018-12-16 09:41:09 +01:00
31m059
4f3804f3f3 Remove Null Move Pruning material threshold
On November 30th, @xoto10 experimented with removing this threshold,
but the simplification barely failed LTC. I was inspired to try various
[0, 4] tweaks to increase its value, which would narrow the effects of
this threshold without removing it entirely. Various values repeatedly
led to Elo gains at both STC and LTC, most of which were insufficient
to pass.

After a couple of weeks, I tried again to find an Elo-gaining tweak
but noticed that I could raise the threshold higher and higher without
regression. I decided to try removing it entirely--forgetting that
@xoto10 had already attempted this. However, this now performs much
better at both STC and LTC, producing a STC Elo gain and also potentially
a smaller LTC one.

The reason appears to be a recent change in master (e8ffca3) near
this code, which interacts with this patch. This simplification
governs the conditions under which that patch's effects are applied.
Something non-obvious about that change has significantly improved
the performance of this simplification.

I recognize and thank @xoto10, who originally had this idea. Since
I ran several LTCs recently (to determine whether to open this PR,
or one for a related [0, 4]), I would also like to acknowledge the
other developers and CPU donors for their patience. Thank you all!

STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 13445 W: 3000 L: 2862 D: 7583
http://tests.stockfishchess.org/tests/view/5c11f01b0ebc5902ba11a6b8

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 33868 W: 5663 L: 5563 D: 22642
http://tests.stockfishchess.org/tests/view/5c11ffe90ebc5902ba11a8a9

Closes https://github.com/official-stockfish/Stockfish/pull/1870

Bench: 3343286
2018-12-16 09:32:37 +01:00
SFisGOD
31ac538f96 A combo of parameter tweaks
Joint work by SFisGOD, xoroshiro and Chess13234.

This combo consists of the following tweaks:
Assorted bonuses and penalties by SFisGOD
Bishop and Rook PSQT by SFisGOD
Tempo Value by xoroshiro
Futility pruning by Chess13234

STC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 9005 W: 2082 L: 1882 D: 5041
http://tests.stockfishchess.org/tests/view/5c11628c0ebc5902ba119e90

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 44207 W: 7451 L: 7157 D: 29599
http://tests.stockfishchess.org/tests/view/5c1172a40ebc5902ba119fa3

Bench: 3332460
2018-12-13 13:35:35 +01:00
Kurt
883367d217 Asymmetrical 8x8 Pawn PSQT
STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 13323 W: 3015 L: 2818 D: 7490
http://tests.stockfishchess.org/tests/view/5c00a2520ebc5902bcedd41b

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 52294 W: 9093 L: 8756 D:34445
http://tests.stockfishchess.org/tests/view/5c00b2c40ebc5902bcedd596

Some obvious followups to this are to further tune this PSQT, or
try 8x8 for other pieces. As of now I don't plan on trying this
for other pieces as I think the majority of the ELO it brings is
for pawns and kings.

Looking at the new values, the differences between kingside and
queenside are quite significant. I am very hopeful that this a
llows SF to understand and plan pawn structures even better than
it already does. Cheers!

Closes https://github.com/official-stockfish/Stockfish/pull/1839

Bench: 3569243
2018-12-13 13:20:31 +01:00
protonspring
e917bd59b1 Changes identified in RENAME/REFORMATTING thread (#1861)
I've gone through the RENAME/REFORMATTING thread and changed everything I could find, plus a few more. With this, let's close the previous issue and open another.

No functional change.
2018-12-11 13:47:56 +01:00
VoyagerOne
e8ffca3eb4 Tweak CMH pruning
STC: (yellow)
LLR: -2.94 (-2.94,2.94) [0.00,5.00]
Total: 48919 W: 10625 L: 10517 D: 27777
http://tests.stockfishchess.org/tests/view/5c07e6a20ebc5902bcee7395

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 50360 W: 8424 L: 8102 D: 33834
http://tests.stockfishchess.org/tests/view/5c0812450ebc5902bcee76f4

Bench: 3775064
2018-12-09 13:11:13 +01:00
protonspring
4e2e4759a1 remove extra line. 2018-12-09 12:59:57 +01:00
protonspring
a8e903c33a remove parenthesis. 2018-12-09 12:59:57 +01:00
protonspring
090e49547e add paren. 2018-12-09 12:59:57 +01:00
protonspring
fefc0c6789 simplify opposite_colors 2018-12-09 12:59:57 +01:00
Stéphane Nicolet
5c2fbcd09b Revert "pseudo_legal() and MOVE_NONE"
This reverts commit 33d9548218 ,
which crashed in DEBUG mode because of the following assert in position.h

````
Assertion failed: (is_ok(m)), function capture, file ./position.h, line 369.
````

No functional change
2018-12-06 15:04:04 +01:00