From: mlaurent Date: Fri, 31 Mar 2023 18:18:22 +0000 (+0200) Subject: Temporary fixes X-Git-Tag: v3.34~41^2~12^2~3 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/99af2be2b061257ef72e44066e6257e4a5d84a02 Temporary fixes --- diff --git a/src/mc/api/State.cpp b/src/mc/api/State.cpp index c2478cb9dd..e5eacf34fd 100644 --- a/src/mc/api/State.cpp +++ b/src/mc/api/State.cpp @@ -99,6 +99,7 @@ aid_t State::next_transition() const { XBT_DEBUG("Search for an actor to run. %zu actors to consider", strategy_->actors_to_run_.size()); for (auto const& [aid, actor] : strategy_->actors_to_run_) { + XBT_DEBUG("Current penalty for actor %ld:%f", aid, strategy_->penalties_[aid]); /* Only consider actors (1) marked as interleaving by the checker and (2) currently enabled in the application */ if (not actor.is_todo() || not actor.is_enabled() || actor.is_done()) { if (not actor.is_todo()) @@ -120,6 +121,19 @@ aid_t State::next_transition() const std::pair State::next_transition_guided() const { + for (auto const& [aid, actor] : strategy_->actors_to_run_) { + /* Only consider actors (1) marked as interleaving by the checker and (2) currently enabled in the application */ + if (not actor.is_todo() || not actor.is_enabled() || actor.is_done()) { + if (not actor.is_todo()) + XBT_DEBUG("Can't run actor %ld because it is not todo", aid); + + if (not actor.is_enabled()) + XBT_DEBUG("Can't run actor %ld because it is not enabled", aid); + + if (actor.is_done()) + XBT_DEBUG("Can't run actor %ld because it has already been done", aid); + } + } return strategy_->next_transition(); } diff --git a/src/mc/api/strategy/BasicStrategy.hpp b/src/mc/api/strategy/BasicStrategy.hpp index 9c1a482810..e2177fc04f 100644 --- a/src/mc/api/strategy/BasicStrategy.hpp +++ b/src/mc/api/strategy/BasicStrategy.hpp @@ -6,29 +6,58 @@ #ifndef SIMGRID_MC_BASICSTRATEGY_HPP #define SIMGRID_MC_BASICSTRATEGY_HPP +#include "src/mc/transition/Transition.hpp" + namespace simgrid::mc { /** Basic MC guiding class which corresponds to no guide at all (random choice) */ class BasicStrategy : public Strategy { public: - void operator=(const BasicStrategy&) { return; } + void operator=(const BasicStrategy& other) { this->penalties_ = other.penalties_; } - std::pair next_transition() const override + std::pair best_transition(bool need_to_be_todo) const { + auto min = std::make_pair(-1, 10000); for (auto const& [aid, actor] : actors_to_run_) { /* Only consider actors (1) marked as interleaving by the checker and (2) currently enabled in the application */ - if (not actor.is_todo() || not actor.is_enabled() || actor.is_done()) { + if ((not actor.is_todo() and need_to_be_todo) || not actor.is_enabled() || actor.is_done()) { continue; } + if (actor.get_transition(actor.get_times_considered())->type_ != Transition::Type::TESTANY) + return std::make_pair(aid, 0.0); - return std::make_pair(aid, 1.0); + double dist; + auto iterator = penalties_.find(aid); + if (iterator != penalties_.end()) + dist = (*iterator).second; + else + dist = 0; + if (dist < min.second) + min = std::make_pair(aid, dist); } - return std::make_pair(-1, 0.0); + if (min.first == -1) + return std::make_pair(-1, -1000); + return min; + } + + std::pair next_transition() const override { return best_transition(true); } + + void execute_next(aid_t aid, RemoteApp& app) override + { + auto actor = actors_to_run_.at(aid); + if (actor.get_transition(actor.get_times_considered())->type_ != Transition::Type::TESTANY) + penalties_[aid] += 1.0; + return; } - void execute_next(aid_t aid, RemoteApp& app) override { return; } void consider_best() override { + const auto& [aid, _] = this->best_transition(false); + auto actor = actors_to_run_.find(aid); + if (actor != actors_to_run_.end()) { + actor->second.mark_todo(); + return; + } for (auto& [_, actor] : actors_to_run_) { if (actor.is_todo()) return; diff --git a/src/mc/api/strategy/Strategy.hpp b/src/mc/api/strategy/Strategy.hpp index dc0cb106e2..8696b17924 100644 --- a/src/mc/api/strategy/Strategy.hpp +++ b/src/mc/api/strategy/Strategy.hpp @@ -17,6 +17,8 @@ protected: std::map actors_to_run_; public: + /** Used to store penalties computed by the strategy to each actor */ + std::map penalties_; virtual ~Strategy() = default; virtual std::pair next_transition() const = 0; virtual void execute_next(aid_t aid, RemoteApp& app) = 0; diff --git a/src/mc/explo/DFSExplorer.cpp b/src/mc/explo/DFSExplorer.cpp index 8f1fe11789..1067e970de 100644 --- a/src/mc/explo/DFSExplorer.cpp +++ b/src/mc/explo/DFSExplorer.cpp @@ -174,8 +174,9 @@ void DFSExplorer::run() // If there are processes to interleave and the maximum depth has not been // reached then perform one step of the exploration algorithm. - XBT_VERB("Execute %ld: %.60s (stack depth: %zu, state: %ld, %zu interleaves)", state->get_transition()->aid_, - state->get_transition()->to_string().c_str(), stack_.size(), state->get_num(), state->count_todo()); + XBT_VERB("Execute %ld: %.60s (stack depth: %zu, state: %ld, %zu interleaves out of %zu enabled)", + state->get_transition()->aid_, state->get_transition()->to_string().c_str(), stack_.size(), + state->get_num(), state->count_todo(), state->get_actor_count()); /* Create the new expanded state (copy the state of MCed into our MCer data) */ std::shared_ptr next_state = std::make_shared(get_remote_app(), state);