Datagen #46
No files matched your search
+2
-2
@@ -9,8 +9,8 @@ constexpr int noEPTarget = -1;
|
||||
|
||||
constexpr int MAX_MOVES = 218;
|
||||
|
||||
inline int positionIndex = 0;
|
||||
inline U64 positionHistory[1000];
|
||||
thread_local inline int positionIndex = 0;
|
||||
thread_local inline U64 positionHistory[1000];
|
||||
|
||||
class Board {
|
||||
public:
|
||||
|
||||
+30
-21
@@ -3,6 +3,7 @@
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
#include "datagen.h"
|
||||
#include "movegen.h"
|
||||
#include "evaluate.h"
|
||||
@@ -220,23 +221,8 @@ void PrintProgress(int positions, int targetPositions, Stopwatch &stopwatch, int
|
||||
std::cout << std::string(width, '-') << std::endl;
|
||||
}
|
||||
|
||||
void Run(int targetPositions, int threads) {
|
||||
#ifdef _WIN32
|
||||
system("cls");
|
||||
HideCursor();
|
||||
#else
|
||||
std::cout << "\033[2J\033[H";
|
||||
HideCursorLinux();
|
||||
#endif
|
||||
|
||||
Stopwatch stopwatch;
|
||||
stopwatch.Restart();
|
||||
|
||||
int positions = 0;
|
||||
int lastPrintedPosition = 0;
|
||||
double lastPrintedTime = stopwatch.GetElapsedSec();
|
||||
|
||||
while (positions < targetPositions * 1000) {
|
||||
void PlayGame(std::atomic<int>& positions, int targetPositions) {
|
||||
while (positions.load(std::memory_order_relaxed) < targetPositions) {
|
||||
Game game;
|
||||
Board board;
|
||||
|
||||
@@ -264,18 +250,41 @@ void Run(int targetPositions, int threads) {
|
||||
MOVEGEN::GenerateMoves<All>(board);
|
||||
|
||||
// Increment positions, but do not exceed target
|
||||
if (positions < targetPositions * 1000) {
|
||||
positions++;
|
||||
}
|
||||
}
|
||||
if (positions.load(std::memory_order_relaxed) < targetPositions) {
|
||||
positions.fetch_add(1, std::memory_order_relaxed);
|
||||
|
||||
if (std::abs(safeResults.score) >= std::abs(SEARCH::MATE_SCORE) - SEARCH::MAX_PLY) {
|
||||
wdl = board.sideToMove ? 2 : 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
game.format.packFrom(board, staticEval, wdl);
|
||||
WriteToFile(game, "data.binpack");
|
||||
}
|
||||
}
|
||||
|
||||
void Run(int targetPositions, int threads) {
|
||||
#ifdef _WIN32
|
||||
system("cls");
|
||||
HideCursor();
|
||||
#else
|
||||
std::cout << "\033[2J\033[H";
|
||||
HideCursorLinux();
|
||||
#endif
|
||||
|
||||
Stopwatch stopwatch;
|
||||
|
||||
std::atomic<int> positions = 0;
|
||||
|
||||
auto worker = std::thread(PlayGame, std::ref(positions), targetPositions * 1000);
|
||||
worker.detach();
|
||||
|
||||
int lastPrintedPosition = 0;
|
||||
double lastPrintedTime = stopwatch.GetElapsedSec();
|
||||
|
||||
while (positions.load(std::memory_order_relaxed) < targetPositions * 1000) {
|
||||
// Print progress every second
|
||||
double currentTime = stopwatch.GetElapsedSec();
|
||||
if (currentTime - lastPrintedTime >= 1) {
|
||||
|
||||
+7
-7
@@ -10,16 +10,16 @@
|
||||
|
||||
namespace SEARCH {
|
||||
|
||||
U64 nodes = 0;
|
||||
U64 nodesToGo = 0;
|
||||
bool benchStarted = false;
|
||||
thread_local U64 nodes = 0;
|
||||
thread_local U64 nodesToGo = 0;
|
||||
thread_local bool benchStarted = false;
|
||||
|
||||
static inline int timeToSearch = 0;
|
||||
static inline bool doingNullMove = false;
|
||||
thread_local static inline int timeToSearch = 0;
|
||||
thread_local static inline bool doingNullMove = false;
|
||||
|
||||
inline PVLine pvLine;
|
||||
thread_local inline PVLine pvLine;
|
||||
|
||||
Stopwatch sw;
|
||||
thread_local Stopwatch sw;
|
||||
|
||||
void InitLMRTable() {
|
||||
for (int depth = 0; depth <= MAX_DEPTH; depth++) {
|
||||
|
||||
+5
-5
@@ -19,15 +19,15 @@ constexpr int MAX_DEPTH = 64;
|
||||
constexpr int MAX_PLY = 128;
|
||||
constexpr int MAX_HISTORY = 16384;
|
||||
|
||||
extern U64 nodes;
|
||||
extern bool benchStarted;
|
||||
thread_local extern U64 nodes;
|
||||
thread_local extern bool benchStarted;
|
||||
|
||||
constexpr int inf = 100000;
|
||||
|
||||
inline bool searchStopped = false;
|
||||
thread_local inline bool searchStopped = false;
|
||||
|
||||
// [id][ply]
|
||||
inline int killerMoves[2][MAX_PLY];
|
||||
thread_local inline int killerMoves[2][MAX_PLY];
|
||||
|
||||
inline int lmrTable[MAX_DEPTH+1][MAX_MOVES];
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline History history;
|
||||
thread_local inline History history;
|
||||
|
||||
class PVLine {
|
||||
private:
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ constexpr U64 maxHash = (64* 1000000) / sizeof(TTEntry);
|
||||
// 5 MB
|
||||
constexpr U64 defaultHash = (5 * 1000000) / sizeof(TTEntry);
|
||||
|
||||
inline U64 hashSize = defaultHash;
|
||||
thread_local inline U64 hashSize = defaultHash;
|
||||
|
||||
constexpr int invalidEntry = 111111;
|
||||
|
||||
@@ -61,4 +61,4 @@ public:
|
||||
void WriteEntry(U64 &hashKey, int depth, int score, int nodeType, Move besteMove);
|
||||
};
|
||||
|
||||
inline TTable TT;
|
||||
thread_local inline TTable TT;
|
||||
Reference in new issue
Block a user