Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / src / mc / api / strategy / MinMatchComm.hpp
index 665c92f..e8fc1f4 100644 (file)
@@ -13,8 +13,6 @@ namespace simgrid::mc {
 /** Wait MC guiding class that aims at maximizing the number of in-fly communication.
  *  When possible, it will try not to match communications. */
 class MinMatchComm : public Strategy {
-
-    
   /** Stores for each mailbox what kind of transition is waiting on it.
    *  Negative number means that much recv are waiting on that mailbox, while
    *  a positiv number means that much send are waiting there. */
@@ -48,7 +46,7 @@ public:
 
  std::pair<aid_t, int> best_transition(bool must_be_todo) const override
   {
-    std::pair<aid_t, int> min_found = std::make_pair(-1, value_of_state_+2);
+    std::pair<aid_t, int> min_found = std::make_pair(-1, value_of_state_ + 2);
     for (auto const& [aid, actor] : actors_to_run_) {
        if ((not actor.is_todo() && must_be_todo) || not actor.is_enabled() || actor.is_done())
            continue;
@@ -56,23 +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++;
       }
-      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 (aid_value < min_found.second)
          min_found = std::make_pair(aid, aid_value);
     }
@@ -85,15 +81,12 @@ public:
       const Transition* transition = actors_to_run_.at(aid).get_transition(actors_to_run_.at(aid).get_times_considered()).get();
     last_transition_             = transition->type_;
 
-    const CommRecvTransition* cast_recv = dynamic_cast<CommRecvTransition const*>(transition);
-    if (cast_recv != nullptr)
+    if (auto const* cast_recv = dynamic_cast<CommRecvTransition const*>(transition))
       last_mailbox_ = cast_recv->get_mailbox();
 
-    const CommSendTransition* cast_send = dynamic_cast<CommSendTransition const*>(transition);
-    if (cast_send != nullptr)
+    if (auto const* cast_send = dynamic_cast<CommSendTransition const*>(transition))
       last_mailbox_ = cast_send->get_mailbox();
   }
-
 };
 
 } // namespace simgrid::mc