X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=768b0594e559113806f4fa9799c7eeb0bc71824a;hp=36ed82f2771a9c595c70c8835b2f7e9611fada31;hb=6e5bb3279f84428818f65cbcb9903ba77fd28423;hpb=d72e862a5b4bc65f04c4f40f9005042d0e9eee9a diff --git a/src/search.cpp b/src/search.cpp index 36ed82f2..768b0594 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -89,8 +89,8 @@ namespace { void idle_loop(int threadID, SplitPoint* sp); template - bool split(const Position& pos, SearchStack* ss, int ply, Value* alpha, const Value beta, Value* bestValue, - Depth depth, bool mateThreat, int* moves, MovePicker* mp, int master, bool pvNode); + void split(const Position& pos, SearchStack* ss, int ply, Value* alpha, const Value beta, Value* bestValue, + Depth depth, bool mateThreat, int* moveCount, MovePicker* mp, int master, bool pvNode); private: friend void poll(); @@ -1283,7 +1283,9 @@ namespace { continue; // Value based pruning - Depth predictedDepth = newDepth - reduction(depth, moveCount); // FIXME We illogically ignore reduction condition depth >= 3*OnePly + // We illogically ignore reduction condition depth >= 3*OnePly for predicted depth, + // but fixing this made program slightly weaker. + Depth predictedDepth = newDepth - reduction(depth, moveCount); futilityValueScaled = ss[ply].eval + futility_margin(predictedDepth, moveCount) + H.gain(pos.piece_on(move_from(move)), move_to(move)); @@ -1364,10 +1366,9 @@ namespace { && Iteration <= 99 && TM.available_thread_exists(threadID) && !AbortSearch - && !TM.thread_should_stop(threadID) - && TM.split(pos, ss, ply, &alpha, beta, &bestValue, depth, - mateThreat, &moveCount, &mp, threadID, PvNode)) - break; + && !TM.thread_should_stop(threadID)) + TM.split(pos, ss, ply, &alpha, beta, &bestValue, depth, + mateThreat, &moveCount, &mp, threadID, PvNode); } // Step 19. Check for mate and stalemate @@ -1633,7 +1634,7 @@ namespace { && (move = sp->mp->get_next_move()) != MOVE_NONE && !TM.thread_should_stop(threadID)) { - moveCount = ++sp->moves; + moveCount = ++sp->moveCount; lock_release(&(sp->lock)); assert(move_is_ok(move)); @@ -2587,20 +2588,19 @@ namespace { // split() does the actual work of distributing the work at a node between - // several threads at PV nodes. If it does not succeed in splitting the + // several available threads. If it does not succeed in splitting the // node (because no idle threads are available, or because we have no unused - // split point objects), the function immediately returns false. If - // splitting is possible, a SplitPoint object is initialized with all the - // data that must be copied to the helper threads (the current position and - // search stack, alpha, beta, the search depth, etc.), and we tell our - // helper threads that they have been assigned work. This will cause them - // to instantly leave their idle loops and call sp_search(). When all - // threads have returned from sp_search() then split() returns true. + // split point objects), the function immediately returns. If splitting is + // possible, a SplitPoint object is initialized with all the data that must be + // copied to the helper threads and we tell our helper threads that they have + // been assigned work. This will cause them to instantly leave their idle loops + // and call sp_search(). When all threads have returned from sp_search() then + // split() returns. template - bool ThreadsManager::split(const Position& p, SearchStack* sstck, int ply, Value* alpha, + void ThreadsManager::split(const Position& p, SearchStack* sstck, int ply, Value* alpha, const Value beta, Value* bestValue, Depth depth, bool mateThreat, - int* moves, MovePicker* mp, int master, bool pvNode) { + int* moveCount, MovePicker* mp, int master, bool pvNode) { assert(p.is_ok()); assert(sstck != NULL); assert(ply >= 0 && ply < PLY_MAX); @@ -2612,8 +2612,6 @@ namespace { assert(master >= 0 && master < ActiveThreads); assert(ActiveThreads > 1); - SplitPoint* splitPoint; - lock_grab(&MPLock); // If no other thread is available to help us, or if we have too many @@ -2622,11 +2620,11 @@ namespace { || threads[master].activeSplitPoints >= ACTIVE_SPLIT_POINTS_MAX) { lock_release(&MPLock); - return false; + return; } // Pick the next available split point object from the split point stack - splitPoint = &SplitPointStack[master][threads[master].activeSplitPoints]; + SplitPoint* splitPoint = &SplitPointStack[master][threads[master].activeSplitPoints]; // Initialize the split point object splitPoint->parent = threads[master].splitPoint; @@ -2638,9 +2636,8 @@ namespace { splitPoint->beta = beta; splitPoint->pvNode = pvNode; splitPoint->bestValue = *bestValue; - splitPoint->master = master; splitPoint->mp = mp; - splitPoint->moves = *moves; + splitPoint->moveCount = *moveCount; splitPoint->pos = &p; splitPoint->parentSstack = sstck; for (int i = 0; i < ActiveThreads; i++) @@ -2698,7 +2695,6 @@ namespace { threads[master].splitPoint = splitPoint->parent; lock_release(&MPLock); - return true; }