Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add the MPI tag to the Send/Recv Transitions
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 18 Feb 2022 19:53:18 +0000 (20:53 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 18 Feb 2022 19:53:18 +0000 (20:53 +0100)
src/kernel/actor/SimcallObserver.cpp
src/kernel/actor/SimcallObserver.hpp
src/mc/api/TransitionComm.cpp
src/mc/api/TransitionComm.hpp
src/mc/checker/CommunicationDeterminismChecker.cpp
src/smpi/mpi/smpi_request.cpp

index f869507..6da0ea5 100644 (file)
@@ -237,15 +237,17 @@ void ActivityWaitanySimcall::prepare(int times_considered)
 void CommIsendSimcall::serialize(std::stringstream& stream) const
 {
   stream << (short)mc::Transition::Type::COMM_SEND << ' ';
-  stream << (uintptr_t)comm_ << ' ' << mbox_->get_id() << ' ' << (uintptr_t)src_buff_ << ' ' << src_buff_size_;
-  XBT_DEBUG("SendObserver comm:%p mbox:%u buff:%p size:%zu", comm_, mbox_->get_id(), src_buff_, src_buff_size_);
+  stream << (uintptr_t)comm_ << ' ' << mbox_->get_id() << ' ' << (uintptr_t)src_buff_ << ' ' << src_buff_size_ << ' '
+         << tag_;
+  XBT_DEBUG("SendObserver comm:%p mbox:%u buff:%p size:%zu tag:%d", comm_, mbox_->get_id(), src_buff_, src_buff_size_,
+            tag_);
 }
 
 void CommIrecvSimcall::serialize(std::stringstream& stream) const
 {
   stream << (short)mc::Transition::Type::COMM_RECV << ' ';
-  stream << (uintptr_t)comm_ << ' ' << mbox_->get_id() << ' ' << (uintptr_t)dst_buff_;
-  XBT_DEBUG("RecvObserver comm:%p mbox:%u buff:%p", comm_, mbox_->get_id(), dst_buff_);
+  stream << (uintptr_t)comm_ << ' ' << mbox_->get_id() << ' ' << (uintptr_t)dst_buff_ << ' ' << tag_;
+  XBT_DEBUG("RecvObserver comm:%p mbox:%u buff:%p tag:%d", comm_, mbox_->get_id(), dst_buff_, tag_);
 }
 
 } // namespace actor
index df8e285..23086f8 100644 (file)
@@ -218,6 +218,7 @@ class CommIsendSimcall : public SimcallObserver {
   void* payload_;
   bool detached_;
   activity::CommImpl* comm_;
+  int tag_;
 
   bool (*match_fun_)(void*, void*, activity::CommImpl*);
   void (*clean_fun_)(void*); // used to free the synchro in case of problem after a detached send
@@ -252,6 +253,7 @@ public:
   void* get_payload() const { return payload_; }
   bool is_detached() const { return detached_; }
   void set_comm(activity::CommImpl* comm) { comm_ = comm; }
+  void set_tag(int tag) { tag_ = tag; }
 
   auto get_match_fun() const { return match_fun_; }
   auto get_clean_fun() const { return clean_fun_; }
@@ -264,6 +266,7 @@ class CommIrecvSimcall : public SimcallObserver {
   size_t* dst_buff_size_;
   void* payload_;
   double rate_;
+  int tag_;
   activity::CommImpl* comm_;
 
   bool (*match_fun_)(void*, void*, activity::CommImpl*);
@@ -291,6 +294,7 @@ public:
   size_t* get_dst_buff_size() const { return dst_buff_size_; }
   void* get_payload() const { return payload_; }
   void set_comm(activity::CommImpl* comm) { comm_ = comm; }
+  void set_tag(int tag) { tag_ = tag; }
 
   auto get_match_fun() const { return match_fun_; };
   auto get_copy_data_fun() const { return copy_data_fun_; }
index 13094fb..cab3f10 100644 (file)
@@ -103,7 +103,7 @@ bool CommTestTransition::depends(const Transition* other) const
 CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream)
     : Transition(Type::COMM_RECV, issuer, times_considered)
 {
-  xbt_assert(stream >> comm_ >> mbox_ >> rbuff_);
+  xbt_assert(stream >> comm_ >> mbox_ >> rbuff_ >> tag_);
 }
 std::string CommRecvTransition::to_string(bool verbose) const
 {
@@ -152,7 +152,7 @@ bool CommRecvTransition::depends(const Transition* other) const
 CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream)
     : Transition(Type::COMM_SEND, issuer, times_considered)
 {
-  xbt_assert(stream >> comm_ >> mbox_ >> sbuff_ >> size_);
+  xbt_assert(stream >> comm_ >> mbox_ >> sbuff_ >> size_ >> tag_);
   XBT_DEBUG("SendTransition comm:%" PRIxPTR " mbox:%u sbuff:%" PRIxPTR " size:%zu", comm_, mbox_, sbuff_, size_);
 }
 std::string CommSendTransition::to_string(bool verbose = false) const
index 7b7fbf4..2c244f6 100644 (file)
@@ -90,6 +90,7 @@ class CommRecvTransition : public Transition {
   uintptr_t comm_; /* Addr of the CommImpl */
   unsigned mbox_;
   uintptr_t rbuff_;
+  int tag_;
 
 public:
   CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream);
@@ -102,6 +103,8 @@ public:
   unsigned get_mailbox() const { return mbox_; }
   /** Receiver buffer */
   uintptr_t get_rbuff() const { return rbuff_; }
+  /** If using SMPI, the tag */
+  int get_tag() const { return tag_; }
 };
 
 class CommSendTransition : public Transition {
@@ -109,6 +112,7 @@ class CommSendTransition : public Transition {
   unsigned mbox_;
   uintptr_t sbuff_;
   size_t size_;
+  int tag_;
 
 public:
   CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream);
@@ -123,6 +127,8 @@ public:
   uintptr_t get_sbuff() const { return sbuff_; }
   /** data size */
   size_t get_size() const { return size_; }
+  /** If using SMPI, the tag */
+  int get_tag() const { return tag_; }
 };
 
 class TestAnyTransition : public Transition {
index 50f2d68..e0d25a5 100644 (file)
@@ -46,11 +46,10 @@ public:
     // num?
     res.comm_addr = this->comm_addr;
     res.type      = this->type;
-    // src_proc?
-    // dst_proc?
+    res.src_proc  = this->src_proc;
     res.dst_proc = this->dst_proc;
     res.mbox     = this->mbox;
-    // tag?
+    res.tag       = this->tag;
     res.index = this->index;
     return res;
   }
@@ -253,10 +252,7 @@ void CommDetExtension::get_comm_pattern(const Transition* transition, bool backt
     pattern->comm_addr = send->get_comm();
     pattern->mbox      = send->get_mailbox();
     pattern->src_proc  = send->aid_;
-
-#if HAVE_SMPI
-    pattern->tag = 0; // FIXME: replace it by the real tag from the observer
-#endif
+    pattern->tag       = send->get_tag();
 
 #if HAVE_SMPI
     // auto send_detached = api::get().check_send_request_detached(request);
@@ -277,10 +273,7 @@ void CommDetExtension::get_comm_pattern(const Transition* transition, bool backt
 
     pattern->type = PatternCommunicationType::receive;
     pattern->comm_addr = recv->get_comm();
-
-#if HAVE_SMPI
-    pattern->tag = 0; // FIXME: replace it by the real tag from the observer
-#endif
+    pattern->tag       = recv->get_tag();
     pattern->mbox     = recv->get_mailbox();
     pattern->dst_proc = recv->aid_;
   }
index b690a14..e8ab078 100644 (file)
@@ -519,6 +519,7 @@ void Request::start()
                                                                   : smpi_comm_copy_data_callback,
                                              this,
                                              -1.0};
+    observer.set_tag(tag_);
 
     action_ = kernel::actor::simcall([&observer] { return kernel::activity::CommImpl::irecv(&observer); }, &observer);
 
@@ -624,6 +625,7 @@ void Request::start()
         process->replaying() ? &smpi_comm_null_copy_buffer_callback : smpi_comm_copy_data_callback, this,
         // detach if msg size < eager/rdv switch limit
         detached_};
+    observer.set_tag(tag_);
     action_ = kernel::actor::simcall([&observer] { return kernel::activity::CommImpl::isend(&observer); }, &observer);
     XBT_DEBUG("send simcall posted");