mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
Avoid unnecessary allocations in AccumulatorStack
replacing the vector with an array resulted in a .45+-.10 % speedup. closes https://github.com/official-stockfish/Stockfish/pull/6352 no functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
fa3b4ef5af
commit
11ab4cde07
@@ -106,8 +106,6 @@ class Network {
|
||||
|
||||
template<IndexType Size>
|
||||
friend struct AccumulatorCaches::Cache;
|
||||
|
||||
friend class AccumulatorStack;
|
||||
};
|
||||
|
||||
// Definitions of the network types
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include "../types.h"
|
||||
#include "nnue_architecture.h"
|
||||
@@ -48,7 +47,7 @@ template<IndexType Size>
|
||||
struct alignas(CacheLineSize) Accumulator {
|
||||
std::int16_t accumulation[COLOR_NB][Size];
|
||||
std::int32_t psqtAccumulation[COLOR_NB][PSQTBuckets];
|
||||
std::array<bool, COLOR_NB> computed;
|
||||
std::array<bool, COLOR_NB> computed = {};
|
||||
};
|
||||
|
||||
|
||||
@@ -142,10 +141,6 @@ struct AccumulatorState {
|
||||
|
||||
class AccumulatorStack {
|
||||
public:
|
||||
AccumulatorStack() :
|
||||
accumulators(MAX_PLY + 1),
|
||||
size{1} {}
|
||||
|
||||
[[nodiscard]] const AccumulatorState& latest() const noexcept;
|
||||
|
||||
void reset() noexcept;
|
||||
@@ -178,8 +173,8 @@ class AccumulatorStack {
|
||||
const FeatureTransformer<Dimensions>& featureTransformer,
|
||||
const std::size_t end) noexcept;
|
||||
|
||||
std::vector<AccumulatorState> accumulators;
|
||||
std::size_t size;
|
||||
std::array<AccumulatorState, MAX_PLY + 1> accumulators;
|
||||
std::size_t size = 1;
|
||||
};
|
||||
|
||||
} // namespace Stockfish::Eval::NNUE
|
||||
|
||||
Reference in New Issue
Block a user