1
0
Fork 0

Merge branch 'master' into feature/add_cpu_uci_command_and_runtime_info

pull/3602/head
JackWright347 2021-07-22 15:25:12 +02:00
commit 6c55b07111
12 changed files with 33 additions and 30 deletions

View File

@ -177,14 +177,14 @@ namespace {
occupancy[size] = b;
reference[size] = sliding_attack(pt, s, b);
if (HasPext)
if constexpr (HasPext)
m.attacks[pext(b, m.mask)] = reference[size];
size++;
b = (b - m.mask) & m.mask;
} while (b);
if (HasPext)
if constexpr (HasPext)
continue;
PRNG rng(seeds[Is64Bit][rank_of(s)]);

View File

@ -91,10 +91,10 @@ struct Magic {
// Compute the attack's index using the 'magic bitboards' approach
unsigned index(Bitboard occupied) const {
if (HasPext)
if constexpr (HasPext)
return unsigned(pext(occupied, mask));
if (Is64Bit)
if constexpr (Is64Bit)
return unsigned(((occupied & mask) * magic) >> shift);
unsigned lo = unsigned(occupied) & unsigned(mask);

View File

@ -253,7 +253,9 @@ std::string compiler_info() {
#if defined(USE_SSE2)
compiler += " SSE2";
#endif
compiler += (HasPopCnt ? " POPCNT" : "");
#if defined(USE_POPCNT)
compiler += " POPCNT";
#endif
#if defined(USE_MMX)
compiler += " MMX";
#endif

View File

@ -109,7 +109,7 @@ namespace Stockfish::Eval::NNUE {
{
write_little_endian<std::uint32_t>(stream, Version);
write_little_endian<std::uint32_t>(stream, hashValue);
write_little_endian<std::uint32_t>(stream, desc.size());
write_little_endian<std::uint32_t>(stream, static_cast<uint32_t>(desc.size()));
stream.write(&desc[0], desc.size());
return !stream.fail();
}

View File

@ -175,9 +175,11 @@ namespace Stockfish::Eval::NNUE::Layers {
constexpr IndexType Start = 0;
#endif
for (IndexType i = Start; i < InputDimensions; ++i) {
output[i] = static_cast<OutputType>(
std::max(0, std::min(127, input[i] >> WeightScaleBits)));
if constexpr (Start < InputDimensions) {
for (IndexType i = Start; i < InputDimensions; ++i) {
output[i] = static_cast<OutputType>(
std::max(0, std::min(127, input[i] >> WeightScaleBits)));
}
}
return output;
}

View File

@ -123,8 +123,10 @@ namespace Stockfish::Eval::NNUE {
// We use __m* types as template arguments, which causes GCC to emit warnings
// about losing some attribute information. This is irrelevant to us as we
// only take their size, so the following pragma are harmless.
#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-attributes"
#endif
template <typename SIMDRegisterType,
typename LaneType,
@ -157,7 +159,9 @@ namespace Stockfish::Eval::NNUE {
static constexpr int NumRegs = BestRegisterCount<vec_t, WeightType, TransformedFeatureDimensions, NumRegistersSIMD>();
static constexpr int NumPsqtRegs = BestRegisterCount<psqt_vec_t, PSQTWeightType, PSQTBuckets, NumRegistersSIMD>();
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif
#endif
@ -215,7 +219,7 @@ namespace Stockfish::Eval::NNUE {
}
// Convert input features
std::int32_t transform(const Position& pos, OutputType* output, int bucket) const {
std::int32_t transform(const Position& pos, OutputType* output, std::size_t bucket) const {
update_accumulator(pos, WHITE);
update_accumulator(pos, BLACK);

View File

@ -1080,8 +1080,9 @@ bool Position::see_ge(Move m, Value threshold) const {
if (swap <= 0)
return true;
assert(color_of(piece_on(from)) == sideToMove);
Bitboard occupied = pieces() ^ from ^ to;
Color stm = color_of(piece_on(from));
Color stm = sideToMove;
Bitboard attackers = attackers_to(to, occupied);
Bitboard stmAttackers, bb;
int res = 1;

View File

@ -223,9 +223,9 @@ void MainThread::search() {
Thread* bestThread = this;
if ( int(Options["MultiPV"]) == 1
if (static_cast<int>(Options["MultiPV"]) == 1
&& !Limits.depth
&& !(Skill(Options["Skill Level"]).enabled() || int(Options["UCI_LimitStrength"]))
&& !(Skill(static_cast<int>(Options["Skill Level"])).enabled() || static_cast<int>(Options["UCI_LimitStrength"]))
&& rootMoves[0].pv[0] != MOVE_NONE)
bestThread = Threads.get_best_thread();
@ -760,6 +760,7 @@ namespace {
ss->staticEval = eval = -(ss-1)->staticEval;
// Save static evaluation into transposition table
if(!excludedMove)
tte->save(posKey, VALUE_NONE, ss->ttPv, BOUND_NONE, DEPTH_NONE, MOVE_NONE, eval);
}
@ -780,7 +781,6 @@ namespace {
// Step 7. Futility pruning: child node (~50 Elo)
if ( !PvNode
&& depth < 9
&& eval - futility_margin(depth, improving) >= beta
&& eval < VALUE_KNOWN_WIN) // Do not return unproven wins
return eval;
@ -1022,8 +1022,7 @@ moves_loop: // When in check, search starts from here
continue;
// Futility pruning: parent node (~5 Elo)
if ( lmrDepth < 7
&& !ss->inCheck
if ( !ss->inCheck
&& ss->staticEval + 174 + 157 * lmrDepth <= alpha
&& (*contHist[0])[movedPiece][to_sq(move)]
+ (*contHist[1])[movedPiece][to_sq(move)]

View File

@ -74,7 +74,7 @@ struct RootMove {
Value previousScore = -VALUE_INFINITE;
int selDepth = 0;
int tbRank = 0;
Value tbScore;
Value tbScore = -VALUE_INFINITE;
std::vector<Move> pv;
};
@ -87,7 +87,7 @@ typedef std::vector<RootMove> RootMoves;
struct LimitsType {
LimitsType() { // Init explicitly due to broken value-initialization of non POD in MSVC
time[WHITE] = time[BLACK] = inc[WHITE] = inc[BLACK] = npmsec = movetime = TimePoint(0);
time[WHITE] = time[BLACK] = inc[WHITE] = inc[BLACK] = npmsec = movetime = startTime = TimePoint(0);
movestogo = depth = mate = perft = infinite = 0;
nodes = 0;
}

View File

@ -202,7 +202,8 @@ void ThreadPool::start_thinking(Position& pos, StateListPtr& states,
// since they are read-only.
for (Thread* th : *this)
{
th->nodes = th->tbHits = th->nmpMinPly = th->bestMoveChanges = 0;
th->selDepth = th->nmpMinPly = 0;
th->nodes = th->tbHits = th->bestMoveChanges = 0;
th->rootDepth = th->completedDepth = 0;
th->rootMoves = rootMoves;
th->rootPos.set(pos.fen(), pos.is_chess960(), &th->rootState, th);

View File

@ -85,12 +85,6 @@
namespace Stockfish {
#ifdef USE_POPCNT
constexpr bool HasPopCnt = true;
#else
constexpr bool HasPopCnt = false;
#endif
#ifdef USE_PEXT
constexpr bool HasPext = true;
#else

View File

@ -113,19 +113,19 @@ std::ostream& operator<<(std::ostream& os, const OptionsMap& om) {
/// Option class constructors and conversion operators
Option::Option(const char* v, OnChange f) : type("string"), min(0), max(0), on_change(f)
Option::Option(const char* v, OnChange f) : type("string"), min(0), max(0), idx(0), on_change(f)
{ defaultValue = currentValue = v; }
Option::Option(bool v, OnChange f) : type("check"), min(0), max(0), on_change(f)
Option::Option(bool v, OnChange f) : type("check"), min(0), max(0), idx(0), on_change(f)
{ defaultValue = currentValue = (v ? "true" : "false"); }
Option::Option(OnChange f) : type("button"), min(0), max(0), on_change(f)
Option::Option(OnChange f) : type("button"), min(0), max(0), idx(0), on_change(f)
{}
Option::Option(double v, int minv, int maxv, OnChange f) : type("spin"), min(minv), max(maxv), on_change(f)
Option::Option(double v, int minv, int maxv, OnChange f) : type("spin"), min(minv), max(maxv), idx(0), on_change(f)
{ defaultValue = currentValue = std::to_string(v); }
Option::Option(const char* v, const char* cur, OnChange f) : type("combo"), min(0), max(0), on_change(f)
Option::Option(const char* v, const char* cur, OnChange f) : type("combo"), min(0), max(0), idx(0), on_change(f)
{ defaultValue = v; currentValue = cur; }
Option::operator double() const {