1
0
Fork 0
Commit Graph

1533 Commits (6f997a83d6cf3a9ddf93768ae2978c37602a67f6)

Author SHA1 Message Date
Marco Costalba 6f997a83d6 Small code stye fixes
Among them restore the original rootPos name for
the starting position.

No functional change.
2015-10-17 09:29:07 +02:00
joergoster a75e45b37e Simplify altering the search depth of the helper threads
As a side-effect, the old iterative deepening loop
logic is being restored.

bench: 8116244 (after rebasing on new master)
2015-10-17 08:11:15 +02:00
mstembera 7b9e83f604 Back to @mbootsector original easy move fix which is the correct one. 2015-10-17 08:09:40 +02:00
Gary Linscott 17f96bc641 Revert "Delay waiting for threads to finish"
This reverts commit 35e649d70d.

We need to be sure all threads are finished before sending 'bestmove'.
2015-10-17 08:09:38 +02:00
Marco Costalba 47b5242930 Set the search start time much earlier
The start time is the time point we start our clock and in
an ideal case it should be set to the same clock running in
the tournament manager when it sends to the engine the 'go'
UCI command.

Currently it is set at the beginning of MainThread::think()
but this means we have not accounted for the time to wake
up the thread and the time it takes start_thinking to join()
the main thread, possibly waiting for the slave threads to finish.

In standard conditions we are talking of very few msecs, but
with high number of cores and high time pressure, it is
difficult to get a reliable estimate.

So move it much earlier, just before processing the 'go' command.

bench: 8397672
2015-10-17 08:09:36 +02:00
mstembera e854b30c84 Bug fix for MSVC Error
error C2440: cannot convert from 'double' to 'Depth'

No functional change.
2015-10-17 08:09:34 +02:00
Marco Costalba a129fa8ee3 Delay waiting for threads to finish
Wait after best move is sentm so that
waiting time is not accounted.

No functional change.
2015-10-17 08:09:33 +02:00
Ivan Ivec 06801f8dca Use a log formula for depths
The SPRT LTC test on 3 threads was like this:

LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 25653 W: 3730 L: 3521 D: 18402

The ELO STC test on 3 threads was like this:

ELO: 6.79 +-3.4 (95%) LOS: 100.0%
Total: 13716 W: 2435 L: 2167 D: 9114

The ELO STC test on 23 threads was like this:

ELO: 0.77 +-5.3 (95%) LOS: 61.1%
Total: 4970 W: 765 L: 754 D: 3451

bench: 8397672
2015-10-17 08:09:31 +02:00
Marco Costalba f6512a4092 Move EasyMove logic to its original place
And other small fixes.

No functional change.
2015-10-17 08:09:29 +02:00
Marco Costalba 309cc4fcd8 Further reformat lazy smp
No functional change.
2015-10-17 08:07:11 +02:00
Marco Costalba 9c587288da Simplify locking
Retire slavesMask. We don't need it. It si enough
'searching' and 'thinking' flags.

Further simplification is still possible, perhaps
we could use a single flag.

No functional change.
2015-10-17 08:07:09 +02:00
Marco Costalba 32d2c4e12b Move Thread::idle_loop() where it belongs
No functional change.
2015-10-17 08:07:07 +02:00
Marco Costalba caba255a1c Retire id_loop
Inline its contents instead.

No functional change.
2015-10-17 08:07:05 +02:00
Marco Costalba b01ad9ba18 Reformat lazy smp code
Just a first quick pass. Probably Skill and MultiPV
need some work too.

No functional change.
2015-10-17 08:07:03 +02:00
Marco Costalba 713604a3d4 Fix easy move
bench: 8397672
2015-10-17 08:07:01 +02:00
mbootsector 2d668a3cfc Lazy smp
Start all threads searching on root position and
use only the shared TT table as synching scheme.

It seems this scheme scales better than YBWC for
high number of threads.

Tested at very LTC (120+0.1) with 23 threads
ELO: 35.52 +-9.6 (95%) LOS: 100.0%
Total: 1109 W: 183 L: 70 D: 856

Tested at LTC with 23 threads
ELO: 34.41 +-9.9 (95%) LOS: 100.0%
Total: 1094 W: 184 L: 76 D: 834

Tested at LTC with 7 threads
ELO: 8.76 +-5.0 (95%) LOS: 100.0%
Total: 5000 W: 735 L: 609 D: 3656

Tested at STC with 7 threads
ELO: 16.76 +-5.4 (95%) LOS: 100.0%
Total: 5000 W: 899 L: 658 D: 3443

Bench: 8397672
2015-10-17 08:06:59 +02:00
VoyagerOne 8fd34d7763 Combination of two ideas:
Apply bonus for the prior CMH that caused a fail low.

Balance Stats: CMH and History bonuses are updated differently.
This eliminates the "fudge" factor weight when scoring moves. Also
eliminated discontinuity in the gravity history stat formula. (i.e. stat
scores will no longer inverse when depth exceeds 22)

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 21802 W: 4107 L: 3887 D: 13808

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 46036 W: 7046 L: 6756 D: 32234

Bench: 7677367
2015-10-12 14:00:54 -07:00
Marco Costalba ca38358574 Run PVS-STUDIO analyzer
Fix issues after a run of PVS-STUDIO analyzer.
Mainly false positives but warnings are anyhow
useful to point out not very readable code.

Noteworthy is the memset() one, where PVS prefers ss-2
instead of stack. This is because memeset() could
be optimized away by the compiler when using 'stack',
due to stack being a local variable no more used after
memset. This should normally not happen, but when
it happens it leads to very sublte and difficult
to find bug, so better to be safe than sorry.

No functional change.
2015-10-05 09:13:33 +02:00
Marco Costalba 3c0fe1d9b2 Rework lock protecting
When changing 'search' and 'splitPointsSize' we have to
use thread locks, not split point ones, because can_join()
is called under the formers.

Verified succesfully with 24 hours toruture tests with 20
cores machine by Louis Zulli: it does not hangs.

Verifyed for no regressions with STC, 7 threads:
LLR: 2.94 (-2.94,2.94) [-3.00,1.00]
Total: 52804 W: 8159 L: 8087 D: 36558

No functional change.
2015-09-30 10:47:20 +02:00
Joona Kiiski 613dc66c12 Careful SMP locking - Fix very occasional hangs
Louis Zulli reported that Stockfish suffers from very occasional hangs with his 20 cores machine.

Careful SMP debugging revealed that this was caused by "a ghost split point slave", where thread
was marked as a split point slave, but wasn't actually working on it.

The only logical explanation for this was double booking, where due to SMP race, the same thread
is booked for two different split points simultaneously.

Due to very intermittent nature of the problem, we can't say exactly how this happens.

The current handling of Thread specific variables is risky though. Volatile variables are in some
cases changed without spinlock being hold. In this case standard doesn't give us any kind of
guarantees about how the updated values are propagated to other threads.

We resolve the situation by enforcing very strict locking rules:
- Values for key thread variables (splitPointsSize, activeSplitPoint, searching)
can only be changed when the thread specific spinlock is held.
- Structural changes for splitPoints[] are only allowed when the thread specific spinlock is held.
- Thread booking decisions (per split point) can only be done when the thread specific spinlock is held.

With these changes hangs didn't occur anymore during 2 days torture testing on Zulli's machine.

We probably have a slight performance penalty in SMP mode due to more locking.

STC (7 threads):
ELO: -1.00 +-2.2 (95%) LOS: 18.4%
Total: 30000 W: 4538 L: 4624 D: 20838

However stability is worth more than 1-2 ELO points in this case.

No functional change

Resolves #422
2015-09-10 19:15:43 +01:00
gguliash 84a641b8bb A small code simplification
No functional change

Resolves #411
2015-08-30 19:58:32 +01:00
lucasart 7ad85fca6d Prune castling moves
Align the behaviour with reductions. Initially castling moves had to be
treated differently, because the SEE did not handle them correctly. But now it
does.

STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 83750 W: 15722 L: 15711 D: 52317

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 97183 W: 15120 L: 15115 D: 66948

bench 7759837

Resolves #403
2015-08-28 20:33:12 +01:00
lucasart c052e03426 Retire dangerous flag
Replace by its value where it is used. Code is more clear that
way.

No functional change.

Resolves #402
2015-08-20 20:18:23 +01:00
Marco Costalba 68d61b80c6 Simplify IID depth formula
Restore original formula messed up during
half-ply removal.

STC
LLR: 4.11 (-2.94,2.94) [-3.00,1.00]
Total: 21349 W: 4091 L: 3909 D: 13349

LTC
LLR: 5.42 (-2.94,2.94) [-3.00,1.00]
Total: 52819 W: 8321 L: 8122 D: 36376

bench: 8040572
2015-07-30 09:54:25 +02:00
VoyagerOne a2410227cc PV refutation penalty
Extra penalty for PV move in previous ply when it gets refuted.

STC:
LLR: 4.49 (-2.94,2.94) [-1.50,4.50]
Total: 41094 W: 7889 L: 7620 D: 25585

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,6.00]
Total: 12304 W: 1967 L: 1811 D: 8526

Bench: 8373608

Resolves #386
2015-07-30 00:51:49 +08:00
Marco Costalba 42b77ea7ee Tidy up in movepick.cpp
Some formattng after recent changes.

No functional change.
2015-07-19 12:38:33 +02:00
Marco Costalba 4095ff0ee5 Fix formatting of previous patch
No functional change.
2015-07-16 08:17:40 +02:00
VoyagerOne 1d977aa79e LMR Simplification: Remove countermove condition
Removed countermove condition for decreasing reduction.

LTC:
LLR: 3.01 (-2.94,2.94) [-3.00,1.00]
Total: 32410 W: 5092 L: 4986 D: 22332

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 24450 W: 4632 L: 4517 D: 15301

Bench: 6943812

Resolves #378
2015-07-15 20:21:14 +01:00
Marco Costalba b2edac7075 Remove useless razoring condition
STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 20626 W: 3977 L: 3855 D: 12794

LTC:
LLR: 3.10 (-2.94,2.94) [-3.00,1.00]
Total: 87334 W: 13675 L: 13648 D: 60011

Retire also the now unused pawn_on_7th() helper.

bench: 8248166
2015-07-09 08:13:30 +02:00
VoyagerOne aa0dc16b75 CMH Fix: Exclude captures for TT move refutation penalty
This will make sure we store only quiet moves for TT Penalty.

STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 34748 W: 6617 L: 6420 D: 21711

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 19975 W: 3259 L: 3137 D: 13579

Bench: 8063826

Resolves #373
2015-07-04 14:22:41 +01:00
VoyagerOne 7e9f776fca LMR Tweak: Decrease reduction if cmh>0 && history>0.
STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 9627 W: 1879 L: 1748 D: 6000

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,6.00]
Total: 21543 W: 3433 L: 3234 D: 14876

Bench: 8646407

Resolves #370 #371
2015-06-27 09:45:59 +01:00
Marco Costalba 3f1bc9e013 Fix compile on icc
Error is:

  a value of type "int" cannot be assigned to an entity of type "Value"

Also retire the now unused squares_of_color() function.

No functional change.
2015-06-25 05:29:56 +02:00
Vince Negri 7b8ffe0f5d Remove intermediate re-search in LMR
STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 20149 W: 3830 L: 3707 D: 12612

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 45384 W: 7089 L: 7006 D: 31289

Bench: 8110365

Resolves #361
2015-06-05 21:03:10 +01:00
Stefan Geschwentner e14046517e Remove Gain Stats
Additionally in futility pruning the margin is raised for compensation.

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 48481 W: 9229 L: 9156 D: 30096

LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 32058 W: 5134 L: 5031 D: 21893

Bench: 8098149

Resolves #350
2015-05-18 13:59:30 -07:00
Marco Costalba ee0371f86e Cleanup work in misc.cpp
Also some code style tidy up of latest patches.

Also renamed checkSq -> checkSquares because it
is a bitboard and not a square.

No functional change.
2015-05-10 09:42:26 +02:00
lucasart 2e86d1febc Restore deterministic search state
Introduce helper function Search::reset() which clears all kind of search
memory, in order to restore a deterministic search state.

Generalize TT.clear() into Search::reset() for the following use cases:
- bench: needed to guarantee deterministic bench (ie. if you call bench from
interactive command line twice in a row you get the same value).
- Clear Hash: restore clean search state, which is the purpose of this button.
- ucinewgame: ditto.

No functional change.

Resolves #346
2015-05-07 14:20:32 -07:00
lucasart 946fa47625 Never clear stats
Based on an idea and patch by VoyagerOne.

Small simplification, but was tedted for an ELO gain anyway.

STC:
LLR: 2.95 (-2.94,2.94) [-1.00,4.00]
Total: 5375 W: 1119 L: 977 D: 3279

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 17893 W: 2984 L: 2792 D: 12117

bench 8322847
2015-05-06 19:17:33 +08:00
Marco Costalba 578b21bbee Split PSQT init from Position init
Easier for tuning psq tables:

TUNE(myParameters, PSQT::init);

Also move PSQT code in a new *.cpp file, and retire the
old and hacky psqtab.h that required to be included only
once to work correctly, this is not idiomatic for a header
file.

Give wide visibility to psq tables (previously visible only
in position.cpp), this will easy the use of psq tables outside
Position, for instance in move ordering.

Finally trivial code style fixes of the latest patches.

Original patch of Lucas Braesch.

No functional change.
2015-05-03 20:07:15 +02:00
VoyagerOne b7063ef65b Change extra ply LMR condition to: cmh <= 0 && hist < 0
Extra ply LMR condition is now cmh <= 0 && h < 0
Instead of cmh + h < 0

STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 55210 W: 10812 L: 10557 D: 33841

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 13212 W: 2239 L: 2045 D: 8928

Bench: 8420865

Resolves #339
2015-04-26 20:12:25 +01:00
lucasart 6c040c821a Retire FORCE_INLINE
No speed regression on my machine (i7-3770k, gcc 4.9.1, linux 3.16):

        stat        test     master   diff
        mean   2,482,415  2,474,987  7,906
        stdev      4,603      5,644  2,497

        speedup        0.32%
        P(speedup>0)  100.0%

Fishtest 9+0.03:

ELO: 0.26 +-1.8 (95%) LOS: 61.2%
Total: 60000 W: 12437 L: 12392 D: 35171

No functional change.

Resolves #334
2015-04-15 21:21:45 +01:00
VoyagerOne 20e92895af Removed extra condition (history < 0) in LMR to help sync up with move ordering.
LMR condition is now cmh+history<0
Instead of history<0 OR cmh+history<0

STC:
LLR: 2.96 (-2.94,2.94) [-3.00, 1.00]
Total: 26446 W: 5092 L: 4980 D: 16374

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00, 1.00]
Total: 14129 W: 2340 L: 2209 D: 9580

Bench: 7815183

Resolves #331
2015-04-12 20:05:59 +01:00
Marco Costalba fb03188fc7 Assorted cleanup of last patches
No functional change.
2015-04-11 23:24:43 +02:00
Stefan Geschwentner 27efc5ac99 Update stats at pv nodes
If a quiet best move is found at a pv node then always update stats.

STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 41485 W: 8047 L: 7830 D: 25608

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,6.00]
Total: 14351 W: 2420 L: 2250 D: 9681

Bench: 6985247

Resolves #330
2015-04-10 20:34:55 +01:00
Stefan Geschwentner ef4d89c9bd update stats also in check
Update stats also if in check (drop condition).

STC:
LLR: 3.22 (-2.94,2.94) [-3.00,1.00]
Total: 87472 W: 16929 L: 16913 D: 53630

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 39971 W: 6436 L: 6345 D: 27190

Bench: 7086031

Resolves #327
2015-04-09 20:41:08 +01:00
lucasart aaf17326e2 Prune evasions when we can castle
A minor simplification.

STC:

LLR: 2.95 (-2.94,2.94) [-3.50,0.50]
Total: 67877 W: 12882 L: 12904 D: 42091

STC:

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 20677 W: 4023 L: 3901 D: 12753

LTC:

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 12221 W: 2022 L: 1888 D: 8311

Bench: 7911336

Resolves #326
2015-04-09 20:34:06 +01:00
Marco Costalba 926f215061 Add support for playing in 'nodes as time' mode
When running more games in parallel, or simply when running a game
with a background process, due to how OS scheduling works, there is no
guarantee that the CPU resources allocated evenly between the two
players. This introduces noise in the result that leads to unreliable
result and in the worst cases can even invalidate the result. For
instance in SF test framework we avoid running from clouds virtual
machines because are a known source of very unstable CPU speed.

To overcome this issue, without requiring changes to the GUI, the idea
is to use searched nodes instead of time, and to convert time to
available nodes upfront, at the beginning of the game.

When nodestime UCI option is set at a given nodes per milliseconds
(npmsec), at the beginning of the game (and only once), the engine
reads the available time to think, sent by the GUI with 'go wtime x'
UCI command. Then it translates time in available nodes (nodes =
npmsec * x), then feeds available nodes instead of time to the time
management logic and starts the search. During the search the engine
checks the searched nodes against the available ones in such a way
that all the time management logic still fully applies, and the game
mimics a real one played on real time. When the search finishes,
before returning best move, the total available nodes are updated,
subtracting the real searched nodes. After the first move, the time
information sent by the GUI is ignored, and the engine fully relies on
the updated total available nodes to feed time management.

To avoid time losses, the speed of the engine (npms) must be set to a
value lower than real speed so that if the real TC is for instance 30
secs, and npms is half of the real speed, the game will last on
average 15 secs, so much less than the TC limit, providing for a
safety 'time buffer'.

There are 2 main limitations with this mode.

1. Engine speed should be the same for both players, and this limits
the approach to mainly parameter tuning patches.

2. Because npms is fixed while, in real engines, the speed increases
toward endgame, this introduces an artifact that is equivalent to an
altered time management. Namely it is like the time management gives
less available time than what should be in standard case.

May be the second limitation could be mitigated in a future with a
smarter 'dynamic npms' approach.

Tests shows that the standard deviation of the results with 'nodestime'
is lower than in standard TC, as is expected because now all the introduced
noise due the random speed variability of the engines during the game is
fully removed.

Original NIT idea by Michael Hoffman that shows how to play in NIT mode
without requiring changes to the GUI. This implementation goes a bit
further, the key difference is that we read TC from GUI only once upfront
instead of re-reading after every move as in Michael's implementation.

No functional change.
2015-04-03 04:40:55 +02:00
Marco Costalba df722521ba Rename of TimeMgr and friends
More natural naming IMO.

No functional change.
2015-04-03 04:19:29 +02:00
Marco Costalba 5d1b92e8f9 Introduce elapsed_time()
And reformat a bit time manager code.

Note that now we set starting search time in think() and
no more in ThreadPool::start_thinking(), the added delay
is less than 1 msec, so below timer resolution (5msec) and
should not affect time lossses ratio.

No functional change.
2015-04-03 04:19:26 +02:00
mstembera 6661a31541 Simplification to use only one counter move.
STC http://tests.stockfishchess.org/tests/view/5518dca30ebc5902160ec5d0
LLR: 2.95 (-2.94,2.94) [-3.50,0.50]
Total: 18868 W: 3638 L: 3530 D: 11700

LTC http://tests.stockfishchess.org/tests/view/5518f7ed0ebc5902160ec5d4
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 69767 W: 11019 L: 10973 D: 47775

Extracted from http://tests.stockfishchess.org/tests/view/5511028a0ebc5902160ec40b

Original patch by hxim.  All credit goes to him.

Bench: 7664249

Resolves #320
2015-04-03 01:16:15 +08:00
Marco Costalba 6c42575208 Assorted code style of latest commits
No functional chnage.
2015-03-29 10:16:10 +02:00