1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Rename THREAD_MAX in MAX_THREADS

Also rename idle_thread_exists() in available_thread_exists()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-02-20 13:38:04 +01:00
parent 7c61b8ad2a
commit 189a005a0b
5 changed files with 33 additions and 33 deletions

View file

@ -84,9 +84,9 @@ void benchmark(const string& commandLine) {
}
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);

View 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.
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;
@ -305,7 +305,7 @@ template<bool HasPopCnt>
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));
@ -440,9 +440,9 @@ Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
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)
{
@ -464,7 +464,7 @@ void init_eval(int threads) {
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];

View 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;
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();
@ -93,8 +93,8 @@ namespace {
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;
@ -102,7 +102,7 @@ namespace {
pthread_cond_t WaitCond;
pthread_mutex_t WaitLock;
#else
HANDLE SitIdleEvent[THREAD_MAX];
HANDLE SitIdleEvent[MAX_THREADS];
#endif
};
@ -1208,7 +1208,7 @@ namespace {
&& 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,
@ -1522,7 +1522,7 @@ namespace {
&& 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
@ -2585,13 +2585,13 @@ namespace {
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() {
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;
}
@ -2607,7 +2607,7 @@ namespace {
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)];
@ -2621,7 +2621,7 @@ namespace {
void ThreadsManager::idle_loop(int threadID, SplitPoint* waitSp) {
assert(threadID >= 0 && threadID < THREAD_MAX);
assert(threadID >= 0 && threadID < MAX_THREADS);
threads[threadID].running = true;
@ -2693,7 +2693,7 @@ namespace {
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;
@ -2704,7 +2704,7 @@ namespace {
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
@ -2716,11 +2716,11 @@ namespace {
// 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
for (i = 1; i < THREAD_MAX; i++)
for (i = 1; i < MAX_THREADS; i++)
{
#if !defined(_MSC_VER)
@ -2747,18 +2747,18 @@ namespace {
void ThreadsManager::exit_threads() {
ActiveThreads = THREAD_MAX; // HACK
ActiveThreads = MAX_THREADS; // HACK
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
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));
}
@ -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".
bool ThreadsManager::idle_thread_exists(int master) const {
bool ThreadsManager::available_thread_exists(int master) const {
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 ( !idle_thread_exists(master)
if ( !available_thread_exists(master)
|| threads[master].activeSplitPoints >= ACTIVE_SPLIT_POINTS_MAX)
{
lock_release(&MPLock);
@ -2993,7 +2993,7 @@ namespace {
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

View file

@ -38,7 +38,7 @@
//// Constants and variables
////
const int THREAD_MAX = 8;
const int MAX_THREADS = 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;
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;
int master, slaves[THREAD_MAX];
int master, slaves[MAX_THREADS];
Lock lock;
MovePicker *mp;
volatile int moves;

View 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["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);