diff --git a/src/nnue/features/full_threats.cpp b/src/nnue/features/full_threats.cpp index 122478dc6..9c818a8e0 100644 --- a/src/nnue/features/full_threats.cpp +++ b/src/nnue/features/full_threats.cpp @@ -126,20 +126,15 @@ void init_threat_offsets() { } // Index of a feature for a given king position and another piece on some square -inline sf_always_inline -IndexType FullThreats::make_index(Color perspective, - Piece attacker, - Square from, - Square to, - Piece attacked, - Square ksq) { +inline sf_always_inline IndexType FullThreats::make_index( + Color perspective, Piece attacker, Square from, Square to, Piece attacked, Square ksq) { const int orientation = OrientTBL[perspective][ksq]; - from = Square(int(from) ^ orientation); - to = Square(int(to) ^ orientation); + from = Square(int(from) ^ orientation); + to = Square(int(to) ^ orientation); std::int8_t swap = 8 * perspective; - attacker = Piece(attacker ^ swap); - attacked = Piece(attacked ^ swap); + attacker = Piece(attacker ^ swap); + attacked = Piece(attacked ^ swap); const auto piecePairData = index_lut1[attacker][attacked]; @@ -147,8 +142,8 @@ IndexType FullThreats::make_index(Color perspective, if ((piecePairData.excluded_pair_info() + less_than) & 2) return FullThreats::Dimensions; - const IndexType index = piecePairData.feature_index_base() + offsets[attacker][from] - + index_lut2[attacker][from][to]; + const IndexType index = + piecePairData.feature_index_base() + offsets[attacker][from] + index_lut2[attacker][from][to]; sf_assume(index != FullThreats::Dimensions); return index; @@ -156,13 +151,11 @@ IndexType FullThreats::make_index(Color perspective, // Get a list of indices for active features in ascending order -void FullThreats::append_active_indices(Color perspective, - const Position& pos, - IndexList& active) { +void FullThreats::append_active_indices(Color perspective, const Position& pos, IndexList& active) { static constexpr Color order[2][2] = {{WHITE, BLACK}, {BLACK, WHITE}}; - Square ksq = pos.square(perspective); - Bitboard occupied = pos.pieces(); + Square ksq = pos.square(perspective); + Bitboard occupied = pos.pieces(); for (Color color : {WHITE, BLACK}) { @@ -186,7 +179,7 @@ void FullThreats::append_active_indices(Color perspective, Square to = pop_lsb(attacks_left); Square from = to - right; Piece attacked = pos.piece_on(to); - IndexType index = make_index(perspective, attacker, from, to, attacked, ksq); + IndexType index = make_index(perspective, attacker, from, to, attacked, ksq); if (index < Dimensions) active.push_back(index); @@ -197,7 +190,7 @@ void FullThreats::append_active_indices(Color perspective, Square to = pop_lsb(attacks_right); Square from = to - left; Piece attacked = pos.piece_on(to); - IndexType index = make_index(perspective, attacker, from, to, attacked, ksq); + IndexType index = make_index(perspective, attacker, from, to, attacked, ksq); if (index < Dimensions) active.push_back(index); @@ -214,8 +207,8 @@ void FullThreats::append_active_indices(Color perspective, { Square to = pop_lsb(attacks); Piece attacked = pos.piece_on(to); - IndexType index = make_index( - perspective, attacker, from, to, attacked, ksq); + IndexType index = + make_index(perspective, attacker, from, to, attacked, ksq); if (index < Dimensions) active.push_back(index); @@ -275,8 +268,7 @@ void FullThreats::append_changed_indices(Color perspective, } } - const IndexType index = make_index(perspective, - attacker, from, to, attacked, ksq); + const IndexType index = make_index(perspective, attacker, from, to, attacked, ksq); if (index < Dimensions) (add ? added : removed).push_back(index); diff --git a/src/nnue/features/full_threats.h b/src/nnue/features/full_threats.h index d5c91d8c2..bc8a1ce32 100644 --- a/src/nnue/features/full_threats.h +++ b/src/nnue/features/full_threats.h @@ -89,12 +89,8 @@ class FullThreats { using IndexList = ValueList; using DiffType = DirtyThreats; - static IndexType make_index(Color perspective, - Piece attkr, - Square from, - Square to, - Piece attkd, - Square ksq); + static IndexType + make_index(Color perspective, Piece attkr, Square from, Square to, Piece attkd, Square ksq); // Get a list of indices for active features static void append_active_indices(Color perspective, const Position& pos, IndexList& active); diff --git a/src/nnue/features/half_ka_v2_hm.cpp b/src/nnue/features/half_ka_v2_hm.cpp index 5a6f610cf..56779ddce 100644 --- a/src/nnue/features/half_ka_v2_hm.cpp +++ b/src/nnue/features/half_ka_v2_hm.cpp @@ -37,9 +37,7 @@ IndexType HalfKAv2_hm::make_index(Color perspective, Square s, Piece pc, Square // Get a list of indices for active features -void HalfKAv2_hm::append_active_indices(Color perspective, - const Position& pos, - IndexList& active) { +void HalfKAv2_hm::append_active_indices(Color perspective, const Position& pos, IndexList& active) { Square ksq = pos.square(perspective); Bitboard bb = pos.pieces(); while (bb) @@ -51,11 +49,8 @@ void HalfKAv2_hm::append_active_indices(Color perspective, // Get a list of indices for recently changed features -void HalfKAv2_hm::append_changed_indices(Color perspective, - Square ksq, - const DiffType& diff, - IndexList& removed, - IndexList& added) { +void HalfKAv2_hm::append_changed_indices( + Color perspective, Square ksq, const DiffType& diff, IndexList& removed, IndexList& added) { removed.push_back(make_index(perspective, diff.from, diff.pc, ksq)); if (diff.to != SQ_NONE) added.push_back(make_index(perspective, diff.to, diff.pc, ksq)); diff --git a/src/nnue/features/half_ka_v2_hm.h b/src/nnue/features/half_ka_v2_hm.h index e9448f838..c58a3246b 100644 --- a/src/nnue/features/half_ka_v2_hm.h +++ b/src/nnue/features/half_ka_v2_hm.h @@ -112,16 +112,11 @@ class HalfKAv2_hm { // Get a list of indices for active features - static void append_active_indices(Color perspective, - const Position& pos, - IndexList& active); + static void append_active_indices(Color perspective, const Position& pos, IndexList& active); // Get a list of indices for recently changed features - static void append_changed_indices(Color perspective, - Square ksq, - const DiffType& diff, - IndexList& removed, - IndexList& added); + static void append_changed_indices( + Color perspective, Square ksq, const DiffType& diff, IndexList& removed, IndexList& added); // Returns whether the change stored in this DirtyPiece means // that a full accumulator refresh is required. diff --git a/src/nnue/nnue_accumulator.cpp b/src/nnue/nnue_accumulator.cpp index 3d99b8063..3ed729ffb 100644 --- a/src/nnue/nnue_accumulator.cpp +++ b/src/nnue/nnue_accumulator.cpp @@ -41,7 +41,7 @@ using namespace SIMD; namespace { template -void double_inc_update(Color perspective, +void double_inc_update(Color perspective, const FeatureTransformer& featureTransformer, const Square ksq, AccumulatorState& middle_state, @@ -49,7 +49,7 @@ void double_inc_update(Color p const AccumulatorState& computed); template -void double_inc_update(Color perspective, +void double_inc_update(Color perspective, const FeatureTransformer& featureTransformer, const Square ksq, AccumulatorState& middle_state, @@ -57,9 +57,7 @@ void double_inc_update(Color p const AccumulatorState& computed, const DirtyPiece& dp2); -template +template void update_accumulator_incremental( Color perspective, const FeatureTransformer& featureTransformer, @@ -68,14 +66,14 @@ void update_accumulator_incremental( const AccumulatorState& computed); template -void update_accumulator_refresh_cache(Color perspective, +void update_accumulator_refresh_cache(Color perspective, const FeatureTransformer& featureTransformer, const Position& pos, AccumulatorState& accumulatorState, AccumulatorCaches::Cache& cache); template -void update_threats_accumulator_full(Color perspective, +void update_threats_accumulator_full(Color perspective, const FeatureTransformer& featureTransformer, const Position& pos, AccumulatorState& accumulatorState); @@ -205,7 +203,7 @@ std::size_t AccumulatorStack::find_last_usable_accumulator(Color perspective) co template void AccumulatorStack::forward_update_incremental( - Color perspective, + Color perspective, const Position& pos, const FeatureTransformer& featureTransformer, const std::size_t begin) noexcept { @@ -260,7 +258,8 @@ void AccumulatorStack::forward_update_incremental( } template -void AccumulatorStack::backward_update_incremental(Color perspective, +void AccumulatorStack::backward_update_incremental( + Color perspective, const Position& pos, const FeatureTransformer& featureTransformer, @@ -479,16 +478,16 @@ struct AccumulatorUpdateContext { }; template -auto make_accumulator_update_context(Color perspective, +auto make_accumulator_update_context(Color perspective, const FeatureTransformer& featureTransformer, const AccumulatorState& accumulatorFrom, AccumulatorState& accumulatorTo) noexcept { - return AccumulatorUpdateContext{ - perspective, featureTransformer, accumulatorFrom, accumulatorTo}; + return AccumulatorUpdateContext{perspective, featureTransformer, + accumulatorFrom, accumulatorTo}; } template -void double_inc_update(Color perspective, +void double_inc_update(Color perspective, const FeatureTransformer& featureTransformer, const Square ksq, AccumulatorState& middle_state, @@ -532,8 +531,8 @@ void double_inc_update(Color p } template -void double_inc_update(Color perspective, -const FeatureTransformer& featureTransformer, +void double_inc_update(Color perspective, + const FeatureTransformer& featureTransformer, const Square ksq, AccumulatorState& middle_state, AccumulatorState& target_state, @@ -562,9 +561,7 @@ const FeatureTransformer& featureTransformer, target_state.acc().computed[perspective] = true; } -template +template void update_accumulator_incremental( Color perspective, const FeatureTransformer& featureTransformer, @@ -825,7 +822,7 @@ void update_accumulator_refresh_cache(Color pers } template -void update_threats_accumulator_full(Color perspective, +void update_threats_accumulator_full(Color perspective, const FeatureTransformer& featureTransformer, const Position& pos, AccumulatorState& accumulatorState) {