From c435e3d43ed9d8b93d961fac9b7e20291322d3a0 Mon Sep 17 00:00:00 2001 From: borg323 Date: Tue, 27 Nov 2018 21:31:41 +0200 Subject: [PATCH 1/3] ensure bestmove is sent when aborting search --- src/mcts/search.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mcts/search.cc b/src/mcts/search.cc index 5b1de089b6..450e26d291 100644 --- a/src/mcts/search.cc +++ b/src/mcts/search.cc @@ -630,6 +630,10 @@ void Search::Stop() { void Search::Abort() { Mutex::Lock lock(counters_mutex_); + if (ok_to_respond_bestmove_ && !bestmove_is_sent_) { + best_move_callback_(GetBestChildNoTemperature(root_node_) + .GetMove(played_history_.IsBlackToMove())); + } bestmove_is_sent_ = true; FireStopInternal(); LOGFILE << "Aborting search, if it is still active."; From 3df9a61fad3ead2dfca3e44abaabdd9e76d1b942 Mon Sep 17 00:00:00 2001 From: borg323 Date: Wed, 28 Nov 2018 02:00:48 +0200 Subject: [PATCH 2/3] alternative in search destructor --- src/mcts/search.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/mcts/search.cc b/src/mcts/search.cc index 450e26d291..e297293693 100644 --- a/src/mcts/search.cc +++ b/src/mcts/search.cc @@ -630,10 +630,6 @@ void Search::Stop() { void Search::Abort() { Mutex::Lock lock(counters_mutex_); - if (ok_to_respond_bestmove_ && !bestmove_is_sent_) { - best_move_callback_(GetBestChildNoTemperature(root_node_) - .GetMove(played_history_.IsBlackToMove())); - } bestmove_is_sent_ = true; FireStopInternal(); LOGFILE << "Aborting search, if it is still active."; @@ -648,7 +644,7 @@ void Search::Wait() { } Search::~Search() { - Abort(); + if (!stop_.load(std::memory_order_acquire)) Abort(); Wait(); LOGFILE << "Search destroyed."; } From f759ac0fbfc07e83984b4e22b75dd01041fcb9f9 Mon Sep 17 00:00:00 2001 From: borg323 Date: Thu, 29 Nov 2018 20:44:14 +0200 Subject: [PATCH 3/3] new suggestion --- src/mcts/search.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mcts/search.cc b/src/mcts/search.cc index e297293693..b060988880 100644 --- a/src/mcts/search.cc +++ b/src/mcts/search.cc @@ -630,8 +630,10 @@ void Search::Stop() { void Search::Abort() { Mutex::Lock lock(counters_mutex_); - bestmove_is_sent_ = true; - FireStopInternal(); + if (!stop_.load(std::memory_order_acquire)) { + bestmove_is_sent_ = true; + FireStopInternal(); + } LOGFILE << "Aborting search, if it is still active."; } @@ -644,7 +646,7 @@ void Search::Wait() { } Search::~Search() { - if (!stop_.load(std::memory_order_acquire)) Abort(); + Abort(); Wait(); LOGFILE << "Search destroyed."; }