Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Give the comm to {Send,Recv}Transition, as CommDet needs it
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 18 Feb 2022 00:25:50 +0000 (01:25 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 18 Feb 2022 00:25:57 +0000 (01:25 +0100)
src/kernel/activity/CommImpl.cpp
src/kernel/activity/CommImpl.hpp
src/kernel/actor/SimcallObserver.cpp
src/kernel/actor/SimcallObserver.hpp
src/mc/api/TransitionComm.cpp
src/mc/api/TransitionComm.hpp

index 98a5222..842d669 100644 (file)
@@ -267,7 +267,7 @@ void CommImpl::copy_data()
   copied_ = true;
 }
 
-ActivityImplPtr CommImpl::isend(const actor::CommIsendSimcall* observer)
+ActivityImplPtr CommImpl::isend(actor::CommIsendSimcall* observer)
 {
   auto* mbox = observer->get_mailbox();
   XBT_DEBUG("send from mailbox %p", mbox);
@@ -301,6 +301,7 @@ ActivityImplPtr CommImpl::isend(const actor::CommIsendSimcall* observer)
 
     other_comm->set_state(State::READY);
   }
+  observer->set_comm(other_comm.get());
 
   if (observer->is_detached()) {
     other_comm->detach();
@@ -329,7 +330,7 @@ ActivityImplPtr CommImpl::isend(const actor::CommIsendSimcall* observer)
   return (observer->is_detached() ? nullptr : other_comm);
 }
 
-ActivityImplPtr CommImpl::irecv(const actor::CommIrecvSimcall* observer)
+ActivityImplPtr CommImpl::irecv(actor::CommIrecvSimcall* observer)
 {
   CommImplPtr this_synchro(new CommImpl(CommImpl::Type::RECEIVE));
   auto* mbox = observer->get_mailbox();
@@ -376,6 +377,7 @@ ActivityImplPtr CommImpl::irecv(const actor::CommIrecvSimcall* observer)
     }
     observer->get_issuer()->activities_.emplace_back(other_comm);
   }
+  observer->set_comm(other_comm.get());
 
   /* Setup communication synchro */
   other_comm->dst_actor_ = observer->get_issuer();
index 7141785..3837b6b 100644 (file)
@@ -53,8 +53,8 @@ public:
   std::vector<s4u::Link*> get_traversed_links() const;
   void copy_data();
 
-  static ActivityImplPtr isend(const actor::CommIsendSimcall* observer);
-  static ActivityImplPtr irecv(const actor::CommIrecvSimcall* observer);
+  static ActivityImplPtr isend(actor::CommIsendSimcall* observer);
+  static ActivityImplPtr irecv(actor::CommIrecvSimcall* observer);
 
   bool test(actor::ActorImpl* issuer) override;
   void wait_for(actor::ActorImpl* issuer, double timeout) override;
index 7204336..9727778 100644 (file)
@@ -237,14 +237,14 @@ void ActivityWaitanySimcall::prepare(int times_considered)
 void CommIsendSimcall::serialize(std::stringstream& stream) const
 {
   stream << (short)mc::Transition::Type::COMM_SEND << ' ';
-  stream << mbox_->get_id() << ' ' << (void*)src_buff_ << ' ' << src_buff_size_;
+  stream << (void*)comm_ << ' ' << mbox_->get_id() << ' ' << (void*)src_buff_ << ' ' << src_buff_size_;
   XBT_DEBUG("SendObserver mbox:%u buff:%p size:%zu", mbox_->get_id(), src_buff_, src_buff_size_);
 }
 
 void CommIrecvSimcall::serialize(std::stringstream& stream) const
 {
   stream << (short)mc::Transition::Type::COMM_RECV << ' ';
-  stream << mbox_->get_id() << ' ' << (void*)dst_buff_;
+  stream << (void*)comm_ << ' ' << mbox_->get_id() << ' ' << (void*)dst_buff_;
 }
 
 } // namespace actor
index 98cada2..df8e285 100644 (file)
@@ -217,6 +217,7 @@ class CommIsendSimcall : public SimcallObserver {
   size_t src_buff_size_;
   void* payload_;
   bool detached_;
+  activity::CommImpl* comm_;
 
   bool (*match_fun_)(void*, void*, activity::CommImpl*);
   void (*clean_fun_)(void*); // used to free the synchro in case of problem after a detached send
@@ -250,6 +251,7 @@ public:
   size_t get_src_buff_size() const { return src_buff_size_; }
   void* get_payload() const { return payload_; }
   bool is_detached() const { return detached_; }
+  void set_comm(activity::CommImpl* comm) { comm_ = comm; }
 
   auto get_match_fun() const { return match_fun_; }
   auto get_clean_fun() const { return clean_fun_; }
@@ -262,6 +264,7 @@ class CommIrecvSimcall : public SimcallObserver {
   size_t* dst_buff_size_;
   void* payload_;
   double rate_;
+  activity::CommImpl* comm_;
 
   bool (*match_fun_)(void*, void*, activity::CommImpl*);
   void (*copy_data_fun_)(activity::CommImpl*, void*, size_t); // used to copy data if not default one
@@ -287,6 +290,7 @@ public:
   unsigned char* get_dst_buff() const { return dst_buff_; }
   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; }
 
   auto get_match_fun() const { return match_fun_; };
   auto get_copy_data_fun() const { return copy_data_fun_; }
index 6165996..0a846d6 100644 (file)
@@ -101,7 +101,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 >> mbox_ >> dst_buff_);
+  xbt_assert(stream >> comm_ >> mbox_ >> dst_buff_);
 }
 std::string CommRecvTransition::to_string(bool verbose) const
 {
@@ -150,8 +150,8 @@ 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 >> mbox_ >> src_buff_ >> size_);
-  XBT_DEBUG("SendTransition mbox:%u buff:%p size:%zu", mbox_, src_buff_, size_);
+  xbt_assert(stream >> comm_ >> mbox_ >> src_buff_ >> size_);
+  XBT_DEBUG("SendTransition comm:%p mbox:%u buff:%p size:%zu", comm_, mbox_, src_buff_, size_);
 }
 std::string CommSendTransition::to_string(bool verbose = false) const
 {
index 6f8a7c9..9d4a748 100644 (file)
@@ -56,6 +56,7 @@ public:
 };
 
 class CommRecvTransition : public Transition {
+  void* comm_; /* Addr of the CommImpl */
   unsigned mbox_;
   void* dst_buff_;
 
@@ -66,6 +67,7 @@ public:
 };
 
 class CommSendTransition : public Transition {
+  void* comm_; /* Addr of the CommImpl */
   unsigned mbox_;
   void* src_buff_;
   size_t size_;