From f09266746036b126d06684726fa19e6730d89018 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 16 Oct 2010 12:09:49 +0100 Subject: [PATCH] Retire now obsoleted do_sp_search() trampoline code We can call search() directly from idle_loop() No functional change. Signed-off-by: Marco Costalba --- src/search.cpp | 48 +++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 1a63299e..b8c6c952 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -295,9 +295,6 @@ namespace { template Value qsearch(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, int ply); - template - void do_sp_search(SplitPoint* sp, int threadID); - template Depth extension(const Position& pos, Move m, bool captureOrPromotion, bool moveIsCheck, bool singleEvasion, bool mateThreat, bool* dangerous); @@ -961,7 +958,12 @@ namespace { } - // search<>() is the main search function for both PV and non-PV nodes + // search<>() is the main search function for both PV and non-PV nodes and for + // normal and SplitPoint nodes. When called just after a split point the search + // is simpler because we have already probed the hash table, done a null move + // search, and searched the first move before splitting, we don't have to repeat + // all this work again. We also don't need to store anything to the hash table + // here: This is taken care of after we return from the split point. template Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, int ply) { @@ -994,7 +996,7 @@ namespace { ttMove = excludedMove = MOVE_NONE; threatMove = ss->sp->threatMove; mateThreat = ss->sp->mateThreat; - goto split_start; + goto split_point_start; } // Step 1. Initialize node and poll. Polling can abort search @@ -1180,7 +1182,7 @@ namespace { if (PvNode) mateThreat = pos.has_mate_threat(); -split_start: +split_point_start: // At split points actual search starts from here // Initialize a MovePicker object for the current position // FIXME currently MovePicker() c'tor is needless called also in SplitPoint @@ -1616,28 +1618,6 @@ split_start: } - // sp_search() is used to search from a split point. This function is called - // by each thread working at the split point. It is similar to the normal - // search() function, but simpler. Because we have already probed the hash - // table, done a null move search, and searched the first move before - // splitting, we don't have to repeat all this work in sp_search(). We - // also don't need to store anything to the hash table here: This is taken - // care of after we return from the split point. - - template - void do_sp_search(SplitPoint* sp, int threadID) { - - assert(threadID >= 0 && threadID < ThreadsMgr.active_threads()); - assert(ThreadsMgr.active_threads() > 1); - - Position pos(*sp->pos, threadID); - SearchStack* ss = sp->sstack[threadID] + 1; - ss->sp = sp; - - search(pos, ss, sp->alpha, sp->beta, sp->depth, sp->ply); - } - - // connected_moves() tests whether two moves are 'connected' in the sense // that the first move somehow made the second move possible (for instance // if the moving piece is the same in both moves). The first move is assumed @@ -2287,10 +2267,16 @@ split_start: threads[threadID].state = THREAD_SEARCHING; - if (threads[threadID].splitPoint->pvNode) - do_sp_search(threads[threadID].splitPoint, threadID); + // Here we call search() with SplitPoint template parameter set to true + SplitPoint* sp = threads[threadID].splitPoint; + Position pos(*sp->pos, threadID); + SearchStack* ss = sp->sstack[threadID] + 1; + ss->sp = sp; + + if (sp->pvNode) + search(pos, ss, sp->alpha, sp->beta, sp->depth, sp->ply); else - do_sp_search(threads[threadID].splitPoint, threadID); + search(pos, ss, sp->alpha, sp->beta, sp->depth, sp->ply); assert(threads[threadID].state == THREAD_SEARCHING); -- 2.39.2