Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix the depends of iSend/iRecv vs. WaitComm to fix the bugged2 example
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 11 Feb 2022 23:26:41 +0000 (00:26 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 11 Feb 2022 23:26:41 +0000 (00:26 +0100)
examples/cpp/mc-bugged2/s4u-mc-bugged2.cpp
src/mc/api/TransitionComm.cpp

index df2b83f..1f6d3c3 100644 (file)
@@ -20,25 +20,25 @@ static void server()
 
   received1 = simgrid::s4u::Mailbox::by_name("mymailbox")->get<int>();
   long val1 = *received1;
-  received1 = nullptr;
-  XBT_INFO("Received %ld", val1);
+  delete received1;
 
   received2 = simgrid::s4u::Mailbox::by_name("mymailbox")->get<int>();
   long val2 = *received2;
-  received2 = nullptr;
-  XBT_INFO("Received %ld", val2);
+  delete received2;
 
-  MC_assert(std::min(val1, val2) == 1);
+  XBT_INFO("First pair received: %ld %ld", val1, val2);
+
+  MC_assert(std::min(val1, val2) == 1); // if the two messages of the second client arrive first, this is violated.
 
   received1 = simgrid::s4u::Mailbox::by_name("mymailbox")->get<int>();
   val1      = *received1;
-  XBT_INFO("Received %ld", val1);
+  delete received1;
 
   received2 = simgrid::s4u::Mailbox::by_name("mymailbox")->get<int>();
   val2      = *received2;
-  XBT_INFO("Received %ld", val2);
+  delete received2;
 
-  XBT_INFO("OK");
+  XBT_INFO("Second pair received: %ld %ld", val1, val2);
 }
 
 static void client(int id)
@@ -46,10 +46,7 @@ static void client(int id)
   auto* payload1 = new int(id);
   auto* payload2 = new int(id);
 
-  XBT_INFO("Send %d", id);
   simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload1, 10000);
-
-  XBT_INFO("Send %d", id);
   simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload2, 10000);
 }
 
index 1e38480..6fa6730 100644 (file)
@@ -103,10 +103,7 @@ bool CommRecvTransition::depends(const Transition* other) const
     if (mbox_ != wait->mbox_)
       return false;
 
-    if ((aid_ != wait->sender_) && (aid_ != wait->receiver_))
-      return false;
-
-    if (wait->dst_buff_ != dst_buff_)
+    if ((aid_ != wait->sender_) && (aid_ != wait->receiver_) && (wait->dst_buff_ != dst_buff_))
       return false;
   }
 
@@ -146,7 +143,6 @@ bool CommSendTransition::depends(const Transition* other) const
   if (const auto* other_isend = dynamic_cast<const CommSendTransition*>(other))
     return mbox_ == other_isend->mbox_;
 
-  // FIXME: Not in the former dependency check because of the ordering but seems logical to add it
   if (dynamic_cast<const CommRecvTransition*>(other) != nullptr)
     return false;
 
@@ -157,10 +153,7 @@ bool CommSendTransition::depends(const Transition* other) const
     if (mbox_ != wait->mbox_)
       return false;
 
-    if ((aid_ != wait->sender_) && (aid_ != wait->receiver_))
-      return false;
-
-    if (wait->src_buff_ != src_buff_)
+    if ((aid_ != wait->sender_) && (aid_ != wait->receiver_) && (wait->src_buff_ != src_buff_))
       return false;
   }