]> git.sesse.net Git - stockfish/commitdiff
Rename THREAD_MAX in MAX_THREADS
authorMarco Costalba <mcostalba@gmail.com>
Sat, 20 Feb 2010 12:38:04 +0000 (13:38 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 20 Feb 2010 12:38:04 +0000 (13:38 +0100)
Also rename idle_thread_exists() in available_thread_exists()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/benchmark.cpp
src/evaluate.cpp
src/search.cpp
src/thread.h
src/ucioption.cpp

index 3abcda62f75e2a2fe87adba4878e4f1d715870c6..ca40b24845b02f7ddf74dd9c3103c86b9c31c6f0 100644 (file)
@@ -84,9 +84,9 @@ void benchmark(const string& commandLine) {
   }
   csStr >> threads;
   csVal >> val;
   }
   csStr >> threads;
   csVal >> val;
-  if (val < 1 || val > THREAD_MAX)
+  if (val < 1 || val > MAX_THREADS)
   {
   {
-      cerr << "The number of threads must be between 1 and " << THREAD_MAX << endl;
+      cerr << "The number of threads must be between 1 and " << MAX_THREADS << endl;
       Application::exit_with_failure();
   }
   set_option_value("Hash", ttSize);
       Application::exit_with_failure();
   }
   set_option_value("Hash", ttSize);
index d225de26fff69994013aabd9762dc373abe730f6..86e5999f85cfe49fd899ee38ae34a2a5fd4309cb 100644 (file)
@@ -253,8 +253,8 @@ namespace {
 
   // Pawn and material hash tables, indexed by the current thread id.
   // Note that they will be initialized at 0 being global variables.
 
   // Pawn and material hash tables, indexed by the current thread id.
   // Note that they will be initialized at 0 being global variables.
-  MaterialInfoTable* MaterialTable[THREAD_MAX];
-  PawnInfoTable* PawnTable[THREAD_MAX];
+  MaterialInfoTable* MaterialTable[MAX_THREADS];
+  PawnInfoTable* PawnTable[MAX_THREADS];
 
   // Sizes of pawn and material hash tables
   const int PawnTableSize = 16384;
 
   // Sizes of pawn and material hash tables
   const int PawnTableSize = 16384;
@@ -305,7 +305,7 @@ template<bool HasPopCnt>
 Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
 
   assert(pos.is_ok());
 Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
 
   assert(pos.is_ok());
-  assert(threadID >= 0 && threadID < THREAD_MAX);
+  assert(threadID >= 0 && threadID < MAX_THREADS);
   assert(!pos.is_check());
 
   memset(&ei, 0, sizeof(EvalInfo));
   assert(!pos.is_check());
 
   memset(&ei, 0, sizeof(EvalInfo));
@@ -440,9 +440,9 @@ Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
 
 void init_eval(int threads) {
 
 
 void init_eval(int threads) {
 
-  assert(threads <= THREAD_MAX);
+  assert(threads <= MAX_THREADS);
 
 
-  for (int i = 0; i < THREAD_MAX; i++)
+  for (int i = 0; i < MAX_THREADS; i++)
   {
     if (i >= threads)
     {
   {
     if (i >= threads)
     {
@@ -464,7 +464,7 @@ void init_eval(int threads) {
 
 void quit_eval() {
 
 
 void quit_eval() {
 
-  for (int i = 0; i < THREAD_MAX; i++)
+  for (int i = 0; i < MAX_THREADS; i++)
   {
       delete PawnTable[i];
       delete MaterialTable[i];
   {
       delete PawnTable[i];
       delete MaterialTable[i];
index 8d941f92f062ccddf051187a5ec11069bb73f9ea..3712bd571c4cd57630094992b4b4faa90584710d 100644 (file)
@@ -79,7 +79,7 @@ namespace {
     void resetBetaCounters();
     int64_t nodes_searched() const;
     void get_beta_counters(Color us, int64_t& our, int64_t& their) const;
     void resetBetaCounters();
     int64_t nodes_searched() const;
     void get_beta_counters(Color us, int64_t& our, int64_t& their) const;
-    bool idle_thread_exists(int master) const;
+    bool available_thread_exists(int master) const;
     bool thread_is_available(int slave, int master) const;
     bool thread_should_stop(int threadID) const;
     void wake_sleeping_threads();
     bool thread_is_available(int slave, int master) const;
     bool thread_should_stop(int threadID) const;
     void wake_sleeping_threads();
@@ -93,8 +93,8 @@ namespace {
 
     int ActiveThreads;
     bool AllThreadsShouldExit, AllThreadsShouldSleep;
 
     int ActiveThreads;
     bool AllThreadsShouldExit, AllThreadsShouldSleep;
-    Thread threads[THREAD_MAX];
-    SplitPoint SplitPointStack[THREAD_MAX][ACTIVE_SPLIT_POINTS_MAX];
+    Thread threads[MAX_THREADS];
+    SplitPoint SplitPointStack[MAX_THREADS][ACTIVE_SPLIT_POINTS_MAX];
 
     Lock MPLock, IOLock;
 
 
     Lock MPLock, IOLock;
 
@@ -102,7 +102,7 @@ namespace {
     pthread_cond_t WaitCond;
     pthread_mutex_t WaitLock;
 #else
     pthread_cond_t WaitCond;
     pthread_mutex_t WaitLock;
 #else
-    HANDLE SitIdleEvent[THREAD_MAX];
+    HANDLE SitIdleEvent[MAX_THREADS];
 #endif
 
   };
 #endif
 
   };
@@ -1208,7 +1208,7 @@ namespace {
           && bestValue < beta
           && depth >= MinimumSplitDepth
           && Iteration <= 99
           && bestValue < beta
           && depth >= MinimumSplitDepth
           && Iteration <= 99
-          && TM.idle_thread_exists(threadID)
+          && TM.available_thread_exists(threadID)
           && !AbortSearch
           && !TM.thread_should_stop(threadID)
           && TM.split(pos, ss, ply, &alpha, &beta, &bestValue, VALUE_NONE,
           && !AbortSearch
           && !TM.thread_should_stop(threadID)
           && TM.split(pos, ss, ply, &alpha, &beta, &bestValue, VALUE_NONE,
@@ -1522,7 +1522,7 @@ namespace {
           && bestValue < beta
           && depth >= MinimumSplitDepth
           && Iteration <= 99
           && bestValue < beta
           && depth >= MinimumSplitDepth
           && Iteration <= 99
-          && TM.idle_thread_exists(threadID)
+          && TM.available_thread_exists(threadID)
           && !AbortSearch
           && !TM.thread_should_stop(threadID)
           && TM.split(pos, ss, ply, &beta, &beta, &bestValue, futilityValue, //FIXME: SMP & futilityValue
           && !AbortSearch
           && !TM.thread_should_stop(threadID)
           && TM.split(pos, ss, ply, &beta, &beta, &bestValue, futilityValue, //FIXME: SMP & futilityValue
@@ -2585,13 +2585,13 @@ namespace {
 
   void ThreadsManager::resetNodeCounters() {
 
 
   void ThreadsManager::resetNodeCounters() {
 
-    for (int i = 0; i < THREAD_MAX; i++)
+    for (int i = 0; i < MAX_THREADS; i++)
         threads[i].nodes = 0ULL;
   }
 
   void ThreadsManager::resetBetaCounters() {
 
         threads[i].nodes = 0ULL;
   }
 
   void ThreadsManager::resetBetaCounters() {
 
-    for (int i = 0; i < THREAD_MAX; i++)
+    for (int i = 0; i < MAX_THREADS; i++)
         threads[i].betaCutOffs[WHITE] = threads[i].betaCutOffs[BLACK] = 0ULL;
   }
 
         threads[i].betaCutOffs[WHITE] = threads[i].betaCutOffs[BLACK] = 0ULL;
   }
 
@@ -2607,7 +2607,7 @@ namespace {
   void ThreadsManager::get_beta_counters(Color us, int64_t& our, int64_t& their) const {
 
     our = their = 0UL;
   void ThreadsManager::get_beta_counters(Color us, int64_t& our, int64_t& their) const {
 
     our = their = 0UL;
-    for (int i = 0; i < THREAD_MAX; i++)
+    for (int i = 0; i < MAX_THREADS; i++)
     {
         our += threads[i].betaCutOffs[us];
         their += threads[i].betaCutOffs[opposite_color(us)];
     {
         our += threads[i].betaCutOffs[us];
         their += threads[i].betaCutOffs[opposite_color(us)];
@@ -2621,7 +2621,7 @@ namespace {
 
   void ThreadsManager::idle_loop(int threadID, SplitPoint* waitSp) {
 
 
   void ThreadsManager::idle_loop(int threadID, SplitPoint* waitSp) {
 
-    assert(threadID >= 0 && threadID < THREAD_MAX);
+    assert(threadID >= 0 && threadID < MAX_THREADS);
 
     threads[threadID].running = true;
 
 
     threads[threadID].running = true;
 
@@ -2693,7 +2693,7 @@ namespace {
     lock_init(&IOLock, NULL);
 
     // Initialize SplitPointStack locks
     lock_init(&IOLock, NULL);
 
     // Initialize SplitPointStack locks
-    for (int i = 0; i < THREAD_MAX; i++)
+    for (int i = 0; i < MAX_THREADS; i++)
         for (int j = 0; j < ACTIVE_SPLIT_POINTS_MAX; j++)
         {
             SplitPointStack[i][j].parent = NULL;
         for (int j = 0; j < ACTIVE_SPLIT_POINTS_MAX; j++)
         {
             SplitPointStack[i][j].parent = NULL;
@@ -2704,7 +2704,7 @@ namespace {
     pthread_mutex_init(&WaitLock, NULL);
     pthread_cond_init(&WaitCond, NULL);
 #else
     pthread_mutex_init(&WaitLock, NULL);
     pthread_cond_init(&WaitCond, NULL);
 #else
-    for (i = 0; i < THREAD_MAX; i++)
+    for (i = 0; i < MAX_THREADS; i++)
         SitIdleEvent[i] = CreateEvent(0, FALSE, FALSE, 0);
 #endif
 
         SitIdleEvent[i] = CreateEvent(0, FALSE, FALSE, 0);
 #endif
 
@@ -2716,11 +2716,11 @@ namespace {
 
     // All threads except the main thread should be initialized to idle state
     ActiveThreads = 1;
 
     // All threads except the main thread should be initialized to idle state
     ActiveThreads = 1;
-    for (i = 1; i < THREAD_MAX; i++)
+    for (i = 1; i < MAX_THREADS; i++)
         threads[i].idle = true;
 
     // Launch the helper threads
         threads[i].idle = true;
 
     // Launch the helper threads
-    for (i = 1; i < THREAD_MAX; i++)
+    for (i = 1; i < MAX_THREADS; i++)
     {
 
 #if !defined(_MSC_VER)
     {
 
 #if !defined(_MSC_VER)
@@ -2747,18 +2747,18 @@ namespace {
 
   void ThreadsManager::exit_threads() {
 
 
   void ThreadsManager::exit_threads() {
 
-    ActiveThreads = THREAD_MAX;  // HACK
+    ActiveThreads = MAX_THREADS;  // HACK
     AllThreadsShouldSleep = true;  // HACK
     wake_sleeping_threads();
     AllThreadsShouldExit = true;
     AllThreadsShouldSleep = true;  // HACK
     wake_sleeping_threads();
     AllThreadsShouldExit = true;
-    for (int i = 1; i < THREAD_MAX; i++)
+    for (int i = 1; i < MAX_THREADS; i++)
     {
         threads[i].stopRequest = true;
         while (threads[i].running);
     }
 
     // Now we can safely destroy the locks
     {
         threads[i].stopRequest = true;
         while (threads[i].running);
     }
 
     // Now we can safely destroy the locks
-    for (int i = 0; i < THREAD_MAX; i++)
+    for (int i = 0; i < MAX_THREADS; i++)
         for (int j = 0; j < ACTIVE_SPLIT_POINTS_MAX; j++)
             lock_destroy(&(SplitPointStack[i][j].lock));
   }
         for (int j = 0; j < ACTIVE_SPLIT_POINTS_MAX; j++)
             lock_destroy(&(SplitPointStack[i][j].lock));
   }
@@ -2827,10 +2827,10 @@ namespace {
   }
 
 
   }
 
 
-  // idle_thread_exists() tries to find an idle thread which is available as
+  // available_thread_exists() tries to find an idle thread which is available as
   // a slave for the thread with threadID "master".
 
   // a slave for the thread with threadID "master".
 
-  bool ThreadsManager::idle_thread_exists(int master) const {
+  bool ThreadsManager::available_thread_exists(int master) const {
 
     assert(master >= 0 && master < ActiveThreads);
     assert(ActiveThreads > 1);
 
     assert(master >= 0 && master < ActiveThreads);
     assert(ActiveThreads > 1);
@@ -2875,7 +2875,7 @@ namespace {
 
     // If no other thread is available to help us, or if we have too many
     // active split points, don't split.
 
     // If no other thread is available to help us, or if we have too many
     // active split points, don't split.
-    if (   !idle_thread_exists(master)
+    if (   !available_thread_exists(master)
         || threads[master].activeSplitPoints >= ACTIVE_SPLIT_POINTS_MAX)
     {
         lock_release(&MPLock);
         || threads[master].activeSplitPoints >= ACTIVE_SPLIT_POINTS_MAX)
     {
         lock_release(&MPLock);
@@ -2993,7 +2993,7 @@ namespace {
     pthread_cond_broadcast(&WaitCond);
     pthread_mutex_unlock(&WaitLock);
 #else
     pthread_cond_broadcast(&WaitCond);
     pthread_mutex_unlock(&WaitLock);
 #else
-    for (int i = 1; i < THREAD_MAX; i++)
+    for (int i = 1; i < MAX_THREADS; i++)
         SetEvent(SitIdleEvent[i]);
 #endif
 
         SetEvent(SitIdleEvent[i]);
 #endif
 
index fd4f42cfeb317d7339f2101c90d63972ad5f0669..e62857dd409b7df14ef90c59226f889b8413f570 100644 (file)
@@ -38,7 +38,7 @@
 //// Constants and variables
 ////
 
 //// Constants and variables
 ////
 
-const int THREAD_MAX = 8;
+const int MAX_THREADS = 8;
 const int ACTIVE_SPLIT_POINTS_MAX = 8;
 
 
 const int ACTIVE_SPLIT_POINTS_MAX = 8;
 
 
@@ -49,14 +49,14 @@ const int ACTIVE_SPLIT_POINTS_MAX = 8;
 struct SplitPoint {
   SplitPoint *parent;
   const Position* pos;
 struct SplitPoint {
   SplitPoint *parent;
   const Position* pos;
-  SearchStack sstack[THREAD_MAX][PLY_MAX_PLUS_2];
+  SearchStack sstack[MAX_THREADS][PLY_MAX_PLUS_2];
   SearchStack *parentSstack;
   int ply;
   Depth depth;
   volatile Value alpha, beta, bestValue;
   Value futilityValue;
   bool pvNode;
   SearchStack *parentSstack;
   int ply;
   Depth depth;
   volatile Value alpha, beta, bestValue;
   Value futilityValue;
   bool pvNode;
-  int master, slaves[THREAD_MAX];
+  int master, slaves[MAX_THREADS];
   Lock lock;
   MovePicker *mp;
   volatile int moves;
   Lock lock;
   MovePicker *mp;
   volatile int moves;
index e118d45be5614e9a86306915ea5ec91290b50f51..bc35865540aa151b734b306b483d8e26a4110633 100644 (file)
@@ -120,7 +120,7 @@ namespace {
     o["Randomness"] = Option(0, 0, 10);
     o["Minimum Split Depth"] = Option(4, 4, 7);
     o["Maximum Number of Threads per Split Point"] = Option(5, 4, 8);
     o["Randomness"] = Option(0, 0, 10);
     o["Minimum Split Depth"] = Option(4, 4, 7);
     o["Maximum Number of Threads per Split Point"] = Option(5, 4, 8);
-    o["Threads"] = Option(1, 1, THREAD_MAX);
+    o["Threads"] = Option(1, 1, MAX_THREADS);
     o["Hash"] = Option(32, 4, 8192);
     o["Clear Hash"] = Option(false, BUTTON);
     o["New Game"] = Option(false, BUTTON);
     o["Hash"] = Option(32, 4, 8192);
     o["Clear Hash"] = Option(false, BUTTON);
     o["New Game"] = Option(false, BUTTON);