Small cleanups.
closes https://github.com/official-stockfish/Stockfish/pull/2532 Bench: 4869669pull/2547/head
parent
ddd4224640
commit
0c878adb36
|
@ -19,7 +19,6 @@
|
|||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
#include <bitset>
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
#ifndef ENDGAME_H_INCLUDED
|
||||
#define ENDGAME_H_INCLUDED
|
||||
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include "position.h"
|
||||
|
|
|
@ -520,7 +520,6 @@ namespace {
|
|||
}
|
||||
|
||||
// Bonus for restricting their piece moves
|
||||
// Greater bonus when landing square is occupied
|
||||
b = attackedBy[Them][ALL_PIECES]
|
||||
& ~stronglyProtected
|
||||
& attackedBy[Us][ALL_PIECES];
|
||||
|
@ -721,7 +720,6 @@ namespace {
|
|||
- 43 * almostUnwinnable
|
||||
-110 ;
|
||||
|
||||
// Give more importance to non-material score
|
||||
Value mg = mg_value(score);
|
||||
Value eg = eg_value(score);
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "bitboard.h"
|
||||
#include "endgame.h"
|
||||
#include "position.h"
|
||||
#include "search.h"
|
||||
#include "thread.h"
|
||||
#include "tt.h"
|
||||
#include "uci.h"
|
||||
#include "endgame.h"
|
||||
#include "syzygy/tbprobe.h"
|
||||
|
||||
namespace PSQT {
|
||||
|
|
14
src/misc.cpp
14
src/misc.cpp
|
@ -299,23 +299,23 @@ void prefetch(void* addr) {
|
|||
/// With c++17 some of this functionality can be simplified.
|
||||
#if defined(__linux__) && !defined(__ANDROID__)
|
||||
|
||||
void* aligned_ttmem_alloc(size_t allocSize, void** mem) {
|
||||
void* aligned_ttmem_alloc(size_t allocSize, void*& mem) {
|
||||
|
||||
constexpr size_t alignment = 2 * 1024 * 1024; // assumed 2MB page sizes
|
||||
size_t size = ((allocSize + alignment - 1) / alignment) * alignment; // multiple of alignment
|
||||
*mem = aligned_alloc(alignment, size);
|
||||
madvise(*mem, allocSize, MADV_HUGEPAGE);
|
||||
return *mem;
|
||||
mem = aligned_alloc(alignment, size);
|
||||
madvise(mem, allocSize, MADV_HUGEPAGE);
|
||||
return mem;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void* aligned_ttmem_alloc(size_t allocSize, void** mem) {
|
||||
void* aligned_ttmem_alloc(size_t allocSize, void*& mem) {
|
||||
|
||||
constexpr size_t alignment = 64; // assumed cache line size
|
||||
size_t size = allocSize + alignment - 1; // allocate some extra space
|
||||
*mem = malloc(size);
|
||||
void* ret = reinterpret_cast<void*>((uintptr_t(*mem) + alignment - 1) & ~uintptr_t(alignment - 1));
|
||||
mem = malloc(size);
|
||||
void* ret = reinterpret_cast<void*>((uintptr_t(mem) + alignment - 1) & ~uintptr_t(alignment - 1));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ const std::string engine_info(bool to_uci = false);
|
|||
const std::string compiler_info();
|
||||
void prefetch(void* addr);
|
||||
void start_logger(const std::string& fname);
|
||||
void* aligned_ttmem_alloc(size_t size, void** mem);
|
||||
void* aligned_ttmem_alloc(size_t size, void*& mem);
|
||||
|
||||
void dbg_hit_on(bool b);
|
||||
void dbg_hit_on(bool c, bool b);
|
||||
|
|
|
@ -52,7 +52,6 @@ namespace {
|
|||
template<Color Us, GenType Type>
|
||||
ExtMove* generate_pawn_moves(const Position& pos, ExtMove* moveList, Bitboard target) {
|
||||
|
||||
// Compute some compile time parameters relative to the white side
|
||||
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
|
||||
constexpr Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB);
|
||||
constexpr Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);
|
||||
|
|
|
@ -633,11 +633,11 @@ bool Position::gives_check(Move m) const {
|
|||
Square to = to_sq(m);
|
||||
|
||||
// Is there a direct check?
|
||||
if (st->checkSquares[type_of(piece_on(from))] & to)
|
||||
if (check_squares(type_of(piece_on(from))) & to)
|
||||
return true;
|
||||
|
||||
// Is there a discovered check?
|
||||
if ( (st->blockersForKing[~sideToMove] & from)
|
||||
if ( (blockers_for_king(~sideToMove) & from)
|
||||
&& !aligned(from, to, square<KING>(~sideToMove)))
|
||||
return true;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ Thread::~Thread() {
|
|||
|
||||
/// Thread::bestMoveCount(Move move) return best move counter for the given root move
|
||||
|
||||
int Thread::best_move_count(Move move) {
|
||||
int Thread::best_move_count(Move move) const {
|
||||
|
||||
auto rm = std::find(rootMoves.begin() + pvIdx,
|
||||
rootMoves.begin() + pvLast, move);
|
||||
|
@ -71,14 +71,13 @@ void Thread::clear() {
|
|||
captureHistory.fill(0);
|
||||
|
||||
for (bool inCheck : { false, true })
|
||||
for (StatsType c : { NoCaptures, Captures })
|
||||
for (auto& to : continuationHistory[inCheck][c])
|
||||
for (auto& h : to)
|
||||
h->fill(0);
|
||||
|
||||
for (bool inCheck : { false, true })
|
||||
for (StatsType c : { NoCaptures, Captures })
|
||||
continuationHistory[inCheck][c][NO_PIECE][0]->fill(Search::CounterMovePruneThreshold - 1);
|
||||
for (StatsType c : { NoCaptures, Captures })
|
||||
{
|
||||
for (auto& to : continuationHistory[inCheck][c])
|
||||
for (auto& h : to)
|
||||
h->fill(0);
|
||||
continuationHistory[inCheck][c][NO_PIECE][0]->fill(Search::CounterMovePruneThreshold - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// Thread::start_searching() wakes up the thread that will start the search
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
void idle_loop();
|
||||
void start_searching();
|
||||
void wait_for_search_finished();
|
||||
int best_move_count(Move move);
|
||||
int best_move_count(Move move) const;
|
||||
|
||||
Pawns::Table pawnsTable;
|
||||
Material::Table materialTable;
|
||||
|
|
|
@ -66,7 +66,7 @@ void TranspositionTable::resize(size_t mbSize) {
|
|||
free(mem);
|
||||
|
||||
clusterCount = mbSize * 1024 * 1024 / sizeof(Cluster);
|
||||
table = static_cast<Cluster*>(aligned_ttmem_alloc(clusterCount * sizeof(Cluster), &mem));
|
||||
table = static_cast<Cluster*>(aligned_ttmem_alloc(clusterCount * sizeof(Cluster), mem));
|
||||
if (!mem)
|
||||
{
|
||||
std::cerr << "Failed to allocate " << mbSize
|
||||
|
|
Loading…
Reference in New Issue