mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 14:27:45 +00:00
Simplify accumulator updates
AMD Ryzen 5 7600X ``` sf_base = 1902646 +/- 2114 (95%) sf_test = 1920873 +/- 2515 (95%) diff = 18227 +/- 3067 (95%) speedup = 0.95800% +/- 0.161% (95%) ``` Ryzen 9 5950X ``` sf_base = 1413387 +/- 3592 (95%) sf_test = 1437893 +/- 3355 (95%) diff = 24505 +/- 4669 (95%) speedup = 1.73380% +/- 0.330% (95%) ``` Intel Core i7-6700K ``` sf_base = 912476 +/- 1863 (95%) sf_test = 921864 +/- 2042 (95%) diff = 9388 +/- 3333 (95%) speedup = 1.02893% +/- 0.365% (95%) ``` Raspberry Pi 5 ``` sf_base = 260993 +/- 1508 (95%) sf_test = 262912 +/- 1746 (95%) diff = 1918 +/- 1221 (95%) speedup = 0.73504% +/- 0.468% (95%) ``` Passed Non-regression STC: LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 23072 W: 6041 L: 5813 D: 11218 Ptnml(0-2): 61, 2435, 6319, 2657, 64 https://tests.stockfishchess.org/tests/view/6780a0ca9168c8bf30927757 closes https://github.com/official-stockfish/Stockfish/pull/5759 No functional change
This commit is contained in:
@@ -472,9 +472,8 @@ class FeatureTransformer {
|
|||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
// It computes the accumulator of the next position, or updates the
|
// Computes the accumulator of the next position.
|
||||||
// current position's accumulator if CurrentOnly is true.
|
template<Color Perspective>
|
||||||
template<Color Perspective, bool CurrentOnly>
|
|
||||||
void update_accumulator_incremental(const Position& pos, StateInfo* computed) const {
|
void update_accumulator_incremental(const Position& pos, StateInfo* computed) const {
|
||||||
assert((computed->*accPtr).computed[Perspective]);
|
assert((computed->*accPtr).computed[Perspective]);
|
||||||
assert(computed->next != nullptr);
|
assert(computed->next != nullptr);
|
||||||
@@ -493,16 +492,10 @@ class FeatureTransformer {
|
|||||||
// feature set's update cost calculation to be correct and never allow
|
// feature set's update cost calculation to be correct and never allow
|
||||||
// updates with more added/removed features than MaxActiveDimensions.
|
// updates with more added/removed features than MaxActiveDimensions.
|
||||||
FeatureSet::IndexList removed, added;
|
FeatureSet::IndexList removed, added;
|
||||||
|
FeatureSet::append_changed_indices<Perspective>(ksq, computed->next->dirtyPiece, removed,
|
||||||
|
added);
|
||||||
|
|
||||||
if constexpr (CurrentOnly)
|
StateInfo* next = computed->next;
|
||||||
for (StateInfo* st = pos.state(); st != computed; st = st->previous)
|
|
||||||
FeatureSet::append_changed_indices<Perspective>(ksq, st->dirtyPiece, removed,
|
|
||||||
added);
|
|
||||||
else
|
|
||||||
FeatureSet::append_changed_indices<Perspective>(ksq, computed->next->dirtyPiece,
|
|
||||||
removed, added);
|
|
||||||
|
|
||||||
StateInfo* next = CurrentOnly ? pos.state() : computed->next;
|
|
||||||
assert(!(next->*accPtr).computed[Perspective]);
|
assert(!(next->*accPtr).computed[Perspective]);
|
||||||
|
|
||||||
#ifdef VECTOR
|
#ifdef VECTOR
|
||||||
@@ -665,8 +658,8 @@ class FeatureTransformer {
|
|||||||
|
|
||||||
(next->*accPtr).computed[Perspective] = true;
|
(next->*accPtr).computed[Perspective] = true;
|
||||||
|
|
||||||
if (!CurrentOnly && next != pos.state())
|
if (next != pos.state())
|
||||||
update_accumulator_incremental<Perspective, false>(pos, next);
|
update_accumulator_incremental<Perspective>(pos, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<Color Perspective>
|
template<Color Perspective>
|
||||||
@@ -844,7 +837,7 @@ class FeatureTransformer {
|
|||||||
StateInfo* oldest = try_find_computed_accumulator<Perspective>(pos);
|
StateInfo* oldest = try_find_computed_accumulator<Perspective>(pos);
|
||||||
|
|
||||||
if ((oldest->*accPtr).computed[Perspective] && oldest != pos.state())
|
if ((oldest->*accPtr).computed[Perspective] && oldest != pos.state())
|
||||||
update_accumulator_incremental<Perspective, true>(pos, oldest);
|
update_accumulator_incremental<Perspective>(pos, oldest);
|
||||||
else
|
else
|
||||||
update_accumulator_refresh_cache<Perspective>(pos, cache);
|
update_accumulator_refresh_cache<Perspective>(pos, cache);
|
||||||
}
|
}
|
||||||
@@ -858,7 +851,7 @@ class FeatureTransformer {
|
|||||||
if ((oldest->*accPtr).computed[Perspective] && oldest != pos.state())
|
if ((oldest->*accPtr).computed[Perspective] && oldest != pos.state())
|
||||||
// Start from the oldest computed accumulator, update all the
|
// Start from the oldest computed accumulator, update all the
|
||||||
// accumulators up to the current position.
|
// accumulators up to the current position.
|
||||||
update_accumulator_incremental<Perspective, false>(pos, oldest);
|
update_accumulator_incremental<Perspective>(pos, oldest);
|
||||||
else
|
else
|
||||||
update_accumulator_refresh_cache<Perspective>(pos, cache);
|
update_accumulator_refresh_cache<Perspective>(pos, cache);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user