mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 05:07:46 +00:00
Use incremental updates more often
Use incremental updates for accumulators for up to 2 plies.
Do not copy accumulator. About 2% speedup.
Passed STC:
LLR: 2.95 (-2.94,2.94) {-0.25,1.25}
Total: 21752 W: 2583 L: 2403 D: 16766
Ptnml(0-2): 128, 1761, 6923, 1931, 133
https://tests.stockfishchess.org/tests/view/5f7150cf3b22d6afa5069412
closes https://github.com/official-stockfish/Stockfish/pull/3157
No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
1dbd2a1ad5
commit
c065abdcaf
@@ -127,9 +127,14 @@ namespace Eval::NNUE {
|
||||
return true;
|
||||
|
||||
const auto prev = now->previous;
|
||||
if (prev && prev->accumulator.computed_accumulation) {
|
||||
UpdateAccumulator(pos);
|
||||
return true;
|
||||
if (prev) {
|
||||
if (prev->accumulator.computed_accumulation) {
|
||||
UpdateAccumulator(pos);
|
||||
return true;
|
||||
} else if (prev->previous && prev->previous->accumulator.computed_accumulation) {
|
||||
UpdateAccumulator(pos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -289,11 +294,21 @@ namespace Eval::NNUE {
|
||||
// Calculate cumulative value using difference calculation
|
||||
void UpdateAccumulator(const Position& pos) const {
|
||||
|
||||
const auto prev_accumulator = pos.state()->previous->accumulator;
|
||||
Accumulator* prev_accumulator;
|
||||
assert(pos.state()->previous);
|
||||
if (pos.state()->previous->accumulator.computed_accumulation) {
|
||||
prev_accumulator = &pos.state()->previous->accumulator;
|
||||
}
|
||||
else {
|
||||
assert(pos.state()->previous->previous);
|
||||
assert(pos.state()->previous->previous->accumulator.computed_accumulation);
|
||||
prev_accumulator = &pos.state()->previous->previous->accumulator;
|
||||
}
|
||||
|
||||
auto& accumulator = pos.state()->accumulator;
|
||||
IndexType i = 0;
|
||||
Features::IndexList removed_indices[2], added_indices[2];
|
||||
bool reset[2];
|
||||
bool reset[2] = { false, false };
|
||||
RawFeatures::AppendChangedIndices(pos, kRefreshTriggers[i],
|
||||
removed_indices, added_indices, reset);
|
||||
|
||||
@@ -311,7 +326,7 @@ namespace Eval::NNUE {
|
||||
acc[k] = biasesTile[k];
|
||||
} else {
|
||||
auto prevAccTile = reinterpret_cast<const vec_t*>(
|
||||
&prev_accumulator.accumulation[perspective][i][j * kTileHeight]);
|
||||
&prev_accumulator->accumulation[perspective][i][j * kTileHeight]);
|
||||
for (IndexType k = 0; k < kNumRegs; ++k)
|
||||
acc[k] = vec_load(&prevAccTile[k]);
|
||||
|
||||
@@ -350,7 +365,7 @@ namespace Eval::NNUE {
|
||||
kHalfDimensions * sizeof(BiasType));
|
||||
} else {
|
||||
std::memcpy(accumulator.accumulation[perspective][i],
|
||||
prev_accumulator.accumulation[perspective][i],
|
||||
prev_accumulator->accumulation[perspective][i],
|
||||
kHalfDimensions * sizeof(BiasType));
|
||||
// Difference calculation for the deactivated features
|
||||
for (const auto index : removed_indices[perspective]) {
|
||||
|
||||
Reference in New Issue
Block a user