Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
CommImpl: don't mix state and type, and make type_ const
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 5 Feb 2021 08:37:20 +0000 (09:37 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 5 Feb 2021 08:48:46 +0000 (09:48 +0100)
src/kernel/activity/CommImpl.cpp
src/kernel/activity/CommImpl.hpp
src/mc/api.cpp
src/mc/mc_base.cpp

index c57f0a7..630a2c2 100644 (file)
@@ -69,7 +69,6 @@ XBT_PRIVATE simgrid::kernel::activity::ActivityImplPtr simcall_HANDLER_comm_isen
     XBT_DEBUG("Receive already pushed");
 
     other_comm->state_ = simgrid::kernel::activity::State::READY;
-    other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::READY);
   }
 
   if (detached) {
@@ -136,7 +135,7 @@ simcall_HANDLER_comm_irecv(smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_
       if (other_comm->surf_action_ && other_comm->get_remaining() < 1e-12) {
         XBT_DEBUG("comm %p has been already sent, and is finished, destroy it", other_comm.get());
         other_comm->state_ = simgrid::kernel::activity::State::DONE;
-        other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::DONE).set_mailbox(nullptr);
+        other_comm->set_mailbox(nullptr);
       }
     }
   } else {
@@ -158,7 +157,6 @@ simcall_HANDLER_comm_irecv(smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_
       XBT_DEBUG("Match my %p with the existing %p", this_synchro.get(), other_comm.get());
 
       other_comm->state_ = simgrid::kernel::activity::State::READY;
-      other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::READY);
     }
     receiver->activities_.emplace_back(other_comm);
   }
@@ -365,12 +363,6 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-CommImpl& CommImpl::set_type(CommImpl::Type type)
-{
-  type_ = type;
-  return *this;
-}
-
 CommImpl& CommImpl::set_size(double size)
 {
   size_ = size;
index 195209d..e9485d6 100644 (file)
@@ -26,12 +26,11 @@ class XBT_PUBLIC CommImpl : public ActivityImpl_T<CommImpl> {
   MailboxImpl* mbox_ = nullptr; /* Rendez-vous where the comm is queued */
 
 public:
-  enum class Type { SEND = 0, RECEIVE, READY, DONE };
+  enum class Type { SEND, RECEIVE };
 
   CommImpl(Type type) : type_(type) {}
   CommImpl(s4u::Host* from, s4u::Host* to, double bytes);
 
-  CommImpl& set_type(CommImpl::Type type);
   CommImpl& set_size(double size);
   CommImpl& set_src_buff(unsigned char* buff, size_t size);
   CommImpl& set_dst_buff(unsigned char* buff, size_t* size);
@@ -52,7 +51,7 @@ public:
   void post() override;
   void finish() override;
 
-  CommImpl::Type type_; /* Type of the communication (SEND or RECEIVE) */
+  const CommImpl::Type type_; /* Type of the communication (SEND or RECEIVE) */
 
 #if SIMGRID_HAVE_MC
   MailboxImpl* mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
index 89f93c5..6c1504d 100644 (file)
@@ -118,7 +118,7 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta
       const simgrid::kernel::activity::CommImpl* act = temp_act.get_buffer();
       if (act->src_actor_.get() && act->dst_actor_.get())
         state->transition_.argument_ = 0; // OK
-      else if (act->src_actor_.get() == nullptr && act->type_ == simgrid::kernel::activity::CommImpl::Type::READY &&
+      else if (act->src_actor_.get() == nullptr && act->state_ == simgrid::kernel::activity::State::READY &&
                act->detached())
         state->transition_.argument_ = 0; // OK
       else
index 5cc8b49..8274ec2 100644 (file)
@@ -102,8 +102,7 @@ bool actor_is_enabled(smx_actor_t actor)
           return true;
       }
       /* On the other hand if it hasn't a timeout, check if the comm is ready.*/
-      else if (act->detached() && act->src_actor_ == nullptr &&
-               act->type_ == simgrid::kernel::activity::CommImpl::Type::READY)
+      else if (act->detached() && act->src_actor_ == nullptr && act->state_ == simgrid::kernel::activity::State::READY)
         return (act->dst_actor_ != nullptr);
       return (act->src_actor_ && act->dst_actor_);
     }