Add Stockfish namespace.

fixes #3350 and is a small cleanup that might make it easier to use SF
in separate projects, like a NNUE trainer or similar.

closes https://github.com/official-stockfish/Stockfish/pull/3370

No functional change.
This commit is contained in:
Dieter Dobbelaere
2021-02-26 10:02:13 +01:00
committed by Joost VandeVondele
parent 9b1274aba3
commit 7ffae17f85
56 changed files with 199 additions and 57 deletions
+4
View File
@@ -92,6 +92,8 @@ const vector<string> Defaults = {
} // namespace } // namespace
namespace Stockfish {
/// setup_bench() builds a list of UCI commands to be run by bench. There /// setup_bench() builds a list of UCI commands to be run by bench. There
/// are five parameters: TT size in MB, number of search threads that /// are five parameters: TT size in MB, number of search threads that
/// should be used, the limit value spent for each position, a file name /// should be used, the limit value spent for each position, a file name
@@ -168,3 +170,5 @@ vector<string> setup_bench(const Position& current, istream& is) {
return list; return list;
} }
} // namespace Stockfish
+4 -2
View File
@@ -23,6 +23,8 @@
#include "bitboard.h" #include "bitboard.h"
#include "types.h" #include "types.h"
namespace Stockfish {
namespace { namespace {
// There are 24 possible pawn squares: files A to D and ranks from 2 to 7. // There are 24 possible pawn squares: files A to D and ranks from 2 to 7.
@@ -66,7 +68,6 @@ namespace {
} // namespace } // namespace
bool Bitbases::probe(Square wksq, Square wpsq, Square bksq, Color stm) { bool Bitbases::probe(Square wksq, Square wpsq, Square bksq, Color stm) {
assert(file_of(wpsq) <= FILE_D); assert(file_of(wpsq) <= FILE_D);
@@ -96,7 +97,6 @@ void Bitbases::init() {
KPKBitbase.set(idx); KPKBitbase.set(idx);
} }
namespace { namespace {
KPKPosition::KPKPosition(unsigned idx) { KPKPosition::KPKPosition(unsigned idx) {
@@ -168,3 +168,5 @@ namespace {
} }
} // namespace } // namespace
} // namespace Stockfish
+4 -2
View File
@@ -22,6 +22,8 @@
#include "bitboard.h" #include "bitboard.h"
#include "misc.h" #include "misc.h"
namespace Stockfish {
uint8_t PopCnt16[1 << 16]; uint8_t PopCnt16[1 << 16];
uint8_t SquareDistance[SQUARE_NB][SQUARE_NB]; uint8_t SquareDistance[SQUARE_NB][SQUARE_NB];
@@ -42,7 +44,6 @@ namespace {
} }
/// safe_destination() returns the bitboard of target square for the given step /// safe_destination() returns the bitboard of target square for the given step
/// from the given square. If the step is off the board, returns empty bitboard. /// from the given square. If the step is off the board, returns empty bitboard.
@@ -111,7 +112,6 @@ void Bitboards::init() {
} }
} }
namespace { namespace {
Bitboard sliding_attack(PieceType pt, Square sq, Bitboard occupied) { Bitboard sliding_attack(PieceType pt, Square sq, Bitboard occupied) {
@@ -211,3 +211,5 @@ namespace {
} }
} }
} }
} // namespace Stockfish
+6 -2
View File
@@ -23,19 +23,21 @@
#include "types.h" #include "types.h"
namespace Stockfish {
namespace Bitbases { namespace Bitbases {
void init(); void init();
bool probe(Square wksq, Square wpsq, Square bksq, Color us); bool probe(Square wksq, Square wpsq, Square bksq, Color us);
} } // namespace Stockfish::Bitbases
namespace Bitboards { namespace Bitboards {
void init(); void init();
std::string pretty(Bitboard b); std::string pretty(Bitboard b);
} } // namespace Stockfish::Bitboards
constexpr Bitboard AllSquares = ~Bitboard(0); constexpr Bitboard AllSquares = ~Bitboard(0);
constexpr Bitboard DarkSquares = 0xAA55AA55AA55AA55ULL; constexpr Bitboard DarkSquares = 0xAA55AA55AA55AA55ULL;
@@ -430,4 +432,6 @@ inline Square frontmost_sq(Color c, Bitboard b) {
return c == WHITE ? msb(b) : lsb(b); return c == WHITE ? msb(b) : lsb(b);
} }
} // namespace Stockfish
#endif // #ifndef BITBOARD_H_INCLUDED #endif // #ifndef BITBOARD_H_INCLUDED
+4
View File
@@ -22,6 +22,8 @@
#include "endgame.h" #include "endgame.h"
#include "movegen.h" #include "movegen.h"
namespace Stockfish {
namespace { namespace {
// Used to drive the king towards the edge of the board // Used to drive the king towards the edge of the board
@@ -741,3 +743,5 @@ ScaleFactor Endgame<KPKP>::operator()(const Position& pos) const {
// it's probably at least a draw even with the pawn. // it's probably at least a draw even with the pawn.
return Bitbases::probe(strongKing, strongPawn, weakKing, us) ? SCALE_FACTOR_NONE : SCALE_FACTOR_DRAW; return Bitbases::probe(strongKing, strongPawn, weakKing, us) ? SCALE_FACTOR_NONE : SCALE_FACTOR_DRAW;
} }
} // namespace Stockfish
+3
View File
@@ -28,6 +28,7 @@
#include "position.h" #include "position.h"
#include "types.h" #include "types.h"
namespace Stockfish {
/// EndgameCode lists all supported endgame functions by corresponding codes /// EndgameCode lists all supported endgame functions by corresponding codes
@@ -120,4 +121,6 @@ namespace Endgames {
} }
} }
} // namespace Stockfish
#endif // #ifndef ENDGAME_H_INCLUDED #endif // #ifndef ENDGAME_H_INCLUDED
+5 -1
View File
@@ -54,7 +54,9 @@
using namespace std; using namespace std;
using namespace Eval::NNUE; using namespace Stockfish::Eval::NNUE;
namespace Stockfish {
namespace Eval { namespace Eval {
@@ -1146,3 +1148,5 @@ std::string Eval::trace(const Position& pos) {
return ss.str(); return ss.str();
} }
} // namespace Stockfish
+4
View File
@@ -23,6 +23,8 @@
#include "types.h" #include "types.h"
namespace Stockfish {
class Position; class Position;
namespace Eval { namespace Eval {
@@ -49,4 +51,6 @@ namespace Eval {
} // namespace Eval } // namespace Eval
} // namespace Stockfish
#endif // #ifndef EVALUATE_H_INCLUDED #endif // #ifndef EVALUATE_H_INCLUDED
+2
View File
@@ -28,6 +28,8 @@
#include "tt.h" #include "tt.h"
#include "uci.h" #include "uci.h"
using namespace Stockfish;
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
std::cout << engine_info() << std::endl; std::cout << engine_info() << std::endl;
+4
View File
@@ -24,6 +24,8 @@
using namespace std; using namespace std;
namespace Stockfish {
namespace { namespace {
#define S(mg, eg) make_score(mg, eg) #define S(mg, eg) make_score(mg, eg)
@@ -223,3 +225,5 @@ Entry* probe(const Position& pos) {
} }
} // namespace Material } // namespace Material
} // namespace Stockfish
+2 -2
View File
@@ -24,7 +24,7 @@
#include "position.h" #include "position.h"
#include "types.h" #include "types.h"
namespace Material { namespace Stockfish::Material {
/// Material::Entry contains various information about a material configuration. /// Material::Entry contains various information about a material configuration.
/// It contains a material imbalance evaluation, a function pointer to a special /// It contains a material imbalance evaluation, a function pointer to a special
@@ -66,6 +66,6 @@ typedef HashTable<Entry, 8192> Table;
Entry* probe(const Position& pos); Entry* probe(const Position& pos);
} // namespace Material } // namespace Stockfish::Material
#endif // #ifndef MATERIAL_H_INCLUDED #endif // #ifndef MATERIAL_H_INCLUDED
+4
View File
@@ -61,6 +61,8 @@ typedef bool(*fun3_t)(HANDLE, CONST GROUP_AFFINITY*, PGROUP_AFFINITY);
using namespace std; using namespace std;
namespace Stockfish {
namespace { namespace {
/// Version number. If Version is left empty, then compile date in the format /// Version number. If Version is left empty, then compile date in the format
@@ -626,3 +628,5 @@ void init(int argc, char* argv[]) {
} // namespace CommandLine } // namespace CommandLine
} // namespace Stockfish
+4
View File
@@ -28,6 +28,8 @@
#include "types.h" #include "types.h"
namespace Stockfish {
std::string engine_info(bool to_uci = false); std::string engine_info(bool to_uci = false);
std::string compiler_info(); std::string compiler_info();
void prefetch(void* addr); void prefetch(void* addr);
@@ -143,4 +145,6 @@ namespace CommandLine {
extern std::string workingDirectory; // path of the working directory extern std::string workingDirectory; // path of the working directory
} }
} // namespace Stockfish
#endif // #ifndef MISC_H_INCLUDED #endif // #ifndef MISC_H_INCLUDED
+4
View File
@@ -21,6 +21,8 @@
#include "movegen.h" #include "movegen.h"
#include "position.h" #include "position.h"
namespace Stockfish {
namespace { namespace {
template<GenType Type, Direction D> template<GenType Type, Direction D>
@@ -362,3 +364,5 @@ ExtMove* generate<LEGAL>(const Position& pos, ExtMove* moveList) {
return moveList; return moveList;
} }
} // namespace Stockfish
+4
View File
@@ -23,6 +23,8 @@
#include "types.h" #include "types.h"
namespace Stockfish {
class Position; class Position;
enum GenType { enum GenType {
@@ -70,4 +72,6 @@ private:
ExtMove moveList[MAX_MOVES], *last; ExtMove moveList[MAX_MOVES], *last;
}; };
} // namespace Stockfish
#endif // #ifndef MOVEGEN_H_INCLUDED #endif // #ifndef MOVEGEN_H_INCLUDED
+4
View File
@@ -20,6 +20,8 @@
#include "movepick.h" #include "movepick.h"
namespace Stockfish {
namespace { namespace {
enum Stages { enum Stages {
@@ -263,3 +265,5 @@ top:
assert(false); assert(false);
return MOVE_NONE; // Silence warning return MOVE_NONE; // Silence warning
} }
} // namespace Stockfish
+4
View File
@@ -27,6 +27,8 @@
#include "position.h" #include "position.h"
#include "types.h" #include "types.h"
namespace Stockfish {
/// StatsEntry stores the stat table value. It is usually a number but could /// StatsEntry stores the stat table value. It is usually a number but could
/// be a move or even a nested history. We use a class instead of naked value /// be a move or even a nested history. We use a class instead of naked value
/// to directly call history update operator<<() on the entry so to use stats /// to directly call history update operator<<() on the entry so to use stats
@@ -156,4 +158,6 @@ private:
ExtMove moves[MAX_MOVES]; ExtMove moves[MAX_MOVES];
}; };
} // namespace Stockfish
#endif // #ifndef MOVEPICK_H_INCLUDED #endif // #ifndef MOVEPICK_H_INCLUDED
+2 -2
View File
@@ -28,7 +28,7 @@
#include "../layers/affine_transform.h" #include "../layers/affine_transform.h"
#include "../layers/clipped_relu.h" #include "../layers/clipped_relu.h"
namespace Eval::NNUE { namespace Stockfish::Eval::NNUE {
// Input features used in evaluation function // Input features used in evaluation function
using RawFeatures = Features::FeatureSet< using RawFeatures = Features::FeatureSet<
@@ -49,6 +49,6 @@ using OutputLayer = AffineTransform<HiddenLayer2, 1>;
using Network = Layers::OutputLayer; using Network = Layers::OutputLayer;
} // namespace Eval::NNUE } // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_HALFKP_256X2_32_32_H_INCLUDED #endif // #ifndef NNUE_HALFKP_256X2_32_32_H_INCLUDED
+2 -2
View File
@@ -29,7 +29,7 @@
#include "evaluate_nnue.h" #include "evaluate_nnue.h"
namespace Eval::NNUE { namespace Stockfish::Eval::NNUE {
// Input feature converter // Input feature converter
LargePagePtr<FeatureTransformer> feature_transformer; LargePagePtr<FeatureTransformer> feature_transformer;
@@ -141,4 +141,4 @@ namespace Eval::NNUE {
return ReadParameters(stream); return ReadParameters(stream);
} }
} // namespace Eval::NNUE } // namespace Stockfish::Eval::NNUE
+2 -2
View File
@@ -25,7 +25,7 @@
#include <memory> #include <memory>
namespace Eval::NNUE { namespace Stockfish::Eval::NNUE {
// Hash value of evaluation function structure // Hash value of evaluation function structure
constexpr std::uint32_t kHashValue = constexpr std::uint32_t kHashValue =
@@ -54,6 +54,6 @@ namespace Eval::NNUE {
template <typename T> template <typename T>
using LargePagePtr = std::unique_ptr<T, LargePageDeleter<T>>; using LargePagePtr = std::unique_ptr<T, LargePageDeleter<T>>;
} // namespace Eval::NNUE } // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_EVALUATE_NNUE_H_INCLUDED #endif // #ifndef NNUE_EVALUATE_NNUE_H_INCLUDED
+2 -2
View File
@@ -24,7 +24,7 @@
#include "features_common.h" #include "features_common.h"
#include <array> #include <array>
namespace Eval::NNUE::Features { namespace Stockfish::Eval::NNUE::Features {
// Class template that represents a list of values // Class template that represents a list of values
template <typename T, T... Values> template <typename T, T... Values>
@@ -64,6 +64,6 @@ namespace Eval::NNUE::Features {
}; };
} // namespace Eval::NNUE::Features } // namespace Stockfish::Eval::NNUE::Features
#endif // #ifndef NNUE_FEATURE_SET_H_INCLUDED #endif // #ifndef NNUE_FEATURE_SET_H_INCLUDED
+2 -2
View File
@@ -24,7 +24,7 @@
#include "../../evaluate.h" #include "../../evaluate.h"
#include "../nnue_common.h" #include "../nnue_common.h"
namespace Eval::NNUE::Features { namespace Stockfish::Eval::NNUE::Features {
class IndexList; class IndexList;
@@ -40,6 +40,6 @@ namespace Eval::NNUE::Features {
kFriend // side to move kFriend // side to move
}; };
} // namespace Eval::NNUE::Features } // namespace Stockfish::Eval::NNUE::Features
#endif // #ifndef NNUE_FEATURES_COMMON_H_INCLUDED #endif // #ifndef NNUE_FEATURES_COMMON_H_INCLUDED
+2 -2
View File
@@ -21,7 +21,7 @@
#include "half_kp.h" #include "half_kp.h"
#include "index_list.h" #include "index_list.h"
namespace Eval::NNUE::Features { namespace Stockfish::Eval::NNUE::Features {
// Orient a square according to perspective (rotates by 180 for black) // Orient a square according to perspective (rotates by 180 for black)
inline Square orient(Color perspective, Square s) { inline Square orient(Color perspective, Square s) {
@@ -65,4 +65,4 @@ namespace Eval::NNUE::Features {
template class HalfKP<Side::kFriend>; template class HalfKP<Side::kFriend>;
} // namespace Eval::NNUE::Features } // namespace Stockfish::Eval::NNUE::Features
+2 -2
View File
@@ -24,7 +24,7 @@
#include "../../evaluate.h" #include "../../evaluate.h"
#include "features_common.h" #include "features_common.h"
namespace Eval::NNUE::Features { namespace Stockfish::Eval::NNUE::Features {
// Feature HalfKP: Combination of the position of own king // Feature HalfKP: Combination of the position of own king
// and the position of pieces other than kings // and the position of pieces other than kings
@@ -54,6 +54,6 @@ namespace Eval::NNUE::Features {
IndexList* removed, IndexList* added); IndexList* removed, IndexList* added);
}; };
} // namespace Eval::NNUE::Features } // namespace Stockfish::Eval::NNUE::Features
#endif // #ifndef NNUE_FEATURES_HALF_KP_H_INCLUDED #endif // #ifndef NNUE_FEATURES_HALF_KP_H_INCLUDED
+2 -2
View File
@@ -24,7 +24,7 @@
#include "../../position.h" #include "../../position.h"
#include "../nnue_architecture.h" #include "../nnue_architecture.h"
namespace Eval::NNUE::Features { namespace Stockfish::Eval::NNUE::Features {
// Class template used for feature index list // Class template used for feature index list
template <typename T, std::size_t MaxSize> template <typename T, std::size_t MaxSize>
@@ -59,6 +59,6 @@ namespace Eval::NNUE::Features {
: public ValueList<IndexType, RawFeatures::kMaxActiveDimensions> { : public ValueList<IndexType, RawFeatures::kMaxActiveDimensions> {
}; };
} // namespace Eval::NNUE::Features } // namespace Stockfish::Eval::NNUE::Features
#endif // NNUE_FEATURES_INDEX_LIST_H_INCLUDED #endif // NNUE_FEATURES_INDEX_LIST_H_INCLUDED
+2 -2
View File
@@ -24,7 +24,7 @@
#include <iostream> #include <iostream>
#include "../nnue_common.h" #include "../nnue_common.h"
namespace Eval::NNUE::Layers { namespace Stockfish::Eval::NNUE::Layers {
// Affine transformation layer // Affine transformation layer
template <typename PreviousLayer, IndexType OutputDimensions> template <typename PreviousLayer, IndexType OutputDimensions>
@@ -459,6 +459,6 @@ namespace Eval::NNUE::Layers {
#endif #endif
}; };
} // namespace Eval::NNUE::Layers } // namespace Stockfish::Eval::NNUE::Layers
#endif // #ifndef NNUE_LAYERS_AFFINE_TRANSFORM_H_INCLUDED #endif // #ifndef NNUE_LAYERS_AFFINE_TRANSFORM_H_INCLUDED
+2 -2
View File
@@ -23,7 +23,7 @@
#include "../nnue_common.h" #include "../nnue_common.h"
namespace Eval::NNUE::Layers { namespace Stockfish::Eval::NNUE::Layers {
// Clipped ReLU // Clipped ReLU
template <typename PreviousLayer> template <typename PreviousLayer>
@@ -161,6 +161,6 @@ namespace Eval::NNUE::Layers {
PreviousLayer previous_layer_; PreviousLayer previous_layer_;
}; };
} // namespace Eval::NNUE::Layers } // namespace Stockfish::Eval::NNUE::Layers
#endif // NNUE_LAYERS_CLIPPED_RELU_H_INCLUDED #endif // NNUE_LAYERS_CLIPPED_RELU_H_INCLUDED
+2 -2
View File
@@ -23,7 +23,7 @@
#include "../nnue_common.h" #include "../nnue_common.h"
namespace Eval::NNUE::Layers { namespace Stockfish::Eval::NNUE::Layers {
// Input layer // Input layer
template <IndexType OutputDimensions, IndexType Offset = 0> template <IndexType OutputDimensions, IndexType Offset = 0>
@@ -63,6 +63,6 @@ class InputSlice {
private: private:
}; };
} // namespace Layers } // namespace Stockfish::Eval::NNUE::Layers
#endif // #ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED #endif // #ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED
+2 -2
View File
@@ -23,7 +23,7 @@
#include "nnue_architecture.h" #include "nnue_architecture.h"
namespace Eval::NNUE { namespace Stockfish::Eval::NNUE {
// The accumulator of a StateInfo without parent is set to the INIT state // The accumulator of a StateInfo without parent is set to the INIT state
enum AccumulatorState { EMPTY, COMPUTED, INIT }; enum AccumulatorState { EMPTY, COMPUTED, INIT };
@@ -35,6 +35,6 @@ namespace Eval::NNUE {
AccumulatorState state[2]; AccumulatorState state[2];
}; };
} // namespace Eval::NNUE } // namespace Stockfish::Eval::NNUE
#endif // NNUE_ACCUMULATOR_H_INCLUDED #endif // NNUE_ACCUMULATOR_H_INCLUDED
+2 -2
View File
@@ -24,7 +24,7 @@
// Defines the network structure // Defines the network structure
#include "architectures/halfkp_256x2-32-32.h" #include "architectures/halfkp_256x2-32-32.h"
namespace Eval::NNUE { namespace Stockfish::Eval::NNUE {
static_assert(kTransformedFeatureDimensions % kMaxSimdWidth == 0, ""); static_assert(kTransformedFeatureDimensions % kMaxSimdWidth == 0, "");
static_assert(Network::kOutputDimensions == 1, ""); static_assert(Network::kOutputDimensions == 1, "");
@@ -33,6 +33,6 @@ namespace Eval::NNUE {
// Trigger for full calculation instead of difference calculation // Trigger for full calculation instead of difference calculation
constexpr auto kRefreshTriggers = RawFeatures::kRefreshTriggers; constexpr auto kRefreshTriggers = RawFeatures::kRefreshTriggers;
} // namespace Eval::NNUE } // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_ARCHITECTURE_H_INCLUDED #endif // #ifndef NNUE_ARCHITECTURE_H_INCLUDED
+2 -2
View File
@@ -43,7 +43,7 @@
#include <arm_neon.h> #include <arm_neon.h>
#endif #endif
namespace Eval::NNUE { namespace Stockfish::Eval::NNUE {
// Version of the evaluation file // Version of the evaluation file
constexpr std::uint32_t kVersion = 0x7AF32F16u; constexpr std::uint32_t kVersion = 0x7AF32F16u;
@@ -127,6 +127,6 @@ namespace Eval::NNUE {
return result; return result;
} }
} // namespace Eval::NNUE } // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_COMMON_H_INCLUDED #endif // #ifndef NNUE_COMMON_H_INCLUDED
+2 -2
View File
@@ -27,7 +27,7 @@
#include <cstring> // std::memset() #include <cstring> // std::memset()
namespace Eval::NNUE { namespace Stockfish::Eval::NNUE {
// If vector instructions are enabled, we update and refresh the // If vector instructions are enabled, we update and refresh the
// accumulator tile by tile such that each tile fits in the CPU's // accumulator tile by tile such that each tile fits in the CPU's
@@ -412,6 +412,6 @@ namespace Eval::NNUE {
WeightType weights_[kHalfDimensions * kInputDimensions]; WeightType weights_[kHalfDimensions * kInputDimensions];
}; };
} // namespace Eval::NNUE } // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_FEATURE_TRANSFORMER_H_INCLUDED #endif // #ifndef NNUE_FEATURE_TRANSFORMER_H_INCLUDED
+4
View File
@@ -24,6 +24,8 @@
#include "position.h" #include "position.h"
#include "thread.h" #include "thread.h"
namespace Stockfish {
namespace { namespace {
#define V Value #define V Value
@@ -298,3 +300,5 @@ template Score Entry::do_king_safety<WHITE>(const Position& pos);
template Score Entry::do_king_safety<BLACK>(const Position& pos); template Score Entry::do_king_safety<BLACK>(const Position& pos);
} // namespace Pawns } // namespace Pawns
} // namespace Stockfish
+2 -2
View File
@@ -23,7 +23,7 @@
#include "position.h" #include "position.h"
#include "types.h" #include "types.h"
namespace Pawns { namespace Stockfish::Pawns {
/// Pawns::Entry contains various information about a pawn structure. A lookup /// Pawns::Entry contains various information about a pawn structure. A lookup
/// to the pawn hash table (performed by calling the probe function) returns a /// to the pawn hash table (performed by calling the probe function) returns a
@@ -65,6 +65,6 @@ typedef HashTable<Entry, 131072> Table;
Entry* probe(const Position& pos); Entry* probe(const Position& pos);
} // namespace Pawns } // namespace Stockfish::Pawns
#endif // #ifndef PAWNS_H_INCLUDED #endif // #ifndef PAWNS_H_INCLUDED
+4
View File
@@ -34,6 +34,8 @@
using std::string; using std::string;
namespace Stockfish {
namespace Zobrist { namespace Zobrist {
Key psq[PIECE_NB][SQUARE_NB]; Key psq[PIECE_NB][SQUARE_NB];
@@ -1338,3 +1340,5 @@ bool Position::pos_is_ok() const {
return true; return true;
} }
} // namespace Stockfish
+3
View File
@@ -31,6 +31,7 @@
#include "nnue/nnue_accumulator.h" #include "nnue/nnue_accumulator.h"
namespace Stockfish {
/// StateInfo struct stores information needed to restore a Position object to /// StateInfo struct stores information needed to restore a Position object to
/// its previous state when we retract a move. Whenever a move is made on the /// its previous state when we retract a move. Whenever a move is made on the
@@ -423,4 +424,6 @@ inline StateInfo* Position::state() const {
return st; return st;
} }
} // namespace Stockfish
#endif // #ifndef POSITION_H_INCLUDED #endif // #ifndef POSITION_H_INCLUDED
+3
View File
@@ -24,6 +24,7 @@
#include "bitboard.h" #include "bitboard.h"
#include "types.h" #include "types.h"
namespace Stockfish {
namespace namespace
{ {
@@ -126,3 +127,5 @@ void init() {
} }
} // namespace PSQT } // namespace PSQT
} // namespace Stockfish
+2 -2
View File
@@ -24,7 +24,7 @@
#include "types.h" #include "types.h"
namespace PSQT namespace Stockfish::PSQT
{ {
extern Score psq[PIECE_NB][SQUARE_NB]; extern Score psq[PIECE_NB][SQUARE_NB];
@@ -32,7 +32,7 @@ extern Score psq[PIECE_NB][SQUARE_NB];
// Fill psqt array from a set of internally linked parameters // Fill psqt array from a set of internally linked parameters
extern void init(); extern void init();
} // namespace PSQT } // namespace Stockfish::PSQT
#endif // PSQT_H_INCLUDED #endif // PSQT_H_INCLUDED
+5 -1
View File
@@ -35,6 +35,8 @@
#include "uci.h" #include "uci.h"
#include "syzygy/tbprobe.h" #include "syzygy/tbprobe.h"
namespace Stockfish {
namespace Search { namespace Search {
LimitsType Limits; LimitsType Limits;
@@ -422,7 +424,7 @@ void Thread::search() {
while (true) while (true)
{ {
Depth adjustedDepth = std::max(1, rootDepth - failedHighCnt - searchAgainCounter); Depth adjustedDepth = std::max(1, rootDepth - failedHighCnt - searchAgainCounter);
bestValue = ::search<PV>(rootPos, ss, alpha, beta, adjustedDepth, false); bestValue = Stockfish::search<PV>(rootPos, ss, alpha, beta, adjustedDepth, false);
// Bring the best move to the front. It is critical that sorting // Bring the best move to the front. It is critical that sorting
// is done with a stable algorithm because all the values but the // is done with a stable algorithm because all the values but the
@@ -2034,3 +2036,5 @@ void Tablebases::rank_root_moves(Position& pos, Search::RootMoves& rootMoves) {
m.tbRank = 0; m.tbRank = 0;
} }
} }
} // namespace Stockfish
+4
View File
@@ -25,6 +25,8 @@
#include "movepick.h" #include "movepick.h"
#include "types.h" #include "types.h"
namespace Stockfish {
class Position; class Position;
namespace Search { namespace Search {
@@ -107,4 +109,6 @@ void clear();
} // namespace Search } // namespace Search
} // namespace Stockfish
#endif // #ifndef SEARCH_H_INCLUDED #endif // #ifndef SEARCH_H_INCLUDED
+6 -2
View File
@@ -50,9 +50,11 @@
#include <windows.h> #include <windows.h>
#endif #endif
using namespace Tablebases; using namespace Stockfish::Tablebases;
int Tablebases::MaxCardinality; int Stockfish::Tablebases::MaxCardinality;
namespace Stockfish {
namespace { namespace {
@@ -1610,3 +1612,5 @@ bool Tablebases::root_probe_wdl(Position& pos, Search::RootMoves& rootMoves) {
return true; return true;
} }
} // namespace Stockfish
+2 -2
View File
@@ -23,7 +23,7 @@
#include "../search.h" #include "../search.h"
namespace Tablebases { namespace Stockfish::Tablebases {
enum WDLScore { enum WDLScore {
WDLLoss = -2, // Loss WDLLoss = -2, // Loss
@@ -73,6 +73,6 @@ inline std::ostream& operator<<(std::ostream& os, const ProbeState v) {
return os; return os;
} }
} } // namespace Stockfish::Tablebases
#endif #endif
+4
View File
@@ -26,6 +26,8 @@
#include "syzygy/tbprobe.h" #include "syzygy/tbprobe.h"
#include "tt.h" #include "tt.h"
namespace Stockfish {
ThreadPool Threads; // Global object ThreadPool Threads; // Global object
@@ -258,3 +260,5 @@ void ThreadPool::wait_for_search_finished() const {
if (th != front()) if (th != front())
th->wait_for_search_finished(); th->wait_for_search_finished();
} }
} // namespace Stockfish
+3
View File
@@ -32,6 +32,7 @@
#include "search.h" #include "search.h"
#include "thread_win32_osx.h" #include "thread_win32_osx.h"
namespace Stockfish {
/// Thread class keeps together all the thread-related stuff. We use /// Thread class keeps together all the thread-related stuff. We use
/// per-thread pawn and material hash tables so that once we get a /// per-thread pawn and material hash tables so that once we get a
@@ -128,4 +129,6 @@ private:
extern ThreadPool Threads; extern ThreadPool Threads;
} // namespace Stockfish
#endif // #ifndef THREAD_H_INCLUDED #endif // #ifndef THREAD_H_INCLUDED
+8
View File
@@ -31,6 +31,8 @@
#include <pthread.h> #include <pthread.h>
namespace Stockfish {
static const size_t TH_STACK_SIZE = 8 * 1024 * 1024; static const size_t TH_STACK_SIZE = 8 * 1024 * 1024;
template <class T, class P = std::pair<T*, void(T::*)()>> template <class T, class P = std::pair<T*, void(T::*)()>>
@@ -57,10 +59,16 @@ public:
void join() { pthread_join(thread, NULL); } void join() { pthread_join(thread, NULL); }
}; };
} // namespace Stockfish
#else // Default case: use STL classes #else // Default case: use STL classes
namespace Stockfish {
typedef std::thread NativeThread; typedef std::thread NativeThread;
} // namespace Stockfish
#endif #endif
#endif // #ifndef THREAD_WIN32_OSX_H_INCLUDED #endif // #ifndef THREAD_WIN32_OSX_H_INCLUDED
+4
View File
@@ -24,6 +24,8 @@
#include "timeman.h" #include "timeman.h"
#include "uci.h" #include "uci.h"
namespace Stockfish {
TimeManagement Time; // Our global time management object TimeManagement Time; // Our global time management object
@@ -95,3 +97,5 @@ void TimeManagement::init(Search::LimitsType& limits, Color us, int ply) {
if (Options["Ponder"]) if (Options["Ponder"])
optimumTime += optimumTime / 4; optimumTime += optimumTime / 4;
} }
} // namespace Stockfish
+4
View File
@@ -23,6 +23,8 @@
#include "search.h" #include "search.h"
#include "thread.h" #include "thread.h"
namespace Stockfish {
/// The TimeManagement class computes the optimal time to think depending on /// The TimeManagement class computes the optimal time to think depending on
/// the maximum available time, the game move number and other parameters. /// the maximum available time, the game move number and other parameters.
@@ -44,4 +46,6 @@ private:
extern TimeManagement Time; extern TimeManagement Time;
} // namespace Stockfish
#endif // #ifndef TIMEMAN_H_INCLUDED #endif // #ifndef TIMEMAN_H_INCLUDED
+4
View File
@@ -26,6 +26,8 @@
#include "tt.h" #include "tt.h"
#include "uci.h" #include "uci.h"
namespace Stockfish {
TranspositionTable TT; // Our global transposition table TranspositionTable TT; // Our global transposition table
/// TTEntry::save() populates the TTEntry with a new node's data, possibly /// TTEntry::save() populates the TTEntry with a new node's data, possibly
@@ -156,3 +158,5 @@ int TranspositionTable::hashfull() const {
return cnt / ClusterSize; return cnt / ClusterSize;
} }
} // namespace Stockfish
+4
View File
@@ -22,6 +22,8 @@
#include "misc.h" #include "misc.h"
#include "types.h" #include "types.h"
namespace Stockfish {
/// TTEntry struct is the 10 bytes transposition table entry, defined as below: /// TTEntry struct is the 10 bytes transposition table entry, defined as below:
/// ///
/// key 16 bit /// key 16 bit
@@ -100,4 +102,6 @@ private:
extern TranspositionTable TT; extern TranspositionTable TT;
} // namespace Stockfish
#endif // #ifndef TT_H_INCLUDED #endif // #ifndef TT_H_INCLUDED
+8
View File
@@ -26,6 +26,8 @@
using std::string; using std::string;
namespace Stockfish {
bool Tune::update_on_last; bool Tune::update_on_last;
const UCI::Option* LastOption = nullptr; const UCI::Option* LastOption = nullptr;
BoolConditions Conditions; BoolConditions Conditions;
@@ -126,6 +128,8 @@ void BoolConditions::set() {
sync_cout << binary[i] << sync_endl; sync_cout << binary[i] << sync_endl;
} }
} // namespace Stockfish
// Init options with tuning session results instead of default values. Useful to // Init options with tuning session results instead of default values. Useful to
// get correct bench signature after a tuning session or to test tuned values. // get correct bench signature after a tuning session or to test tuned values.
@@ -138,7 +142,11 @@ void BoolConditions::set() {
#include <cmath> #include <cmath>
namespace Stockfish {
void Tune::read_results() { void Tune::read_results() {
/* ...insert your values here... */ /* ...insert your values here... */
} }
} // namespace Stockfish
+4
View File
@@ -24,6 +24,8 @@
#include <type_traits> #include <type_traits>
#include <vector> #include <vector>
namespace Stockfish {
typedef std::pair<int, int> Range; // Option's min-max values typedef std::pair<int, int> Range; // Option's min-max values
typedef Range (RangeFun) (int); typedef Range (RangeFun) (int);
@@ -190,4 +192,6 @@ public:
#define TUNE_CONDITIONS() int UNIQUE(c, __LINE__) = (Conditions.init(__COUNTER__), 0); \ #define TUNE_CONDITIONS() int UNIQUE(c, __LINE__) = (Conditions.init(__COUNTER__), 0); \
TUNE(Conditions, set_conditions) TUNE(Conditions, set_conditions)
} // namespace Stockfish
#endif // #ifndef TUNE_H_INCLUDED #endif // #ifndef TUNE_H_INCLUDED
+4
View File
@@ -83,6 +83,8 @@
# define pext(b, m) 0 # define pext(b, m) 0
#endif #endif
namespace Stockfish {
#ifdef USE_POPCNT #ifdef USE_POPCNT
constexpr bool HasPopCnt = true; constexpr bool HasPopCnt = true;
#else #else
@@ -482,6 +484,8 @@ constexpr Key make_key(uint64_t seed) {
return seed * 6364136223846793005ULL + 1442695040888963407ULL; return seed * 6364136223846793005ULL + 1442695040888963407ULL;
} }
} // namespace Stockfish
#endif // #ifndef TYPES_H_INCLUDED #endif // #ifndef TYPES_H_INCLUDED
#include "tune.h" // Global visibility to tuning setup #include "tune.h" // Global visibility to tuning setup
+4
View File
@@ -34,6 +34,8 @@
using namespace std; using namespace std;
namespace Stockfish {
extern vector<string> setup_bench(const Position&, istream&); extern vector<string> setup_bench(const Position&, istream&);
namespace { namespace {
@@ -369,3 +371,5 @@ Move UCI::to_move(const Position& pos, string& str) {
return MOVE_NONE; return MOVE_NONE;
} }
} // namespace Stockfish
+4
View File
@@ -24,6 +24,8 @@
#include "types.h" #include "types.h"
namespace Stockfish {
class Position; class Position;
namespace UCI { namespace UCI {
@@ -78,4 +80,6 @@ Move to_move(const Position& pos, std::string& str);
extern UCI::OptionsMap Options; extern UCI::OptionsMap Options;
} // namespace Stockfish
#endif // #ifndef UCI_H_INCLUDED #endif // #ifndef UCI_H_INCLUDED
+4
View File
@@ -31,6 +31,8 @@
using std::string; using std::string;
namespace Stockfish {
UCI::OptionsMap Options; // Global object UCI::OptionsMap Options; // Global object
namespace UCI { namespace UCI {
@@ -190,3 +192,5 @@ Option& Option::operator=(const string& v) {
} }
} // namespace UCI } // namespace UCI
} // namespace Stockfish
+9 -9
View File
@@ -39,16 +39,16 @@ case $1 in
threads="2" threads="2"
cat << EOF > tsan.supp cat << EOF > tsan.supp
race:TTEntry::move race:Stockfish::TTEntry::move
race:TTEntry::depth race:Stockfish::TTEntry::depth
race:TTEntry::bound race:Stockfish::TTEntry::bound
race:TTEntry::save race:Stockfish::TTEntry::save
race:TTEntry::value race:Stockfish::TTEntry::value
race:TTEntry::eval race:Stockfish::TTEntry::eval
race:TTEntry::is_pv race:Stockfish::TTEntry::is_pv
race:TranspositionTable::probe race:Stockfish::TranspositionTable::probe
race:TranspositionTable::hashfull race:Stockfish::TranspositionTable::hashfull
EOF EOF