- // Calculate cumulative value without using difference calculation
- void RefreshAccumulator(const Position& pos) const {
-
- auto& accumulator = pos.state()->accumulator;
- IndexType i = 0;
- Features::IndexList active_indices[2];
- RawFeatures::AppendActiveIndices(pos, kRefreshTriggers[i],
- active_indices);
- for (Color perspective : { WHITE, BLACK }) {
- #ifdef TILING
- for (unsigned j = 0; j < kHalfDimensions / kTileHeight; ++j) {
- auto biasesTile = reinterpret_cast<const vec_t*>(
- &biases_[j * kTileHeight]);
- auto accTile = reinterpret_cast<vec_t*>(
- &accumulator.accumulation[perspective][i][j * kTileHeight]);
- vec_t acc[kNumRegs];
-
- for (unsigned k = 0; k < kNumRegs; ++k)
- acc[k] = biasesTile[k];
-
- for (const auto index : active_indices[perspective]) {
- const IndexType offset = kHalfDimensions * index + j * kTileHeight;
- auto column = reinterpret_cast<const vec_t*>(&weights_[offset]);
-
- for (unsigned k = 0; k < kNumRegs; ++k)
- acc[k] = vec_add_16(acc[k], column[k]);
- }
-
- for (unsigned k = 0; k < kNumRegs; k++)
- vec_store(&accTile[k], acc[k]);
- }
- #else
- std::memcpy(accumulator.accumulation[perspective][i], biases_,
- kHalfDimensions * sizeof(BiasType));
-
- for (const auto index : active_indices[perspective]) {
- const IndexType offset = kHalfDimensions * index;
-
- for (IndexType j = 0; j < kHalfDimensions; ++j)
- accumulator.accumulation[perspective][i][j] += weights_[offset + j];
- }
+ void update_accumulator(const Position& pos, const Color perspective) const {
+
+ // The size must be enough to contain the largest possible update.
+ // That might depend on the feature set and generally relies on the
+ // feature set's update cost calculation to be correct and never
+ // allow updates with more added/removed features than MaxActiveDimensions.
+ using IndexList = ValueList<IndexType, FeatureSet::MaxActiveDimensions>;
+
+ #ifdef VECTOR
+ // Gcc-10.2 unnecessarily spills AVX2 registers if this array
+ // is defined in the VECTOR code below, once in each branch
+ vec_t acc[NumRegs];