Marco Costalba [Sat, 18 Feb 2012 09:57:00 +0000 (10:57 +0100)]
Small renaming in Thread struct
Should be a bit more clear the meaning of the
single variables.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 17 Feb 2012 19:38:17 +0000 (20:38 +0100)]
Fix a race when extracting PV from TT
Because TT table is shared tte->move() could change
under our feet, in particular we could validate
tte->move() then the move is changed by another
thread and we call pos.do_move() with a move different
from the original validated one !
This leads to a very rare but reproducible crash once
every about 20K games.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 18 Feb 2012 09:16:01 +0000 (10:16 +0100)]
Increase MAX_PLY from 100 to 256
There is no need to limit the maximum ply searched to
100, with deep exclusion search extensions we could
reach it even with much smaller search depths.
The only drawback is an increase in stack usage, but
is limited mainly to id_loop(), in particular the
recursive search() functions are not affected.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 13 Feb 2012 08:52:58 +0000 (09:52 +0100)]
Micro-optimize pop_1st_bit() for 32 bits
Small perft speed-up of 2% and also a code
simplification.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 12 Feb 2012 15:02:13 +0000 (16:02 +0100)]
Templetize sliding attacks
No functional change and no speed regression, it seems
to be even a bit faster on MSVC and gcc.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 12 Feb 2012 14:12:01 +0000 (15:12 +0100)]
Speedup sliders attacks for 32bit CPU
Replace a 64 bit 'and' by two 32 bits ones and
use unsigned instead of int.
This simple patch increases perft speed of 6% on
my Intel Core 2 Duo !
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 12 Feb 2012 13:07:21 +0000 (14:07 +0100)]
Don't wake up threads at the beginning of the search
But only when needed, after a split point. This behaviour
does not apply when useSleepingThreads is false, becuase
in this case threads are not woken up at split points so
must be already running.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 12 Feb 2012 08:59:19 +0000 (09:59 +0100)]
Don't reset 50-move counter after castling
Rule says should be reset only after a capture and/or
a pawn move.
This incredible bug was here since Glaurung times !
Spotted by Kiriakos.
No functional change in the test bench because we
don't reach the 50 moves limits.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
mcostalba [Mon, 6 Feb 2012 05:34:32 +0000 (21:34 -0800)]
Merge pull request #3 from glinscott/
b46bf29
Detect stalemate in evaluation
Gary Linscott [Sun, 5 Feb 2012 19:52:01 +0000 (14:52 -0500)]
Simpler stalemate check.
Gary Linscott [Sun, 5 Feb 2012 15:24:53 +0000 (10:24 -0500)]
Detect stalemate in KXK endgames
Also, handle cases where there are 2 bishops of the same color.
Marco Costalba [Sat, 4 Feb 2012 09:41:09 +0000 (10:41 +0100)]
Add "Slow Mover" UCI parameter to adjust time management
With default value of 100 no change in regard of current
behaviour. Increasing the value makes SF to think a
longer time for each move. Decreasing the value makes SF
to move faster.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 3 Feb 2012 15:07:13 +0000 (16:07 +0100)]
Move wait_for_stop_or_ponderhit() under Thread
This method belongs to Thread, not to ThreadsManager.
Reshuffle stuff in thread.cpp while there.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 3 Feb 2012 12:18:51 +0000 (13:18 +0100)]
Reduce lock contention in idle_loop
Release split point lock before to wake up
master thread. This seems to increase speed
in case "sleeping threads" are used:
After 7792 games with 4 threads at very fast TC (2"+0.05)
Mod vs Orig 1722 - 1627 - 4443 ELO +4 (+- 5.1)
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 3 Feb 2012 07:03:17 +0000 (08:03 +0100)]
Fix an alignment warning with MSVC
The declared alignment is different from the one
in the definition.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 30 Jan 2012 13:09:20 +0000 (14:09 +0100)]
Fix subtle race with slave allocation
When allocating a slave we set both is_searching
and splitPoint under lock protection.
Unfortunatly the order in which the variables are
set is not defined. This article was very clarifying:
http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/
So when in idle loop we test for is_searching and then
access splitPoint, it could happen that splitPoint is still
not updated leading to a possible crash.
Fix the race lock protecting splitPoint access.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 29 Jan 2012 21:38:08 +0000 (22:38 +0100)]
Fix bug in useless checks prune
With current code we could raise bestValue above beta,
not what is intended for.
Spotted by Richard Vida.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 29 Jan 2012 11:41:50 +0000 (12:41 +0100)]
Reformat kpk bitbase
Simplify and streamline the code. Verified all the
resulting bitbases are not changed.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 29 Jan 2012 10:25:02 +0000 (11:25 +0100)]
Don't log search info after a stop
Fix an issue where the log file stores an incorrect +0.00
eval after a search has been stopped.
Bug reported by Ajedrecista.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 29 Jan 2012 08:54:17 +0000 (09:54 +0100)]
Bitwise operator overloads between Bitboard and Square
Yes, we try to be fancy here ;-)
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 29 Jan 2012 08:11:03 +0000 (09:11 +0100)]
Replace clear_bit() with xor_bit()
This allows to retire ClearMaskBB[] and use just
one SquareBB[] array to set and clear a bit.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 27 Jan 2012 18:47:56 +0000 (19:47 +0100)]
Rename ValueType to Bound
It is a more conventional and common naming.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 27 Jan 2012 18:41:12 +0000 (19:41 +0100)]
Do not require -lpthread when linking in mingw
With this we should compeltely remove the need
of installing third party POSIX threads library
when compiling with mingw-gcc under Windows.
Spotted by Trung Tu.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 24 Jan 2012 06:17:15 +0000 (07:17 +0100)]
Restore LMR depth limit
It is not clear the advantage and we don't want
to risk of introducing regressions on this
very critical parameter. So revert to old limit.
After 16003 games
Mod vs Orig 2496 - 2421 - 11086 ELO +1 (+-3)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 26 Jan 2012 22:18:43 +0000 (23:18 +0100)]
Reformat threads code
Apart from some renaming the biggest change
is the retire of split_point_finished()
replaced by slavesMask flags. As a side
effect we now take also split point lock
when allocation available threads.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 25 Jan 2012 05:29:30 +0000 (06:29 +0100)]
Use Windows threads library with mingw
Instead of Posix threads. This seems to fix time
losses of the gcc compiled version for Windows.
The patch replaces the MSVC specific _MSC_VER flag
with _WIN32 and _WIN64 that are defined both by
MSVC and mingw-gcc.
Workaround found by Jim Ablett.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 21 Jan 2012 19:53:42 +0000 (20:53 +0100)]
Order bad captures by MVV/LVA
Instead of by SEE. Almost no ELO change but it is
a bit easier and is a more natural choice given
that good captures are ordered in the same way.
After 10424 games
Mod vs Orig 1639 - 1604 - 7181 ELO +1 (+-3.8)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 23 Jan 2012 19:47:20 +0000 (20:47 +0100)]
Revert "Fix link time optimization gcc option"
It seems we need to pass the full optimization
flags to the linker otherwise we end up in a
slow compile:
http://lists.debian.org/debian-devel/2011/06/msg00181.html
Regression reported by Benigno Hernandez.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 23 Jan 2012 14:20:53 +0000 (15:20 +0100)]
Simplify locking usage
pass references (Windows style) instead of
pointers (Posix style) as function arguments.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 22 Jan 2012 21:53:57 +0000 (22:53 +0100)]
Simplify our insertion sort implementation
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Auguste Pop [Wed, 4 Jan 2012 10:01:12 +0000 (18:01 +0800)]
Fix link time optimization gcc option
The previous line, LDFLAGS += $(CXXFLAGS), does not make sense, and
breaks profile-build, thus changing it into: LDFLAGS += -flto.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 22 Jan 2012 13:25:31 +0000 (14:25 +0100)]
Shrink sequencer table
Integrate TT_MOVE step into the first state. This allows to
avoid the first call to next_phase() in case of a TT move.
And use overflow detection instead of the bunch of STOP_XX
states to detect end of moves.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 22 Jan 2012 10:57:42 +0000 (11:57 +0100)]
Assorted code style in movepicker.cpp
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 22 Jan 2012 10:33:53 +0000 (11:33 +0100)]
Fix incorrect assert(PvNode == (alpha != beta - 1))
In case of a PvNode could happen that alpha == beta - 1,
for instance in case the same previous node was visited
with same beta during a non-pv search, the node failed low
and stored beta-1 in TT. Then the node is searched again
in PV mode, TT value beta-1 is retrieved and updates alpha
that now happens to be beta-1.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 22 Jan 2012 10:19:44 +0000 (11:19 +0100)]
Order the recaptures by MVV/LVA
Almost no functional change because multiple recaptures
to same square are very rare, but neverthless it seems
the correct thing to do.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 21 Jan 2012 17:45:18 +0000 (18:45 +0100)]
Rename NON_CAPTURE to QUIET
It is a more conventional naming and is nicer.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 21 Jan 2012 22:32:48 +0000 (23:32 +0100)]
Reshuffle stuff in MovePicker
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 21 Jan 2012 22:30:56 +0000 (23:30 +0100)]
Fix ss->currentMove when probcutting
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 21 Jan 2012 12:43:24 +0000 (13:43 +0100)]
Use an enum instead of a table as MovePicker sequencer
No functional change
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 21 Jan 2012 11:07:03 +0000 (12:07 +0100)]
Sync generate_direct_checks() with generate_piece_moves()
They are almost the same, if the function arguments would
have been the same they could even be integrated.
Also a bit of renaming while there.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 18 Jan 2012 16:52:55 +0000 (17:52 +0100)]
Triviality in SERIALIZE_PAWNS() macro usage
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Justin Blanchard [Mon, 16 Jan 2012 20:20:13 +0000 (04:20 +0800)]
Remove unused #include lines
Justin Blanchard [Fri, 13 Jan 2012 06:33:22 +0000 (14:33 +0800)]
Fix "go nodes", at least when Threads=1
Marco Costalba [Sun, 15 Jan 2012 08:54:27 +0000 (09:54 +0100)]
Don't allow LMR to fall in qsearch
And increase LMR limit. Tests show no change ELO wise,
but we prefer to take the risk to commit anyhow becuase
is a 'prune reducing' patch.
After 10749 games
Mod vs Orig: 1670 - 1676 - 7403 ELO 0 (+-3.7)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 17 Jan 2012 20:31:49 +0000 (21:31 +0100)]
Microptimize generation of pawn evasions
Skip calling promotion generation functions in
the very common case of no possible promotion
evasion. Also retire generate_pawn_captures()
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 16 Jan 2012 13:27:12 +0000 (14:27 +0100)]
Simplify pawn captures generation
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 16 Jan 2012 09:11:52 +0000 (10:11 +0100)]
Fix a (bogus) warning with gcc 4.4
Fix an incorrect warning: 'bm may be used uninitialized'
with the old but still commonly used gcc 4.4
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 15 Jan 2012 16:02:06 +0000 (17:02 +0100)]
Retire double-profile-build Makefile target
Now that we don't support anymore popcount detection
at runtime this target is obsolete.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 15 Jan 2012 11:50:09 +0000 (12:50 +0100)]
Fix gcc name used in Link Time Optimization
Use $(CXX) instead of assuming compiler name is 'gcc'
Spotted by Louis Zulli.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 15 Jan 2012 07:24:50 +0000 (08:24 +0100)]
Make init_magic() piece agnostic
All the piece dependant data is passed now as
function arguments so that the code is exactly
the same for bishop and rook.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 14 Jan 2012 22:01:09 +0000 (23:01 +0100)]
Unify some template specializations
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 14 Jan 2012 22:00:10 +0000 (23:00 +0100)]
Retire queen_attacks_bb()
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 14 Jan 2012 17:03:57 +0000 (18:03 +0100)]
Use 'adjacent' instead of 'neighboring'
It is more correct and specific. Another naming
improvement while reading Critter sources.
No functional changes.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 2 Jan 2012 17:23:05 +0000 (18:23 +0100)]
Restore development version
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 29 Dec 2011 10:09:11 +0000 (11:09 +0100)]
Stockfish 2.2.2
Dedicated to the new Jim's super fast builds ! :-)
stockfish bench signature is:
5447426
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 14 Jan 2012 12:49:25 +0000 (13:49 +0100)]
Move struct RootMove to Search namespace
And directly pass RootMoves instead of SearchMoves
to main thread. A class declaration is better suited
in a header and slims a bit the fatty search.cpp
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 14 Jan 2012 10:45:54 +0000 (11:45 +0100)]
Use a set to store SearchMoves
We just need to verify if a legal move is among the
SearchMoves, so we don't need a vector for this.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 13 Jan 2012 06:56:59 +0000 (07:56 +0100)]
Fix a gcc 4.7 warning
New gcc 4.7 complains about casting a volatile pointer
to void* so assign the variables directly.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 12 Jan 2012 20:26:25 +0000 (21:26 +0100)]
Enable easy move detection only for recaptures
It could lead to terrible mistakes otherwise, as
it happened during a game on playchess when on
this position (after white's f4):
2q4r/4b1k1/p3rpp1/3np2p/PpNpNP1P/1P1P2PQ/2P1R3/4R1K1 b - - 0 1
SF moves immediately e5xf4 instead of the correct f5.
In general during engine matches it is impossible the
opponent leaves a piece hanging or anyhow starts a
clear losing sequence. So avoid to fall in subtle traps.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 12 Jan 2012 18:31:18 +0000 (19:31 +0100)]
Use operator~ to flip colors and squares
More natural and nicer. Idea from Critter.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 12 Jan 2012 17:12:25 +0000 (18:12 +0100)]
Small touches in FEN decoding
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 10 Jan 2012 10:57:06 +0000 (11:57 +0100)]
Retire is_mate()
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 9 Jan 2012 21:34:00 +0000 (22:34 +0100)]
Introduce piece_moved() to simplify common code
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 9 Jan 2012 08:48:27 +0000 (09:48 +0100)]
Unify PseudoAttacks arrays
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 8 Jan 2012 14:08:20 +0000 (15:08 +0100)]
Use CheckInfo to generate checks
It should help to avoid recalculating check squares
of sliding attackers for queen when already done for
bishops and rooks. Of course this helps when there are
bishop, rook and queen on the board !
Fixed also a subtle bug (use of same variable b in while
condition and in condition body) introduced recently by
revision
d655147e8c that triggers
in case we have at least 2 non-pawn discovered check pieces.
This is very rare that's why didn't show in the node count
verification where we actually have a case of 2 dc pieces
in position 14, but one is a pawn.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 8 Jan 2012 11:08:16 +0000 (12:08 +0100)]
Add castling to generation of checking moves
During generation of non-captures checks (in qsearch)
we don't consider castling moves that give check,
this patch includes also this rare case. Verified with
perft that all the non-capture checks are now generated.
There should be a very little slowdown due to the extra
work, but actually I failed to measure it. I don't expect
any ELO improvment, there is even no functional change on
the standard depth 12 search, it is just to have a correct
move generator.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 6 Jan 2012 11:37:33 +0000 (12:37 +0100)]
Last touches to movegen.cpp
The full movegen patch series shows a speed up of almost
6% (!) on perft, and code is much more readable too.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 5 Jan 2012 09:50:51 +0000 (10:50 +0100)]
Retire the redundant MV_CHECK
MV_CHECK is an alias of the more appropiate named
MV_NON_CAPTURE_CHECK so use only the latter.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 5 Jan 2012 08:27:50 +0000 (09:27 +0100)]
Retire generate_discovered_checks
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 4 Jan 2012 15:40:12 +0000 (16:40 +0100)]
Rearrange pawn moves generation
Functional change due only to rearrangement
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 4 Jan 2012 13:10:53 +0000 (14:10 +0100)]
Reshuffle stuff in movegen.cpp
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 7 Jan 2012 10:17:10 +0000 (11:17 +0100)]
Retire OLD_LOCKS option
And make CRITICAL_SECTION locks the only option for Windows.
This guarantees backward compatibility with all the Windows
versions (even XP and older) and an hassle free experience
when compiling for Windows. Tests performed by Ingo and
reported on talkchess confirm there is no speed penalty
against the most modern SRW locks:
http://www.talkchess.com/forum/viewtopic.php?t=41835&start=20
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 6 Jan 2012 23:04:08 +0000 (00:04 +0100)]
Fix compile on HP-UX 11's HP's C++
On that platform non-bracketed casting are not supported.
Reported by Richard Lloyd.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 2 Jan 2012 17:23:05 +0000 (18:23 +0100)]
Restore development version
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 29 Dec 2011 10:09:11 +0000 (11:09 +0100)]
Stockfish 2.2.1
Hopefully fixed the "lose on time" issue.
stockfish bench signature is:
5457475
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 6 Jan 2012 09:28:15 +0000 (10:28 +0100)]
Extra time management safety
Further increase safety against time losses. After this
change (tested on LittleBlitzer and cutechess) I had no
more time losses at 2" and 1"+0.02 TC both on Windows
and Linux on more than 10000 games.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 2 Jan 2012 22:40:14 +0000 (23:40 +0100)]
Try hard not to lose on time
We try hard not to lose on time even under extreme
time pressure. We achieve this through 3 different but
coordinated steps:
1) Increase max frequency of timer events
2) Quickly return after a stop signal
3) Take in account timer resolution
With these SF played under LittleBlitzer at 1"+0.02 and 3"+0
without losing on time even one game.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 3 Jan 2012 20:13:29 +0000 (21:13 +0100)]
Avoid a race at thread creation
Before creating main thread we set its do_sleep flag to true,
then thread is created and it will go to sleep in main_loop()
after resetting do_sleep.
But if after the setting of do_sleep and before its resetting
the UI thread calls start_thinking() it will not wait on:
if (!asyncMode)
while (!main.do_sleep)
cond_wait(&sleepCond, &main.sleepLock);
as it should but will immediately return before the main thread has
started the search. This very rare race show itself during bench,
when the first position is erroneusly skipped so that bench node count
results of
5309038 instead of the correct
5457475.
The patch is somewhat tricky, but is simple and it works!
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 3 Jan 2012 14:16:01 +0000 (15:16 +0100)]
Streamline generation of MV_NON_EVASION
Small speed-up of 3% in perft.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Tue, 3 Jan 2012 07:56:29 +0000 (08:56 +0100)]
Fix a warning under gcc
Locals left and right shadow two same named
variables in the std::ifstream base class.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 2 Jan 2012 13:37:44 +0000 (14:37 +0100)]
Revert cond_signal() fix
It seems it yields to missing wake-up events with the
result of SF loosing on time as reported by many people.
So revert the patch and use a more robust approach: assume
there can be spurious wake ups events and make the code to
work also in those cases.
While debugging I found that WaitForSingleObject() had wrong
parameter 0 instead of INFINITE yielding to a crash while
exiting under Windows, strangely unnoticed til now.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 1 Jan 2012 15:00:00 +0000 (16:00 +0100)]
Big renaming of move's helpers
The aim is to have shorter names without losing
readibility but, if possible, increasing it.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 31 Dec 2011 16:52:14 +0000 (17:52 +0100)]
Simplify Book APIs
Retire open(), close() and name() from public visibility
and greately simplify the code. It is amazing how much
can be squeezed out of an already mature code !
No functional change
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 29 Dec 2011 10:49:49 +0000 (11:49 +0100)]
Restore development version
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 29 Dec 2011 10:09:11 +0000 (11:09 +0100)]
Stockfish 2.2
stockfish bench signature is:
5457475
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 31 Dec 2011 14:27:14 +0000 (15:27 +0100)]
Fix cond_signal() semantics when using OLD_LOCKS
In Windows when OLD_LOCKS is defined we use SetEvent() to mimic
the semantic of the POSIX pthread_cond_signal().
Unfortunatly there is not a direct mapping because with SetEvent()
the state of an event object remains signaled until it is set
explicitly to the nonsignaled state or until a single waiting thread
has been released. Instead in case of pthread_cond_signal(), if there
are no waiting threads it has no effect. What we may want is something
like PulseEvent() instead of SetEvent(). Unfortunatly it is documented
by Mcrosoft as 'unreliable' due to spurious wakes up that could
filter out the signal resetting. So we opt to reset manually any
pending signaled state before to go to sleep.
This fixes the strange misbehaves during 'stockfish bench'
when using OLD_LOCKS under Windows.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 31 Dec 2011 08:46:43 +0000 (09:46 +0100)]
Unify BitCountType selection
Now that HasPopCnt is a compile time constant we can
centralize and unify the BitCountType selection.
Also rename count_1s() in the more standard popcount()
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 30 Dec 2011 23:11:49 +0000 (00:11 +0100)]
Fix Windows 64 build
Broken by previous patch.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 30 Dec 2011 16:08:07 +0000 (17:08 +0100)]
Reformat types.h
Retire obsolete code and reshuffle stuff.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 30 Dec 2011 15:14:24 +0000 (16:14 +0100)]
Simplify debug functions
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 30 Dec 2011 13:40:35 +0000 (14:40 +0100)]
Assorted cleanups in benchmark.cpp
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 30 Dec 2011 13:16:15 +0000 (14:16 +0100)]
Retire RootMove::nodes
Was used for time management but is no more used
today.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 30 Dec 2011 12:24:41 +0000 (13:24 +0100)]
Update copyright year to 2012
And refresh Readme.txt while there.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 30 Dec 2011 11:53:51 +0000 (12:53 +0100)]
Simplify printing of engine info
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 30 Dec 2011 10:30:26 +0000 (11:30 +0100)]
Retire run-time detection of hardware POPCNT
It was meant to build a single binary optimized
for any kind of CPU: with and without hardware POPCNT.
This is a nice idea but in practice was never used, or
people builds binary with popcnt enabled or not, mainly
according to their type of CPU. And it was also never
used in the official Jim's builds where, in case, would
be easier for a number of reasons, do build two different
versions: with and without SEE42 support.
So retire this feature and simplify the code.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 29 Dec 2011 17:25:08 +0000 (18:25 +0100)]
Fix an off-by-one bug in ucioption.cpp
Harmless but anyhow wrong.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 29 Dec 2011 12:18:03 +0000 (13:18 +0100)]
Better use STL algorithms in Endgame functions
This leads to a further and unexpected simplification
of this already very size optimized code.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Thu, 29 Dec 2011 08:55:09 +0000 (09:55 +0100)]
Wait for main thread to finish before to exit
Currently after a 'quit' command UI thread raises stop
signal, exits from uci_loop() and calls Threads.exit()
while the search threads are still active.
In Threads.exit() main thread is asked to terminate, but
if it is parked in idle_loop() it will exit and free its
resources (in particular the shared Movepicker object) while
sibling slaves are still active and this leads to a crash.
The fix is to let the UI thread always wait for main thread
to finish the search before to return from uci_loop().
Found by Valgrind when running with 8 threads.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 28 Dec 2011 23:13:49 +0000 (00:13 +0100)]
Use for_each() in Endgames d'tor
And fix some comments while there.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 28 Dec 2011 17:27:18 +0000 (18:27 +0100)]
Add user-defined conversions to UCIOption
Greatly improves the usage. User defined conversions
are a novelity for SF, another amazing C++ facility
at work !
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>