1
0
Fork 0
Commit Graph

3530 Commits (c++11)

Author SHA1 Message Date
Marco Costalba c0a1676a65 Retire spinlocks
Use Mutex instead.

This is in preparaation for merging with master branch,
where we stilll don't have spinlocks.

Eventually spinlocks will be readded in some future
patch, once c++11 has been merged.

No functional change.
2015-03-10 21:50:45 +01:00
Marco Costalba 6027652773 Cleanup thread_win.h
No functional change.
2015-03-10 17:13:52 +01:00
Marco Costalba 04372316b3 Disable spinlocks
To allow testing on fishtest.

No functional change.
2015-03-10 12:47:49 +01:00
Marco Costalba 8725494966 Add thread_win32.h header
Workaround slow std::thread implementation in mingw
and gcc for Windows with our own old low level thread
functions.

No functional change.
2015-03-10 12:42:40 +01:00
Marco Costalba be50952533 Sync with master
bench: 8285241
2015-03-07 10:56:01 +01:00
hxim 3017e8c604 Transform minKingPawnDistance into a local variable
minKingPawnDistance is used only as local variable in one place so we don't need it to be part of "Pawns::Entry" structure.

No functional change.

Resolves #277
2015-03-07 09:03:19 +00:00
Stéphane Nicolet 8fcaa78a04 Update Makefile for Mac OS X compilation
This change in the Makefile restores the possibility to compile
Stockfish on Mac OS X 10.9 and 10.10 after the C++11 has been merged.

To use the default (fastest) settings, compile with:

make build ARCH=x86-64-modern

To test the clang settings, compile with

make build ARCH=x86-64-modern COMP=clang

Beware that the clang settings may provide a slightly slower (6%)
executable.

Backported from master.

No functional change

Resolves #275
2015-03-07 08:39:21 +01:00
Marco Costalba a590d1d52d Re-enable spinlocks
For branch C++11, that doe snot run on fishtest,
there is no need of this kludge, let only master
have it.

No functional change.
2015-03-07 08:38:26 +01:00
Joona Kiiski 856a5f3aaa Revert C++11 merge
Restore the state of repo back to commit 'Simplify pawn code a bit' (1e6d21dbb6)

No functional change
2015-03-07 07:38:22 +00:00
Stéphane Nicolet 6fa6da3ee1 Update Makefile for Mac OS X compilation
This change in the Makefile restores the possibility to compile
Stockfish on Mac OS X 10.9 and 10.10 after the C++11 has been merged.

To use the default (fastest) settings, compile with:

make build ARCH=x86-64-modern

To test the clang settings, compile with

make build ARCH=x86-64-modern COMP=clang

Beware that the clang settings may provide a slightly slower (6%)
executable.

No functional change

Resolves #275
2015-03-05 04:18:59 +00:00
Marco Costalba cb2111f0b6 Disable spinlocks
Now that c++11 branch has been merged in master,
disable unconditionally the spinlocks and use mutex
instead. This will allow to run fishtest even on HT
machines withouth changes.

In the future we will reintorduce spinlocks, once
we will have took care of fishtest.

No functional change.
2015-03-02 08:11:39 +01:00
Marco Costalba 6645115377 Allow to disable spinlocks
And use mutex instead. You may never want to do this.
It is a workaround to run c++11 on fishtest where many
machiens have HTenabled and this can be a problem when
number of cores set is higher than number of physical cores.

To disable spinlocks, just compile with -DNO_SPINLOCK flag

No functional change.
2015-03-01 17:16:05 +01:00
Marco Costalba 63a5fc2366 Rename available_to()
Change this API to be more natural and simple.

Inspired by a patch by Joona.

No functional change.
2015-03-01 12:33:05 +01:00
Marco Costalba 0da7295795 Sync with master
bench: 8285241
2015-02-28 20:22:28 +01:00
Stéphane Nicolet 1e6d21dbb6 Simplify pawn code a bit
Simplify a bit the number of bitwise operators used to calculate the
pawn evaluation in pawns.cpp

No functional change.

Resolves #269
2015-03-01 01:01:37 +08:00
Stéphane Nicolet 9369f4963d Raise penalty for knight attacked by pawn
Raise a bit the penalty for knight attacked by pawn.

STC:
LLR: 2.97 (-2.94,2.94) [-1.50,4.50]
Total: 27744 W: 5563 L: 5380 D: 16801

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 87571 W: 14747 L: 14314 D: 58510

Bench: 8285241

Resolves #270
2015-03-01 00:58:32 +08:00
Marco Costalba a459709fcc Retire apply_weight()
Use the more natural operator*() instead.

No functional change.
2015-02-27 10:38:12 +01:00
Marco Costalba 2dbb1adf2a Sync with master
bench: 8069601
2015-02-26 20:50:39 +01:00
Marco Costalba 8a2c4134a6 Normalize twice supported pawns
Align codying style to current conventions and move
formula for twice supported pawns to Pawns::init()
where it should be.

No functional change.
2015-02-27 01:56:16 +08:00
Alain SAVARD fce799294c Apex Pawns
Pawns which are supported already have a bonus. Apex are pawns which are
supported twice.
This patch gives an additional 50% bonus for them.

STC
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 6549 W: 1333 L: 1209 D: 4007

LTC
LLR: 2.95 (-2.94,2.94) [0.00,6.00]
Total: 18002 W: 3037 L: 2850 D: 12115

Bench: 8069601

Resolves #267
2015-02-27 01:52:23 +08:00
Marco Costalba 0b36ba74fc Don't assume the type of Time::point
But instead use the proper definition. Also
rewrite chrono functions while there.

No functional change.
2015-02-24 14:08:14 +01:00
Marco Costalba 153fb216a1 Small tweaks in pawns.cpp
No functional change.
2015-02-24 11:45:29 +01:00
Marco Costalba d3d26a94b3 Improve spinlock implementation
Calling lock.test_and_set() in a tight loop creates expensive
memory synchronizations among processors and penalize other
running threads. So syncronize only only once at the beginning
with fetch_sub() and then loop on a simple load() that puts much
less pressure on the system.

Reported about 2-3% speed up on various systems.

Patch by Ronald de Man.

No functional change.
2015-02-23 19:48:46 +01:00
Marco Costalba 38112060dc Use spinlock instead of mutex for Threads and SplitPoint
It is reported to be defenitly faster with increasing
number of threads, we go from a +3.5% with 4 threads
to a +15% with 16 threads.

The only drawback is that now when testing with more
threads than physical available cores, the speed slows
down to a crawl. This is expected and was similar at what
we had setting the old sleepingThreads to false.

No functional change.
2015-02-23 13:47:07 +01:00
Marco Costalba 775f8239d3 Introduce Spinlock class
Initialization is more complex than what I'd like due
to MSVC compatibility that for some reason does not like:

std::atomic_flag lock = ATOMIC_FLAG_INIT;

No functional change.
2015-02-23 13:37:46 +01:00
Marco Costalba 098f645d26 Sync with master
bench: 8253813
2015-02-23 13:36:15 +01:00
Marco Costalba 29ff925fd8 Fix build under OS X
Reported by Vince Negri

No functional change.
2015-02-22 16:33:24 +01:00
Marco Costalba 8d16111ffd Sync with master
bench: 8253813
2015-02-22 14:20:23 +01:00
Marco Costalba e2226cbb20 Use only 'level' as late join metric
It seems other metric are useless, this allow us
to simplify the code and to prune useless stuff.

STC 20K games 4 threads
ELO: -0.76 +-2.8 (95%) LOS: 29.9%
Total: 20000 W: 3477 L: 3521 D: 13002

STC 10K games 16 threads
ELO: 1.36 +-3.9 (95%) LOS: 75.0%
Total: 10000 W: 1690 L: 1651 D: 6659

bench: 8253813
2015-02-22 12:59:34 +01:00
Marco Costalba 5fd5453e59 Further refine SMP code
Backported from C++11 branch:

https://github.com/official-stockfish/Stockfish/commit/7ff965eebfbc17d2b
https://github.com/official-stockfish/Stockfish/commit/e74c2df907d5336d3d2b

Fully verified it is equivalent to master (see log msg
of individual commits for details).

No functional change.
2015-02-21 11:33:03 +01:00
Marco Costalba e74c2df907 Use sp->master instead of bestThread
Verified with:

dbg_hit_on(th != sp->master);

It is 100% equivalent on more than 200K hits.

No functional change.
2015-02-21 10:40:59 +01:00
Stéphane Nicolet 41ccc885ec Fix comment for kingAdjacentZoneAttacksCount
The comment for kingAdjacentZoneAttacksCount[] was bogus, using
reversed semantics for color.

No functional change

Resolves #262
2015-02-20 19:59:26 +00:00
snicolet 2f46592736 Mobile phalanxes
Try to create mobile phalanxes

STC:
LLR: 2.97 (-2.94,2.94) [-1.50,4.50]
Total: 52393 W: 10912 L: 10656 D: 30825

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,6.00]
Total: 30398 W: 5315 L: 5063 D: 20020

Bench: 8253813

Resolves #261
2015-02-20 19:56:57 +00:00
Marco Costalba 7ff965eebf Improve comments in SMP code
No functional change.
2015-02-20 12:38:54 +01:00
Marco Costalba a6f873cd8d Use range-based-for in late join
No functional change.
2015-02-20 10:50:47 +01:00
Marco Costalba 40548c9153 Sync with master
bench: 7911944
2015-02-20 10:37:29 +01:00
Marco Costalba 667f350737 Clarify we don't late join with only 2 threads
Thanks to Gary for pointing this out.

No functional change.
2015-02-19 23:12:59 +01:00
Marco Costalba 950c8436ed Use size_t consistently across thread code
No functional change.
2015-02-19 10:43:28 +01:00
Marco Costalba 8d47caa16e Retire redundant sp->slavesCount field
It should be used slavesMask.count() instead.

Verified 100% equivalent when sp->allSlavesSearching:

dbg_hit_on(sp->allSlavesSearching, sp->slavesCount != sp->slavesMask.count());

No functional change.
2015-02-19 10:36:15 +01:00
Marco Costalba b9d4e6f7fd Fix a warning under MSVC
Assignment of size_t to int.

No functional change.
2015-02-19 10:18:24 +01:00
Marco Costalba 193a7ae35b Add a couple of asserts to late join
Document and clarify that we cannot rejoin on ourselves
and that we never late join if we are master and all
slaves have finished, inded in this case we exit idle_loop.

No functional change.
2015-02-19 10:08:29 +01:00
Marco Costalba 4f906a2589 Remove useless condition in late join
In case of Threads.size() == 2 we have that sp->allSlavesSearching
is always false (because we have finished our search), bestSp is
always NULL and we never late join, so there is no need to special
case here.

Tested with dbg_hit_on(sp && sp->allSlavesSearching) and
verified it never fires.

No functional change.
2015-02-19 09:53:39 +01:00
Marco Costalba dccaa145d2 Compute SplitPoint::spLevel on the fly
And retire a redundant field. This is important also
from a concept point of view becuase we want to keep
SMP structures as simple as possible with the only
strictly necessary data.

Verified with

dbg_hit_on(sp->spLevel != level)

that the values are 100% the same out of more 50K samples.

No functional change.
2015-02-18 21:50:35 +01:00
Marco Costalba 6656ed8904 Simplify attackUnits formula
Use '/ 8' instead of '* 31 / 256'

Passed STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 55077 W: 10999 L: 10940 D: 33138

And LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 14751 W: 2530 L: 2400 D: 9821

bench: 7911944
2015-02-17 08:23:35 +01:00
Joona Kiiski d65f75c153 Improve smp performance for high number of threads
Balance threads between split points.

There are huge differences between different machines and autopurging makes it very difficult to measure the improvement in fishtest, but the following was recorded for 16 threads at 15+0.05:

    For Bravone (1000 games): 0 ELO
    For Glinscott (1000 games): +20 ELO
    For bKingUs (1000 games): +50 ELO
    For fastGM (1500 games): +50 ELO

The change was regression for no one, and a big improvement for some, so it should be fine to commit it.
Also for 8 threads at 15+0.05 we measured a statistically significant improvement:
ELO: 6.19 +-3.9 (95%) LOS: 99.9%
Total: 10325 W: 1824 L: 1640 D: 6861

Finally it was verified that there was no (significant) regression for

4 threads:
ELO: 0.09 +-2.8 (95%) LOS: 52.4%
Total: 19908 W: 3422 L: 3417 D: 13069

2 threads:
ELO: 0.38 +-3.0 (95%) LOS: 60.0%
Total: 19044 W: 3480 L: 3459 D: 12105

1 thread:
ELO: -1.27 +-2.1 (95%) LOS: 12.3%
Total: 40000 W: 7829 L: 7975 D: 24196

Resolves #258
2015-02-16 20:36:13 +00:00
lucasart f8f5dcbb68 Compute checkers from scratch
This micro-optimization only complicates the code and provides no benefit.
Removing it is even a speedup on my machine (i7-3770k, linux, gcc 4.9.1):

stat        test     master    diff
mean   2,403,118  2,390,904  12,214
stdev     12,043     10,620   3,677

speedup       0.51%
P(speedup>0) 100.0%

No functional change.
2015-02-16 09:34:26 +08:00
Marco Costalba 686b45e121 Retire one do_move() overload
After Lucas patch it is almost useless.

No functional change.
2015-02-15 12:23:03 +01:00
lucasart dc13004283 Compute checkers from scratch
This micro-optimization only complicates the code and provides no benefit.
Removing it is even a speedup on my machine (i7-3770k, linux, gcc 4.9.1):

stat        test     master    diff
mean   2,403,118  2,390,904  12,214
stdev     12,043     10,620   3,677

speedup       0.51%
P(speedup>0) 100.0%

No functional change.
2015-02-15 12:11:05 +01:00
Marco Costalba 901bfb1f55 Revert "Delayed killers checking"
It seems a slowdown when run with fishbench.

No functional change.
2015-02-15 11:32:53 +01:00
Marco Costalba 20a5c07472 Further simplify KingDanger init
And remove a tale whitespace while there.

No functional change.
2015-02-14 15:56:54 +01:00