Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add preliminary basic tests for ex(C) computation
[simgrid.git] / src / mc / transition / TransitionComm.cpp
index 9a332e2..54c27f6 100644 (file)
@@ -1,18 +1,16 @@
-/* Copyright (c) 2015-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/mc/transition/TransitionComm.hpp"
 #include "simgrid/config.h"
-#include "xbt/asserts.h"
-#include "xbt/string.hpp"
-#if SIMGRID_HAVE_MC
-#include "src/mc/ModelChecker.hpp"
 #include "src/mc/api/RemoteApp.hpp"
 #include "src/mc/api/State.hpp"
-#endif
+#include "xbt/asserts.h"
+#include "xbt/string.hpp"
 
+#include <inttypes.h>
 #include <sstream>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_trans_comm, mc_transition,
@@ -41,23 +39,16 @@ std::string CommWaitTransition::to_string(bool verbose) const
 }
 bool CommWaitTransition::depends(const Transition* other) const
 {
-  if (aid_ == other->aid_)
-    return false;
-
   if (other->type_ < type_)
     return other->depends(this);
 
+  // Actions executed by the same actor are always dependent
+  if (other->aid_ == aid_)
+    return true;
+
   if (const auto* wait = dynamic_cast<const CommWaitTransition*>(other)) {
     if (timeout_ || wait->timeout_)
       return true; // Timeouts are not considered by the independence theorem, thus assumed dependent
-
-    if (sbuff_ == wait->sbuff_ && rbuff_ == wait->rbuff_)
-      return false;
-    if (sbuff_ != 0 && rbuff_ != 0 && wait->sbuff_ != 0 && wait->rbuff_ != 0 && rbuff_ != wait->sbuff_ &&
-        rbuff_ != wait->rbuff_ && rbuff_ != sbuff_)
-      return false;
-
-    return true;
   }
 
   return false; // Comm transitions are INDEP with non-comm transitions
@@ -82,12 +73,13 @@ std::string CommTestTransition::to_string(bool verbose) const
 }
 bool CommTestTransition::depends(const Transition* other) const
 {
-  if (aid_ == other->aid_)
-    return false;
-
   if (other->type_ < type_)
     return other->depends(this);
 
+  // Actions executed by the same actor are always dependent
+  if (other->aid_ == aid_)
+    return true;
+
   if (dynamic_cast<const CommTestTransition*>(other) != nullptr)
     return false; // Test & Test are independent
 
@@ -102,6 +94,15 @@ bool CommTestTransition::depends(const Transition* other) const
   return false; // Comm transitions are INDEP with non-comm transitions
 }
 
+CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, uintptr_t comm_, unsigned mbox_,
+                                       uintptr_t rbuff_, int tag_)
+    : Transition(Type::COMM_ASYNC_RECV, issuer, times_considered)
+    , comm_(comm_)
+    , mbox_(mbox_)
+    , rbuff_(rbuff_)
+    , tag_(tag_)
+{
+}
 CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream)
     : Transition(Type::COMM_ASYNC_RECV, issuer, times_considered)
 {
@@ -117,12 +118,13 @@ std::string CommRecvTransition::to_string(bool verbose) const
 }
 bool CommRecvTransition::depends(const Transition* other) const
 {
-  if (aid_ == other->aid_)
-    return false;
-
   if (other->type_ < type_)
     return other->depends(this);
 
+  // Actions executed by the same actor are always dependent
+  if (other->aid_ == aid_)
+    return true;
+
   if (const auto* recv = dynamic_cast<const CommRecvTransition*>(other))
     return mbox_ == recv->mbox_;
 
@@ -139,7 +141,7 @@ bool CommRecvTransition::depends(const Transition* other) const
     return true; // DEP with other send transitions
   }
 
-  if (auto* wait = dynamic_cast<const CommWaitTransition*>(other)) {
+  if (const auto* wait = dynamic_cast<const CommWaitTransition*>(other)) {
     if (wait->timeout_)
       return true;
 
@@ -155,6 +157,16 @@ bool CommRecvTransition::depends(const Transition* other) const
   return false; // Comm transitions are INDEP with non-comm transitions
 }
 
+CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, uintptr_t comm_, unsigned mbox_,
+                                       uintptr_t sbuff_, size_t size_, int tag_)
+    : Transition(Type::COMM_ASYNC_SEND, issuer, times_considered)
+    , comm_(comm_)
+    , mbox_(mbox_)
+    , sbuff_(sbuff_)
+    , size_(size_)
+    , tag_(tag_)
+{
+}
 CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream)
     : Transition(Type::COMM_ASYNC_SEND, issuer, times_considered)
 {
@@ -172,12 +184,13 @@ std::string CommSendTransition::to_string(bool verbose = false) const
 
 bool CommSendTransition::depends(const Transition* other) const
 {
-  if (aid_ == other->aid_)
-    return false;
-
   if (other->type_ < type_)
     return other->depends(this);
 
+  // Actions executed by the same actor are always dependent
+  if (other->aid_ == aid_)
+    return true;
+
   if (const auto* other_isend = dynamic_cast<const CommSendTransition*>(other))
     return mbox_ == other_isend->mbox_;