Revert thread_local stuff

Unfortunatly accessing thread local variable
is much slower than object data (see previous
patch log msg), so we have to revert to old code
to avoid speed regression.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2012-04-06 18:36:46 +01:00
parent b1f57e92ce
commit c2fc80e5d1
10 changed files with 42 additions and 40 deletions

View File

@@ -92,17 +92,19 @@ CheckInfo::CheckInfo(const Position& pos) {
}
/// Position::operator=() creates a copy of 'pos'. We want the new born Position
/// Position::copy() creates a copy of 'pos'. We want the new born Position
/// object do not depend on any external data so we detach state pointer from
/// the source one.
Position& Position::operator=(const Position& pos) {
void Position::copy(const Position& pos, Thread* th) {
memcpy(this, &pos, sizeof(Position));
startState = *st;
st = &startState;
thisThread = th;
nodes = 0;
return *this;
assert(pos_is_ok());
}
@@ -110,7 +112,7 @@ Position& Position::operator=(const Position& pos) {
/// string. This function is not very robust - make sure that input FENs are
/// correct (this is assumed to be the responsibility of the GUI).
void Position::from_fen(const string& fenStr, bool isChess960) {
void Position::from_fen(const string& fenStr, bool isChess960, Thread* th) {
/*
A FEN string defines a particular position using only the ASCII character set.
@@ -226,6 +228,7 @@ void Position::from_fen(const string& fenStr, bool isChess960) {
st->npMaterial[BLACK] = compute_non_pawn_material(BLACK);
st->checkersBB = attackers_to(king_square(sideToMove)) & pieces(~sideToMove);
chess960 = isChess960;
thisThread = th;
assert(pos_is_ok());
}
@@ -328,7 +331,7 @@ void Position::print(Move move) const {
if (move)
{
Position p(*this);
Position p(*this, thisThread);
cout << "\nMove is: " << (sideToMove == BLACK ? ".." : "") << move_to_san(p, move);
}
@@ -895,8 +898,8 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
}
// Prefetch pawn and material hash tables
prefetch((char*)this_thread->pawnTable.entries[st->pawnKey]);
prefetch((char*)this_thread->materialTable.entries[st->materialKey]);
prefetch((char*)thisThread->pawnTable.entries[st->pawnKey]);
prefetch((char*)thisThread->materialTable.entries[st->materialKey]);
// Update incremental scores
st->psqScore += psq_delta(piece, from, to);
@@ -1538,9 +1541,10 @@ void Position::init() {
void Position::flip() {
// Make a copy of current position before to start changing
const Position pos(*this);
const Position pos(*this, thisThread);
clear();
thisThread = pos.this_thread();
// Board
for (Square s = SQ_A1; s <= SQ_H8; s++)