From: mlaurent Date: Thu, 29 Jun 2023 11:14:05 +0000 (+0200) Subject: Merge branch 'master' of https://framagit.org/simgrid/simgrid X-Git-Tag: v3.35~164^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d9c1e4df4ecfc39d84e55527fa05e9bd19f70c6c Merge branch 'master' of https://framagit.org/simgrid/simgrid --- d9c1e4df4ecfc39d84e55527fa05e9bd19f70c6c diff --cc include/simgrid/s4u/Task.hpp index 5c8050b86f,c776b898c3..f854adb86d --- a/include/simgrid/s4u/Task.hpp +++ b/include/simgrid/s4u/Task.hpp @@@ -45,20 -45,20 +45,20 @@@ class Task ActivityPtr previous_activity_; ActivityPtr current_activity_; + inline static xbt::signal on_start; + xbt::signal on_this_start; + inline static xbt::signal on_completion; + xbt::signal on_this_completion; + protected: explicit Task(const std::string& name); - virtual ~Task() = default; + virtual ~Task() = default; virtual void fire(); void complete(); - void set_current_activity (ActivityPtr a) { current_activity_ = a; } + void set_current_activity(ActivityPtr a) { current_activity_ = a; } - inline static xbt::signal on_start; - xbt::signal on_this_start; - inline static xbt::signal on_completion; - xbt::signal on_this_completion; - public: const std::string& get_name() const { return name_; } const char* get_cname() const { return name_.c_str(); } diff --cc src/mc/api/strategy/MaxMatchComm.hpp index 0bc3dade6a,ec279d0245..77dadd154c --- a/src/mc/api/strategy/MaxMatchComm.hpp +++ b/src/mc/api/strategy/MaxMatchComm.hpp @@@ -49,27 -49,23 +49,23 @@@ public int aid_value = value_of_state_; const Transition* transition = actor.get_transition(actor.get_times_considered()).get(); - - const CommRecvTransition* cast_recv = dynamic_cast(transition); - if (cast_recv != nullptr) { - if (mailbox_.count(cast_recv->get_mailbox()) > 0 and - mailbox_.at(cast_recv->get_mailbox()) > 0) { - aid_value--; // This means we have waiting recv corresponding to this recv - } else { + + if (auto const* cast_recv = dynamic_cast(transition)) { - if (mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) > 0) { - aid_value--; // This means we have waiting recv corresponding to this recv - } else { - aid_value++; - } ++ if (mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) > 0) { ++ aid_value--; // This means we have waiting recv corresponding to this recv ++ } else { + aid_value++; - } ++ } } - - const CommSendTransition* cast_send = dynamic_cast(transition); - if (cast_send != nullptr) { - if (mailbox_.count(cast_send->get_mailbox()) > 0 and - mailbox_.at(cast_send->get_mailbox()) < 0) { - aid_value--; // This means we have waiting recv corresponding to this send - }else { - aid_value++; - } + + if (auto const* cast_send = dynamic_cast(transition)) { - if (mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) < 0) { - aid_value--; // This means we have waiting recv corresponding to this send - } else { - aid_value++; - } ++ if (mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) < 0) { ++ aid_value--; // This means we have waiting recv corresponding to this send ++ } else { ++ aid_value++; ++ } } - + if (aid_value < min_found.second) min_found = std::make_pair(aid, aid_value); } diff --cc src/mc/api/strategy/MinMatchComm.hpp index 607a0a04a3,7393f4a71f..7d06c9dcf0 --- a/src/mc/api/strategy/MinMatchComm.hpp +++ b/src/mc/api/strategy/MinMatchComm.hpp @@@ -54,23 -54,21 +54,21 @@@ public int aid_value = value_of_state_; const Transition* transition = actor.get_transition(actor.get_times_considered()).get(); - const CommRecvTransition* cast_recv = dynamic_cast(transition); - if (cast_recv != nullptr) { - if ((mailbox_.count(cast_recv->get_mailbox()) > 0 and - mailbox_.at(cast_recv->get_mailbox()) <= 0) or mailbox_.count(cast_recv->get_mailbox()) == 0) - aid_value--; // This means we don't have waiting recv corresponding to this recv - else - aid_value++; + if (auto const* cast_recv = dynamic_cast(transition)) { - if ((mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) <= 0) || - mailbox_.count(cast_recv->get_mailbox()) == 0) - aid_value--; // This means we don't have waiting recv corresponding to this recv - else - aid_value++; ++ if ((mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) <= 0) || ++ mailbox_.count(cast_recv->get_mailbox()) == 0) ++ aid_value--; // This means we don't have waiting recv corresponding to this recv ++ else ++ aid_value++; } - const CommSendTransition* cast_send = dynamic_cast(transition); - if (cast_send != nullptr) { - if ((mailbox_.count(cast_send->get_mailbox()) > 0 and - mailbox_.at(cast_send->get_mailbox()) >= 0) or mailbox_.count(cast_send->get_mailbox()) == 0) - aid_value--; - else - aid_value++; + if (auto const* cast_send = dynamic_cast(transition)) { - if ((mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) >= 0) || - mailbox_.count(cast_send->get_mailbox()) == 0) - aid_value--; - else - aid_value++; ++ if ((mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) >= 0) || ++ mailbox_.count(cast_send->get_mailbox()) == 0) ++ aid_value--; ++ else ++ aid_value++; } - + if (aid_value < min_found.second) min_found = std::make_pair(aid, aid_value); } diff --cc src/mc/api/strategy/Strategy.hpp index 96eb753e02,f496ef5b7d..60e21f53fa --- a/src/mc/api/strategy/Strategy.hpp +++ b/src/mc/api/strategy/Strategy.hpp @@@ -66,10 -66,10 +66,10 @@@ public { unsigned long count = 0; for (auto& [_, actor] : actors_to_run_) - if (actor.is_enabled() and not actor.is_done()) { - if (actor.is_enabled() && not actor.is_done()) { -- actor.mark_todo(); -- count++; -- } ++ if (actor.is_enabled() && not actor.is_done()) { ++ actor.mark_todo(); ++ count++; ++ } return count; } diff --cc src/mc/api/strategy/UniformStrategy.hpp index cc5bd85773,472c571d3a..0b665a807b --- a/src/mc/api/strategy/UniformStrategy.hpp +++ b/src/mc/api/strategy/UniformStrategy.hpp @@@ -48,7 -48,7 +48,7 @@@ public chosen = xbt::random::uniform_int(0, possibilities-1); for (auto const& [aid, actor] : actors_to_run_) { - if (((not actor.is_todo()) and must_be_todo) or actor.is_done() or (not actor.is_enabled())) - if (((not actor.is_todo()) && must_be_todo) || actor.is_done() || (not actor.is_enabled())) ++ if (((not actor.is_todo()) && must_be_todo) || actor.is_done() || (not actor.is_enabled())) continue; if (chosen == 0) { return std::make_pair(aid, valuation.at(aid)); diff --cc src/mc/mc_config.cpp index bde1a6b886,8460a9154f..9253c04f0e --- a/src/mc/mc_config.cpp +++ b/src/mc/mc_config.cpp @@@ -66,11 -66,11 +66,11 @@@ simgrid::config::Flag _sg_ "model-check/strategy", "Specify the the kind of heuristic to use for guided model-checking", "none", - {{"none", "No specific strategy: simply pick the first available transistion and act as a DFS."}, + {{"none", "No specific strategy: simply pick the first available transition and act as a DFS."}, {"max_match_comm", "Try to minimize the number of in-fly communication by appairing matching send and receive."}, -- {"min_match_comm", "Try to maximize the number of in-fly communication by not appairing matching send and receive."}, -- {"uniform", "No specific strategy: choices are made randomly based on a uniform sampling."} -- }}; ++ {"min_match_comm", ++ "Try to maximize the number of in-fly communication by not appairing matching send and receive."}, ++ {"uniform", "No specific strategy: choices are made randomly based on a uniform sampling."}}}; simgrid::config::Flag _sg_mc_random_seed{"model-check/rand-seed", "give a specific random seed to initialize the uniform distribution", 0, diff --cc src/s4u/s4u_Task.cpp index b6d8ccd7ff,9419363f1d..ee75342eae --- a/src/s4u/s4u_Task.cpp +++ b/src/s4u/s4u_Task.cpp @@@ -45,11 -45,12 +45,12 @@@ bool Task::ready_to_run() cons void Task::receive(Task* source) { XBT_DEBUG("Task %s received a token from %s", name_.c_str(), source->name_.c_str()); - auto source_count = predecessors_[source]++; + auto source_count = predecessors_[source]; + predecessors_[source]++; if (tokens_received_.size() <= queued_firings_ + source_count) - tokens_received_.push_back({}); + tokens_received_.emplace_back(); tokens_received_[queued_firings_ + source_count][source] = source->token_; - bool enough_tokens = true; + bool enough_tokens = true; for (auto const& [key, val] : predecessors_) if (val < 1) { enough_tokens = false; @@@ -125,13 -126,12 +126,13 @@@ std::shared_ptr Task::get_next_t return tokens_received_.front()[t]; } -void Task::fire() { +void Task::fire() +{ on_this_start(this); on_start(this); - working_ = true; + working_ = true; queued_firings_ = std::max(queued_firings_ - 1, 0); - if (tokens_received_.size() > 0) + if (not tokens_received_.empty()) tokens_received_.pop_front(); }