Prefetch pawn hash key

Plus a bunch of other minor optimizations.

With this power pack we have an increase
of a whopping 1.4%  :-)

...and it took 3 good hours of profiling + hacking to get it out !

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2010-08-21 19:57:52 +02:00
parent b6ba5f7fe4
commit 7b721b3663
7 changed files with 75 additions and 85 deletions

View File

@@ -229,10 +229,6 @@ namespace {
MaterialInfoTable* MaterialTable[MAX_THREADS];
PawnInfoTable* PawnTable[MAX_THREADS];
// Sizes of pawn and material hash tables
const int PawnTableSize = 16384;
const int MaterialTableSize = 1024;
// Function prototypes
template<bool HasPopCnt>
Value do_evaluate(const Position& pos, EvalInfo& ei);
@@ -268,6 +264,14 @@ namespace {
//// Functions
////
/// Prefetches in pawn hash tables
void prefetchPawn(Key key, int threadID) {
PawnTable[threadID]->prefetch(key);
}
/// evaluate() is the main evaluation function. It always computes two
/// values, an endgame score and a middle game score, and interpolates
/// between them based on the remaining material.
@@ -412,9 +416,9 @@ void init_eval(int threads) {
continue;
}
if (!PawnTable[i])
PawnTable[i] = new PawnInfoTable(PawnTableSize);
PawnTable[i] = new PawnInfoTable();
if (!MaterialTable[i])
MaterialTable[i] = new MaterialInfoTable(MaterialTableSize);
MaterialTable[i] = new MaterialInfoTable();
}
}
@@ -682,15 +686,11 @@ namespace {
Bitboard undefended, b, b1, b2, safe;
bool sente;
int attackUnits, shelter = 0;
int attackUnits;
const Square ksq = pos.king_square(Us);
// King shelter
if (relative_rank(Us, ksq) <= RANK_4)
{
shelter = ei.pi->get_king_shelter(pos, Us, ksq);
ei.value += Sign[Us] * make_score(shelter, 0);
}
ei.value += Sign[Us] * ei.pi->king_shelter(pos, Us, ksq);
// King safety. This is quite complicated, and is almost certainly far
// from optimally tuned.
@@ -717,7 +717,7 @@ namespace {
attackUnits = Min(25, (ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]) / 2)
+ 3 * (ei.kingAdjacentZoneAttacksCount[Them] + count_1s_max_15<HasPopCnt>(undefended))
+ InitKingDanger[relative_square(Us, ksq)]
- shelter / 32;
- mg_value(ei.pi->king_shelter(pos, Us, ksq)) / 32;
// Analyse enemy's safe queen contact checks. First find undefended
// squares around the king attacked by enemy queen...
@@ -779,7 +779,7 @@ namespace {
const Color Them = (Us == WHITE ? BLACK : WHITE);
Bitboard squaresToQueen, defendedSquares, unsafeSquares, supportingPawns;
Bitboard b = ei.pi->passed_pawns() & pos.pieces_of_color(Us);
Bitboard b = ei.pi->passed_pawns(Us);
while (b)
{