]> git.sesse.net Git - stockfish/log
stockfish
14 years agoFix some warnings under +w1 HP-UX compile
Marco Costalba [Sun, 11 Apr 2010 16:03:03 +0000 (17:03 +0100)]
Fix some warnings under +w1 HP-UX compile

This is the world's fussiest compiler with +w1

Warnings reported by Richard Lloyd.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRestore development version
Marco Costalba [Sat, 10 Apr 2010 19:42:31 +0000 (20:42 +0100)]
Restore development version

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUpdate polyglot.ini
Marco Costalba [Sat, 10 Apr 2010 19:41:10 +0000 (20:41 +0100)]
Update polyglot.ini

Remove obsolete options and add a few ones.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoStockfish 1.7.1
Marco Costalba [Sat, 10 Apr 2010 15:48:25 +0000 (16:48 +0100)]
Stockfish 1.7.1

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIntroduce "Zugzwang detection" temporary hack for 1.7.1
Marco Costalba [Sat, 10 Apr 2010 15:40:03 +0000 (16:40 +0100)]
Introduce "Zugzwang detection" temporary hack for 1.7.1

Add an UCI option "Zugzwang detection" OFF by default that
enables correct detection of zugzwang.

This is just to let 1.7.1 be 100% compatible with 1.7 and
should be removed after release.

Verified 100% functional equivalent to 1.7

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRevert HT detection
Marco Costalba [Sat, 10 Apr 2010 10:35:30 +0000 (11:35 +0100)]
Revert HT detection

Fall back on 1.6.3 behaviour.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRevert last patch
Marco Costalba [Sat, 10 Apr 2010 10:15:16 +0000 (11:15 +0100)]
Revert last patch

It fails in test position:

8/7P/8/8/K2b4/p7/1k6/1B6 b - -

Not clear why but we revert because it fixes the issue.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRelax TT condition for zugzwang verified null values
Marco Costalba [Sat, 10 Apr 2010 09:48:08 +0000 (10:48 +0100)]
Relax TT condition for zugzwang verified null values

In this case use a normal VALUE_TYPE_LOWER TT type instead of
VALUE_TYPE_NS_LO. This allow us to TT cut-off in a bit more nodes.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAvoid TT cutoffs at root of null zugzwang verification
Marco Costalba [Sat, 10 Apr 2010 09:32:17 +0000 (10:32 +0100)]
Avoid TT cutoffs at root of null zugzwang verification

This patch fixes an issue with zugzwang well explained by Tord:

"Assume that a zugzwang position occurs at iteration N,
at a search depth d, with d < 6*OnePly. The null move search
fails high, and no verification search is done, because the
depth is too small. The position gets stored in the transposition
table with a good score and a depth of d.

Now, consider what happens when the same position occurs at iteration
N+1, this time with a depth of d+OnePly (i.e. one ply deeper than at
the previous iteration). Once again, the null move search fails
high. The point is that the verification search will also fail high,
because of an instant transposition table cutoff caused by the value
stored in the TT during the previous iteration."

With this patch we simply do not allow TT cutoffs at the root node
of a null move verification search if the TT value was found by a
null search.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse a flag in TT to track null search values
Marco Costalba [Sat, 10 Apr 2010 08:53:08 +0000 (09:53 +0100)]
Use a flag in TT to track null search values

Add VALUE_TYPE_NS_LO to enum ValueType and use it when
saving in TT a value from a null search.

Currently no action is performed, the next patch will enable
the new type.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a warning under HP-UX ANSI C++
Marco Costalba [Fri, 9 Apr 2010 06:05:32 +0000 (07:05 +0100)]
Fix a warning under HP-UX ANSI C++

Reported warning is:

warning #2514-D: pointless comparison of unsigned
                 integer with a negative constant

Spotted by Richard Lloyd.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoStockfish 1.7
Marco Costalba [Wed, 7 Apr 2010 11:08:50 +0000 (13:08 +0200)]
Stockfish 1.7

Signatures are:

./stockfish bench 128 1 12 default depth
8299338

./stockfish bench 128 1 13 default depth
15694903

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix PowerPC and ARM compatibility.
Tord Romstad [Tue, 6 Apr 2010 08:19:09 +0000 (10:19 +0200)]
Fix PowerPC and ARM compatibility.

14 years agoAdd -mdynamic-no-pic to CFLAGS when compiling with GCC under OS X.
Tord Romstad [Mon, 5 Apr 2010 19:47:28 +0000 (21:47 +0200)]
Add -mdynamic-no-pic to CFLAGS when compiling with GCC under OS X.
Without this flag, the __cpuid() function doesn't compile correctly
in 32-bit mode.

14 years agoFix one gcc 4.4 warning
Marco Costalba [Mon, 5 Apr 2010 19:08:01 +0000 (20:08 +0100)]
Fix one gcc 4.4 warning

Properly fix previous warning. Patch from Joona.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a warning in HT_enabled()
Marco Costalba [Mon, 5 Apr 2010 14:36:06 +0000 (15:36 +0100)]
Fix a warning in HT_enabled()

Under gcc we have:

warning: dereferencing type-punned pointer will break
strict-aliasing rules

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoStore score in TT when null search fails high
Marco Costalba [Sat, 3 Apr 2010 07:54:21 +0000 (08:54 +0100)]
Store score in TT when null search fails high

Use full depth, not reduced one. This allows
to avoid to do a null search when in the same
position and at the same or bigger depth the
null search failed high.

A very small increase, if any.

After 963 games at 1+0
Mod vs Orig: +158 =657 -147  +4 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoCleanup pawn storm code
Marco Costalba [Fri, 2 Apr 2010 09:48:12 +0000 (11:48 +0200)]
Cleanup pawn storm code

In this form it is even more evident we have some
issue there to be fixed sooner then later....

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a comment in evaluate.cpp
Marco Costalba [Wed, 31 Mar 2010 07:57:48 +0000 (09:57 +0200)]
Fix a comment in evaluate.cpp

Function name is wrong.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoChange poll() signature
Marco Costalba [Wed, 31 Mar 2010 05:43:12 +0000 (06:43 +0100)]
Change poll() signature

After previous patch we don't need any more the call parameters.

This fixes a couple of warnings under MSVC.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove several unnecessary UCI options: All king safety options
Tord Romstad [Tue, 30 Mar 2010 13:15:01 +0000 (15:15 +0200)]
Remove several unnecessary UCI options: All king safety options
except "Aggressiveness" and "Cowardice", and "UCI_ShowCurrLine".
No functional change compared to the previous version with the
default settings.

14 years agoRevert LMR reduction based on thinking time
Marco Costalba [Sun, 28 Mar 2010 11:04:41 +0000 (12:04 +0100)]
Revert LMR reduction based on thinking time

After 500 games at 5+0 on my QUAD (3 days) there
is no difference with old version, so probably it
is a feature that doesn't scale with search depth.

So revert for now, perhaps we should readd under a
different form.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSmall comments tweaks in search.cpp
Marco Costalba [Wed, 24 Mar 2010 09:15:00 +0000 (10:15 +0100)]
Small comments tweaks in search.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSync static null conditions with real one
Marco Costalba [Mon, 22 Mar 2010 07:52:04 +0000 (08:52 +0100)]
Sync static null conditions with real one

Almost no functional change, but it seems more
in line with the meaning of static null pruning.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSilence a couple of warnings
Marco Costalba [Tue, 23 Mar 2010 22:34:21 +0000 (23:34 +0100)]
Silence a couple of warnings

MSVC complains about an implicit conversion from double to int.

Also small comments tweaks.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoVary reduction aggressiveness as a function of thinking time
Joona Kiiski [Sun, 21 Mar 2010 20:44:56 +0000 (22:44 +0200)]
Vary reduction aggressiveness as a function of thinking time

In the beginning use milder reduction and at the end be
more aggressive.

After 1500 games on Joona's QUAD
Mod - Orig: 791 - 720 +16 elo

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoBase work for different reduction schemes
Joona Kiiski [Sun, 21 Mar 2010 20:34:30 +0000 (22:34 +0200)]
Base work for different reduction schemes

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDo not return unproven mate scores from null move search
Joona Kiiski [Sun, 21 Mar 2010 21:41:50 +0000 (23:41 +0200)]
Do not return unproven mate scores from null move search

Causes very small functional change which is not observable with
our usual set of test positions.

However change is observable fx. with following position:
4k3/3r4/5Q2/6K1/8/8/8/8 w - - 0 1
go depth 24

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse fail soft in null search
Marco Costalba [Sat, 20 Mar 2010 11:42:23 +0000 (12:42 +0100)]
Use fail soft in null search

If null search fails high return null value instead of beta.

With TT hash there may be a small advantage for fail-soft since
storing slightly better bounds may cause slightly more hash hits.

After 990 games at 1+0
Mod vs Orig +171 =665 -154  +6 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove castleRightsMask[] hack
Marco Costalba [Sat, 20 Mar 2010 10:59:22 +0000 (11:59 +0100)]
Remove castleRightsMask[] hack

Array castleRightsMask[] is not static because it can
be different for different positions, so let it be
a Position member data. This allows to remove tricky
hacks to take in account that although it was defined
static it could change.

Theoretically now copying a position is a bit slower because
we need to copy also an array of 64 integers, but because in
split() we don't copy the position anymore, but just keep the
pointer, the added burden is not mesurable even in MP case.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRetire Position::fast_copy()
Marco Costalba [Sat, 20 Mar 2010 10:45:04 +0000 (11:45 +0100)]
Retire Position::fast_copy()

It is never used and could be tricky, so remove it.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUpdated copyright year to 2010
Marco Costalba [Sat, 20 Mar 2010 10:27:07 +0000 (11:27 +0100)]
Updated copyright year to 2010

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix POPCNT detection gcc compile error
Marco Costalba [Wed, 17 Mar 2010 17:09:37 +0000 (18:09 +0100)]
Fix POPCNT detection gcc compile error

Also don't use __cpuid() intrinsic for Intel under
Linux because gives wrong results when detecting HT,
use the gcc version instead. Finally clean up the code.

Error was due to changed __cpuid() signature for
gcc compiler.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix __cpuid() compile error with gcc
Marco Costalba [Wed, 17 Mar 2010 12:22:28 +0000 (13:22 +0100)]
Fix __cpuid() compile error with gcc

Use same __cpuid() signature used under Windows.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAdd hyper-threading detection
Marco Costalba [Sun, 14 Mar 2010 11:14:09 +0000 (12:14 +0100)]
Add hyper-threading detection

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoMove __cpuid() definition for gcc in types.h
Marco Costalba [Sun, 14 Mar 2010 10:16:25 +0000 (11:16 +0100)]
Move __cpuid() definition for gcc in types.h

This will allow to use the function also for other
purposes then detecting POPCNT.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIntroduce captured_piece()
Marco Costalba [Mon, 8 Mar 2010 13:57:01 +0000 (14:57 +0100)]
Introduce captured_piece()

It will be used by future patches and also rearranges some
half cooked code that mistakenly ended up in master in the
past.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoReduce increase progression of aspiration window
Marco Costalba [Tue, 9 Mar 2010 14:46:20 +0000 (15:46 +0100)]
Reduce increase progression of aspiration window

Currently, in case of fail high/low we research with
a window increased by 2*AspirationDelta at first
attempt, this patch instead makes the research be
done with an increase of just AspirationDelta size,
in case of a consecutive fail we will widen to
2*AspirationDelta and so on.

After Joona's test:
Orig - Mod: 850 - 890

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse separated research counters in root_search()
Marco Costalba [Sun, 7 Mar 2010 08:02:34 +0000 (10:02 +0200)]
Use separated research counters in root_search()

One for failing highs and one for failing lows, this
should reduce average window size in case of positions
that fail first high and then low (or the contrary).

After ~2000 games on Joona's quad we have:

Mod - Orig: 1012- 975 (+6 elo)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoGroup time management globals initialization
Marco Costalba [Tue, 9 Mar 2010 13:25:07 +0000 (14:25 +0100)]
Group time management globals initialization

Instead to leave uninitialized or scattered in the code
as is the case for ExtraSearchTime.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoHighlight that alpha and beta could change in root_search()
Marco Costalba [Sat, 6 Mar 2010 17:17:04 +0000 (18:17 +0100)]
Highlight that alpha and beta could change in root_search()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a comment and add an assert in root_search()
Marco Costalba [Sat, 6 Mar 2010 16:51:56 +0000 (17:51 +0100)]
Fix a comment and add an assert in root_search()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRetire RootMoveNumber and use FirstRootMove instead
Marco Costalba [Sat, 6 Mar 2010 16:34:36 +0000 (17:34 +0100)]
Retire RootMoveNumber and use FirstRootMove instead

It is more clear why we use that global flag.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSave mateThreat flag in splitPoint and make use of it
Joona Kiiski [Thu, 4 Mar 2010 07:10:06 +0000 (09:10 +0200)]
Save mateThreat flag in splitPoint and make use of it

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDocument one test result
Joona Kiiski [Thu, 4 Mar 2010 06:52:35 +0000 (08:52 +0200)]
Document one test result

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSynchronize root_search() with other search routines
Joona Kiiski [Wed, 3 Mar 2010 20:00:44 +0000 (22:00 +0200)]
Synchronize root_search() with other search routines

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove obsolete code snippet from root_search
Joona Kiiski [Wed, 3 Mar 2010 16:53:46 +0000 (18:53 +0200)]
Remove obsolete code snippet from root_search

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSort again root moves after a fail low
Marco Costalba [Sat, 6 Mar 2010 10:43:31 +0000 (11:43 +0100)]
Sort again root moves after a fail low

Currently we use original sorting after a fail low to
research at wider window. This patch instead sorts the
moves according to the last available move's scores.

Strangely no functional change, but should be.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAdditional search.cpp cleanup
Marco Costalba [Fri, 5 Mar 2010 10:55:27 +0000 (11:55 +0100)]
Additional search.cpp cleanup

Changed FutilityMarginsMatrix dimensions to be a power of two
so that compiler can produce a faster accessing code.

Introduced print_pv_info() to remove some redundant code in
root_search()

Remaining stuff is triviality and documentation tweaks.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDestroy all locks before to exit
Marco Costalba [Sun, 28 Feb 2010 11:23:53 +0000 (12:23 +0100)]
Destroy all locks before to exit

And use platform-independent functions
where possible.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoWe don't need lpThreadId parameter in CreateThread()
Marco Costalba [Sun, 28 Feb 2010 10:53:29 +0000 (11:53 +0100)]
We don't need lpThreadId parameter in CreateThread()

Under Windows we use CreateThread() to setup threads and
we pass a pointer to a variable that receives the thread
identifier, but this parameter is optional and we don't
use it, so remove it.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFunction init_thread() should return an integer under Windows
Marco Costalba [Sun, 28 Feb 2010 10:36:40 +0000 (11:36 +0100)]
Function init_thread() should return an integer under Windows

It happens that NULL is 0, but the conventional meaning is of
a zero pointer, so repleace with an explicit 0 integer value.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoTry bad captures before non-captures
Marco Costalba [Sat, 27 Feb 2010 16:09:07 +0000 (17:09 +0100)]
Try bad captures before non-captures

Consider sligtly negative captures as good if at low
depth and far from beta.

After 999 games at 1+0
Mod vs Orig +169 =694 -136  +11 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRevert previous patch
Marco Costalba [Sat, 27 Feb 2010 16:22:19 +0000 (17:22 +0100)]
Revert previous patch

It raises an assert under Windows, it is not clear why but it
happens that idle_loop() is called with incorrect threadID and
the assert triggered is:

assert(threadID >= 0 && threadID < MAX_THREADS);

So revert the patch for now, but we should understand why it
fails.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDo not wait for sleeping in init_threads()
Marco Costalba [Sat, 27 Feb 2010 12:26:04 +0000 (13:26 +0100)]
Do not wait for sleeping in init_threads()

We can't do it with full guarantee anyway because
there is always a possible race between the setting of
state to THREAD_SLEEPING and actual sleeping.

So just remove the not perfect code to avoid misunderstandings.
This reflects what we have done in wake_sleeping_threads() in
the previous patch.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove an incorrect assert in wake_sleeping_threads()
Marco Costalba [Sat, 27 Feb 2010 11:01:07 +0000 (12:01 +0100)]
Remove an incorrect assert in wake_sleeping_threads()

Currently there is no guarantee that threads are sleeping
when calling wake_sleeping_threads() because put_threads_to_sleep()
returns without waiting for threads to actually sleep.

Assert can be easily triggered calling put_threads_to_sleep() and
wake_sleeping_threads() in a tight loop.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAdd some commentary
Joona Kiiski [Thu, 25 Feb 2010 17:30:57 +0000 (19:30 +0200)]
Add some commentary

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoClean up common adjustments
Joona Kiiski [Thu, 25 Feb 2010 17:16:12 +0000 (19:16 +0200)]
Clean up common adjustments

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove "Threat Depth" ucioption
Joona Kiiski [Thu, 25 Feb 2010 17:05:06 +0000 (19:05 +0200)]
Remove "Threat Depth" ucioption

This option likely has very low meaning for playing strength and style,
so I see no need to keep this configurable

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoCleanup steps 12, 14
Joona Kiiski [Thu, 25 Feb 2010 16:59:16 +0000 (18:59 +0200)]
Cleanup steps 12, 14

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoClean up step 11
Joona Kiiski [Thu, 25 Feb 2010 16:43:47 +0000 (18:43 +0200)]
Clean up step 11

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoClean steps 8 and 9.
Joona Kiiski [Thu, 25 Feb 2010 16:27:27 +0000 (18:27 +0200)]
Clean steps 8 and 9.

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoClean razoring code (step 6)
Joona Kiiski [Thu, 25 Feb 2010 15:50:47 +0000 (17:50 +0200)]
Clean razoring code (step 6)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSynchronize variable listing of 4 different search routines
Joona Kiiski [Thu, 25 Feb 2010 11:52:03 +0000 (13:52 +0200)]
Synchronize variable listing of 4 different search routines

search() is used as a "leading star" and other routines
are modified according to it.

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove current line printing in SMP mode
Joona Kiiski [Thu, 25 Feb 2010 10:21:56 +0000 (12:21 +0200)]
Remove current line printing in SMP mode

Was broken and fixing would be too messy.
Now this option is only activated in single thread mode

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSynchronize sp_search() with search() part I
Joona Kiiski [Wed, 24 Feb 2010 15:30:13 +0000 (17:30 +0200)]
Synchronize sp_search() with search() part I

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRename staticValue to refinedValue
Joona Kiiski [Wed, 24 Feb 2010 11:04:44 +0000 (13:04 +0200)]
Rename staticValue to refinedValue

Just to avoid misunderstandings.
True staticValue is available through search stack

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix repetition detection bug
Joona Kiiski [Wed, 24 Feb 2010 18:13:35 +0000 (20:13 +0200)]
Fix repetition detection bug

Bug spotted by Jouni Uski and fix suggested by Pablo Vazquez

Also add note that we are not always handling fifty move rule correctly

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSynchronize sp_search_pv() with search_pv()
Joona Kiiski [Wed, 24 Feb 2010 15:52:37 +0000 (17:52 +0200)]
Synchronize sp_search_pv() with search_pv()

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSynchronize sp_search() with search() part II
Joona Kiiski [Wed, 24 Feb 2010 15:36:45 +0000 (17:36 +0200)]
Synchronize sp_search() with search() part II

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSimplify locking in splitpoint search
Joona Kiiski [Wed, 24 Feb 2010 14:44:34 +0000 (16:44 +0200)]
Simplify locking in splitpoint search

One rule: Always lock before picking up a move.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSynchronize search_pv() with search take II
Joona Kiiski [Wed, 24 Feb 2010 12:05:31 +0000 (14:05 +0200)]
Synchronize search_pv() with search take II

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSynchronize search_pv() with search take I
Joona Kiiski [Wed, 24 Feb 2010 11:41:22 +0000 (13:41 +0200)]
Synchronize search_pv() with search take I

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSearch code documentation, take III
Joona Kiiski [Wed, 24 Feb 2010 10:55:58 +0000 (12:55 +0200)]
Search code documentation, take III

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSearch code documentation take II
Joona Kiiski [Wed, 24 Feb 2010 10:37:32 +0000 (12:37 +0200)]
Search code documentation take II

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSeparate razoring from null move
Joona Kiiski [Wed, 24 Feb 2010 10:26:36 +0000 (12:26 +0200)]
Separate razoring from null move

I cannot see connection between the two.

Also add one FIXME for illogical behaviour

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSplit search() in independent sections
Joona Kiiski [Wed, 24 Feb 2010 10:19:47 +0000 (12:19 +0200)]
Split search() in independent sections

I don't know if enumerating sections is a good idea,
but for me code is more readable this way

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAvoid research in case thread has already been asked to stop
Joona Kiiski [Wed, 24 Feb 2010 10:02:39 +0000 (12:02 +0200)]
Avoid research in case thread has already been asked to stop

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAdd one assert
Joona Kiiski [Tue, 23 Feb 2010 10:07:58 +0000 (12:07 +0200)]
Add one assert

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDo not wait for threads falling asleep
Joona Kiiski [Tue, 23 Feb 2010 10:05:26 +0000 (12:05 +0200)]
Do not wait for threads falling asleep

I cannot see any reason to do this. Even this is not enough to fix
theoretical race case on Windows which doesn't seem to cause any
problems in practice anyhow

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove unnecessary conditions from if-clauses and replace them with asserts
Joona Kiiski [Tue, 23 Feb 2010 10:00:56 +0000 (12:00 +0200)]
Remove unnecessary conditions from if-clauses and replace them with asserts

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix crash in debug mode
Joona Kiiski [Mon, 22 Feb 2010 13:42:12 +0000 (15:42 +0200)]
Fix crash in debug mode

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix some races
Joona Kiiski [Mon, 22 Feb 2010 13:15:55 +0000 (15:15 +0200)]
Fix some races

Resurrect extra check for sleeping in POSIX code.
This necessary to prevent ugly races between
thread_broadcast and thread_cond_wait.

After thread has woken up, it marks itself as available.
Another thread must not do this, because of possible race.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix one assert
Joona Kiiski [Mon, 22 Feb 2010 13:00:30 +0000 (15:00 +0200)]
Fix one assert

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix compile errors in debug mode
Joona Kiiski [Mon, 22 Feb 2010 12:59:01 +0000 (14:59 +0200)]
Fix compile errors in debug mode

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDocument struct SplitPoint fields constness
Marco Costalba [Sun, 21 Feb 2010 15:10:19 +0000 (16:10 +0100)]
Document struct SplitPoint fields constness

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoBeta is never changed after an sp_search()
Marco Costalba [Sun, 21 Feb 2010 14:28:27 +0000 (15:28 +0100)]
Beta is never changed after an sp_search()

So we can use a const value instead of a pointer in
split().

Also pass NULL instead of a faked address of alpha in
case split is called from a non-PV node.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSupress make warning on missing .depend file
Marco Costalba [Sun, 21 Feb 2010 14:18:35 +0000 (15:18 +0100)]
Supress make warning on missing .depend file

This is generated by make itself, so the warning
is useless.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix an icc warning
Marco Costalba [Sun, 21 Feb 2010 14:07:53 +0000 (15:07 +0100)]
Fix an icc warning

remark #1599: declaration hides variable "i" (declared at line 2651)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoCode style triviality in split()
Marco Costalba [Sun, 21 Feb 2010 13:05:38 +0000 (14:05 +0100)]
Code style triviality in split()

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a warning with POPCNT and MSVC
Marco Costalba [Sun, 21 Feb 2010 12:44:36 +0000 (13:44 +0100)]
Fix a warning with POPCNT and MSVC

Intrinsic __popcnt64() returns an unsigned __int64, cast
to an integer and silence the warning.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRevert "Recursive lock"
Marco Costalba [Sat, 20 Feb 2010 22:56:02 +0000 (23:56 +0100)]
Revert "Recursive lock"

Joona says that sp_update_pv() does not pass the split point
boundaries, so there is no risk to corrupt data from another
split point. Also the race on thread_should_stop() is harmless
because of this.

So revert the patch and come back to single lock.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove a couple of useless thread_should_stop() calls
Marco Costalba [Sat, 20 Feb 2010 22:48:54 +0000 (23:48 +0100)]
Remove a couple of useless thread_should_stop() calls

We test for it anyway few lines below and even under lock
protection.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRevert small state change optimization in idle_loop()
Marco Costalba [Sat, 20 Feb 2010 17:36:07 +0000 (18:36 +0100)]
Revert small state change optimization in idle_loop()

Joona says:

1. We should not be afraid of "AllThreadsShouldExit" flag.
Because when this is set to true we _must_not_ be searching (= All
splits must have been undone).
And if we are not searching it's impossible that some other thread
could give us work to do. So setting state to THREAD_AVAILABLE
doesn't do any harm. If you want to add check for this, you could do
it like this:

 if (threads[threadID].state == THREAD_WORKISWAITING)
 {
+    assert(!AllThreadsShouldExit)
     threads[threadID].state = THREAD_SEARCHING;

2a. If waitSp->cpus == 0, setting state to THREAD_AVAILABLE makes
no harm either, because helpful master concept dictates that _only_
our own slave can book us. If we don't have any slaves, noone has the
right to book us.

2b. If point (2a) is not correct then your extra check only adds extra race:
In smp code checking for waitSp->cpus > 0 is not enough. It's possible that
our slave immediately exits and another thread
books us as a slave when our state is still
THREAD_AVAILABLE. So instead of adding extra level of security we have
just introduced extra race.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRecursive lock all split point's chain
Marco Costalba [Sat, 20 Feb 2010 17:29:53 +0000 (18:29 +0100)]
Recursive lock all split point's chain

When we found a cut-off then lock all the split point chain,
not only current one to avoid races in case two threads running
on different split points where one is ancestor then the other,
find a beta cut-off at the same time, in this case we want only
one to call sp_update_pv().

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRetire per-thread stopRequest flag
Marco Costalba [Sat, 20 Feb 2010 16:52:09 +0000 (17:52 +0100)]
Retire per-thread stopRequest flag

This is a per split-point request, not per-thread. When we find
a beta cut-off in current thread's split point or in or in some
ancestor of the current split point then threads should stop
immediately the search and return to idle_loop().

The check is done by thread_should_stop() that now looks only
at split point's chain.

No functional change and a good semplification.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse state instead of flags to track threads
Marco Costalba [Sat, 20 Feb 2010 13:57:26 +0000 (14:57 +0100)]
Use state instead of flags to track threads

This is easier to follow and also reduces the points
where state changes to mainly idle_loop() and split().

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRename THREAD_MAX in MAX_THREADS
Marco Costalba [Sat, 20 Feb 2010 12:38:04 +0000 (13:38 +0100)]
Rename THREAD_MAX in MAX_THREADS

Also rename idle_thread_exists() in available_thread_exists()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSearch negative SEE moves in qsearch in PV
Joona Kiiski [Fri, 12 Feb 2010 08:53:03 +0000 (10:53 +0200)]
Search negative SEE moves in qsearch in PV

After 2704 games on slow single core
mod - orig: 1381 - 1323

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse zero null move margin when depth < 4 * OnePly
Joona Kiiski [Fri, 12 Feb 2010 14:40:00 +0000 (16:40 +0200)]
Use zero null move margin when depth < 4 * OnePly

This is because when we are below 4 * OnePly, the null move
will directly jump to qsearch and if we are below beta,
our opponent is above beta and will get immediate
stand pat cut off.

So basically this patch is just optimizing away useless
evaluation calls. dbg_hit_on() runs show that this heuristic
is correct >99% of cases. Transposition table probably causes
some inaccurary?

After 1148 games on QUAD
mod-orig: 583 - 565 +5 elo

Signed-off-by: Marco Costalba <mcostalba@gmail.com>