mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Avoid using EmptySearchStack global
This reduces contention in SMP case and also cleanups the code a bit. No functional change Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
5b1316f7bb
commit
e1ed67aacb
5 changed files with 16 additions and 21 deletions
|
@ -63,13 +63,18 @@ namespace {
|
||||||
/// search captures, promotions and some checks) and about how important good
|
/// search captures, promotions and some checks) and about how important good
|
||||||
/// move ordering is at the current node.
|
/// move ordering is at the current node.
|
||||||
|
|
||||||
MovePicker::MovePicker(const Position& p, bool pv, Move ttm,
|
MovePicker::MovePicker(const Position& p, bool pv, Move ttm, Depth d, SearchStack* ss) : pos(p) {
|
||||||
const SearchStack& ss, Depth d) : pos(p) {
|
|
||||||
pvNode = pv;
|
pvNode = pv;
|
||||||
ttMove = ttm;
|
ttMove = ttm;
|
||||||
mateKiller = (ss.mateKiller == ttm)? MOVE_NONE : ss.mateKiller;
|
if (ss)
|
||||||
killer1 = ss.killers[0];
|
{
|
||||||
killer2 = ss.killers[1];
|
mateKiller = (ss->mateKiller == ttm)? MOVE_NONE : ss->mateKiller;
|
||||||
|
killer1 = ss->killers[0];
|
||||||
|
killer2 = ss->killers[1];
|
||||||
|
} else
|
||||||
|
mateKiller = killer1 = killer2 = MOVE_NONE;
|
||||||
|
|
||||||
depth = d;
|
depth = d;
|
||||||
movesPicked = 0;
|
movesPicked = 0;
|
||||||
numOfMoves = 0;
|
numOfMoves = 0;
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
struct EvalInfo;
|
struct EvalInfo;
|
||||||
struct SearchStack;
|
struct SearchStack;
|
||||||
|
|
||||||
extern SearchStack EmptySearchStack;
|
|
||||||
|
|
||||||
/// MovePicker is a class which is used to pick one legal move at a time from
|
/// MovePicker is a class which is used to pick one legal move at a time from
|
||||||
/// the current position. It is initialized with a Position object and a few
|
/// the current position. It is initialized with a Position object and a few
|
||||||
/// moves we have reason to believe are good. The most important method is
|
/// moves we have reason to believe are good. The most important method is
|
||||||
|
@ -66,7 +64,7 @@ public:
|
||||||
PH_STOP
|
PH_STOP
|
||||||
};
|
};
|
||||||
|
|
||||||
MovePicker(const Position& p, bool pvnode, Move ttm, const SearchStack& ss, Depth d);
|
MovePicker(const Position& p, bool pvnode, Move ttm, Depth d, SearchStack* ss = NULL);
|
||||||
Move get_next_move();
|
Move get_next_move();
|
||||||
Move get_next_move(Lock& lock);
|
Move get_next_move(Lock& lock);
|
||||||
int number_of_moves() const;
|
int number_of_moves() const;
|
||||||
|
|
|
@ -143,7 +143,7 @@ Move move_from_san(const Position& pos, const string& movestr) {
|
||||||
|
|
||||||
assert(pos.is_ok());
|
assert(pos.is_ok());
|
||||||
|
|
||||||
MovePicker mp = MovePicker(pos, false, MOVE_NONE, EmptySearchStack, OnePly);
|
MovePicker mp = MovePicker(pos, false, MOVE_NONE, OnePly);
|
||||||
|
|
||||||
// Castling moves
|
// Castling moves
|
||||||
if (movestr == "O-O-O" || movestr == "O-O-O+")
|
if (movestr == "O-O-O" || movestr == "O-O-O+")
|
||||||
|
@ -367,7 +367,7 @@ namespace {
|
||||||
if (type_of_piece(pc) == KING)
|
if (type_of_piece(pc) == KING)
|
||||||
return AMBIGUITY_NONE;
|
return AMBIGUITY_NONE;
|
||||||
|
|
||||||
MovePicker mp = MovePicker(pos, false, MOVE_NONE, EmptySearchStack, OnePly);
|
MovePicker mp = MovePicker(pos, false, MOVE_NONE, OnePly);
|
||||||
Move mv, moveList[8];
|
Move mv, moveList[8];
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
|
@ -332,9 +332,6 @@ Lock IOLock;
|
||||||
|
|
||||||
History H; // Should be made local?
|
History H; // Should be made local?
|
||||||
|
|
||||||
// The empty search stack
|
|
||||||
SearchStack EmptySearchStack;
|
|
||||||
|
|
||||||
|
|
||||||
// SearchStack::init() initializes a search stack. Used at the beginning of a
|
// SearchStack::init() initializes a search stack. Used at the beginning of a
|
||||||
// new search from the root.
|
// new search from the root.
|
||||||
|
@ -597,10 +594,6 @@ void init_threads() {
|
||||||
// Wait until the thread has finished launching:
|
// Wait until the thread has finished launching:
|
||||||
while (!Threads[i].running);
|
while (!Threads[i].running);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init also the empty search stack
|
|
||||||
EmptySearchStack.init(0);
|
|
||||||
EmptySearchStack.initKillers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1063,7 +1056,7 @@ namespace {
|
||||||
|
|
||||||
// Initialize a MovePicker object for the current position, and prepare
|
// Initialize a MovePicker object for the current position, and prepare
|
||||||
// to search all moves
|
// to search all moves
|
||||||
MovePicker mp = MovePicker(pos, true, ttMove, ss[ply], depth);
|
MovePicker mp = MovePicker(pos, true, ttMove, depth, &ss[ply]);
|
||||||
|
|
||||||
Move move, movesSearched[256];
|
Move move, movesSearched[256];
|
||||||
int moveCount = 0;
|
int moveCount = 0;
|
||||||
|
@ -1324,7 +1317,7 @@ namespace {
|
||||||
|
|
||||||
// Initialize a MovePicker object for the current position, and prepare
|
// Initialize a MovePicker object for the current position, and prepare
|
||||||
// to search all moves:
|
// to search all moves:
|
||||||
MovePicker mp = MovePicker(pos, false, ttMove, ss[ply], depth);
|
MovePicker mp = MovePicker(pos, false, ttMove, depth, &ss[ply]);
|
||||||
|
|
||||||
Move move, movesSearched[256];
|
Move move, movesSearched[256];
|
||||||
int moveCount = 0;
|
int moveCount = 0;
|
||||||
|
@ -1545,7 +1538,7 @@ namespace {
|
||||||
// Initialize a MovePicker object for the current position, and prepare
|
// Initialize a MovePicker object for the current position, and prepare
|
||||||
// to search the moves. Because the depth is <= 0 here, only captures,
|
// to search the moves. Because the depth is <= 0 here, only captures,
|
||||||
// queen promotions and checks (only if depth == 0) will be generated.
|
// queen promotions and checks (only if depth == 0) will be generated.
|
||||||
MovePicker mp = MovePicker(pos, pvNode, ttMove, EmptySearchStack, depth);
|
MovePicker mp = MovePicker(pos, pvNode, ttMove, depth);
|
||||||
Move move;
|
Move move;
|
||||||
int moveCount = 0;
|
int moveCount = 0;
|
||||||
Bitboard dcCandidates = mp.discovered_check_candidates();
|
Bitboard dcCandidates = mp.discovered_check_candidates();
|
||||||
|
|
|
@ -69,7 +69,6 @@ struct SearchStack {
|
||||||
//// Global variables
|
//// Global variables
|
||||||
////
|
////
|
||||||
|
|
||||||
extern SearchStack EmptySearchStack;
|
|
||||||
extern TranspositionTable TT;
|
extern TranspositionTable TT;
|
||||||
extern int ActiveThreads;
|
extern int ActiveThreads;
|
||||||
extern Lock SMPLock;
|
extern Lock SMPLock;
|
||||||
|
|
Loading…
Add table
Reference in a new issue