mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 16:47:37 +00:00
Reduce the number of accumulator states
Reduce from 3 to 2. Make the intent of the states clearer. STC: https://tests.stockfishchess.org/tests/view/60c50111457376eb8bcaad03 LLR: 2.95 (-2.94,2.94) <-2.50,0.50> Total: 61888 W: 5007 L: 4944 D: 51937 Ptnml(0-2): 164, 3947, 22649, 4030, 154 LTC: https://tests.stockfishchess.org/tests/view/60c52b1c457376eb8bcaad2c LLR: 2.94 (-2.94,2.94) <-2.50,0.50> Total: 20248 W: 688 L: 618 D: 18942 Ptnml(0-2): 7, 551, 8946, 605, 15 closes https://github.com/official-stockfish/Stockfish/pull/3548 No functional change.
This commit is contained in:
committed by
Joost VandeVondele
parent
f8c779dbe5
commit
900f249f59
@@ -25,14 +25,11 @@
|
||||
|
||||
namespace Stockfish::Eval::NNUE {
|
||||
|
||||
// The accumulator of a StateInfo without parent is set to the INIT state
|
||||
enum AccumulatorState { EMPTY, COMPUTED, INIT };
|
||||
|
||||
// Class that holds the result of affine transformation of input features
|
||||
struct alignas(CacheLineSize) Accumulator {
|
||||
std::int16_t accumulation[2][TransformedFeatureDimensions];
|
||||
std::int32_t psqtAccumulation[2][PSQTBuckets];
|
||||
AccumulatorState state[2];
|
||||
bool computed[2];
|
||||
};
|
||||
|
||||
} // namespace Stockfish::Eval::NNUE
|
||||
|
||||
@@ -383,7 +383,7 @@ namespace Stockfish::Eval::NNUE {
|
||||
// of the estimated gain in terms of features to be added/subtracted.
|
||||
StateInfo *st = pos.state(), *next = nullptr;
|
||||
int gain = FeatureSet::refresh_cost(pos);
|
||||
while (st->accumulator.state[perspective] == EMPTY)
|
||||
while (st->previous && !st->accumulator.computed[perspective])
|
||||
{
|
||||
// This governs when a full feature refresh is needed and how many
|
||||
// updates are better than just one full refresh.
|
||||
@@ -394,7 +394,7 @@ namespace Stockfish::Eval::NNUE {
|
||||
st = st->previous;
|
||||
}
|
||||
|
||||
if (st->accumulator.state[perspective] == COMPUTED)
|
||||
if (st->accumulator.computed[perspective])
|
||||
{
|
||||
if (next == nullptr)
|
||||
return;
|
||||
@@ -412,8 +412,8 @@ namespace Stockfish::Eval::NNUE {
|
||||
ksq, st2, perspective, removed[1], added[1]);
|
||||
|
||||
// Mark the accumulators as computed.
|
||||
next->accumulator.state[perspective] = COMPUTED;
|
||||
pos.state()->accumulator.state[perspective] = COMPUTED;
|
||||
next->accumulator.computed[perspective] = true;
|
||||
pos.state()->accumulator.computed[perspective] = true;
|
||||
|
||||
// Now update the accumulators listed in states_to_update[], where the last element is a sentinel.
|
||||
StateInfo *states_to_update[3] =
|
||||
@@ -533,7 +533,7 @@ namespace Stockfish::Eval::NNUE {
|
||||
{
|
||||
// Refresh the accumulator
|
||||
auto& accumulator = pos.state()->accumulator;
|
||||
accumulator.state[perspective] = COMPUTED;
|
||||
accumulator.computed[perspective] = true;
|
||||
IndexList active;
|
||||
FeatureSet::append_active_indices(pos, perspective, active);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user