Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
authormlaurent <mathieu.laurent@ens-rennes.fr>
Thu, 29 Jun 2023 11:14:05 +0000 (13:14 +0200)
committermlaurent <mathieu.laurent@ens-rennes.fr>
Thu, 29 Jun 2023 11:14:05 +0000 (13:14 +0200)
12 files changed:
1  2 
examples/cpp/task-storm/s4u-task-storm.cpp
examples/cpp/task-switch-host/s4u-task-switch-host.cpp
include/simgrid/s4u/Activity.hpp
include/simgrid/s4u/Task.hpp
src/bindings/python/simgrid_python.cpp
src/mc/api/strategy/MaxMatchComm.hpp
src/mc/api/strategy/MinMatchComm.hpp
src/mc/api/strategy/Strategy.hpp
src/mc/api/strategy/UniformStrategy.hpp
src/mc/mc_config.cpp
src/s4u/s4u_Comm.cpp
src/s4u/s4u_Task.cpp

Simple merge
@@@ -45,20 -45,20 +45,20 @@@ class Task 
    ActivityPtr previous_activity_;
    ActivityPtr current_activity_;
  
+   inline static xbt::signal<void(Task*)> on_start;
+   xbt::signal<void(Task*)> on_this_start;
+   inline static xbt::signal<void(Task*)> on_completion;
+   xbt::signal<void(Task*)> 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<void(Task*)> on_start;
-   xbt::signal<void(Task*)> on_this_start;
-   inline static xbt::signal<void(Task*)> on_completion;
-   xbt::signal<void(Task*)> on_this_completion;
  public:
    const std::string& get_name() const { return name_; }
    const char* get_cname() const { return name_.c_str(); }
@@@ -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<CommRecvTransition const*>(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<CommRecvTransition const*>(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<CommSendTransition const*>(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<CommSendTransition const*>(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);
      }
@@@ -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<CommRecvTransition const*>(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<CommRecvTransition const*>(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<CommSendTransition const*>(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<CommSendTransition const*>(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);
      }
@@@ -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;
    }
  
@@@ -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));
@@@ -66,11 -66,11 +66,11 @@@ simgrid::config::Flag<std::string> _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<int> _sg_mc_random_seed{"model-check/rand-seed",
                                                "give a specific random seed to initialize the uniform distribution", 0,
Simple merge
@@@ -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<Token> 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();
  }