Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
draft CommI{send,recv}Observer
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Thu, 3 Feb 2022 12:22:47 +0000 (13:22 +0100)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Thu, 3 Feb 2022 16:23:52 +0000 (17:23 +0100)
src/kernel/activity/CommImpl.cpp
src/kernel/activity/CommImpl.hpp
src/kernel/actor/SimcallObserver.cpp
src/kernel/actor/SimcallObserver.hpp
src/mc/api.cpp

index 1095f21..b6ef833 100644 (file)
@@ -24,8 +24,8 @@ XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sr
                                            void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                            void* data, double timeout)
 {
-  simgrid::kernel::activity::ActivityImplPtr comm = simcall_HANDLER_comm_isend(
-      simcall, src, mbox, task_size, rate, src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, false);
+  simgrid::kernel::activity::ActivityImplPtr comm = simgrid::kernel::activity::CommImpl::isend(
+      src, mbox, task_size, rate, src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, false);
   simcall->mc_value_ = 0;
   comm->wait_for(simcall->issuer_, timeout);
 }
@@ -48,8 +48,8 @@ XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t re
                                            void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                            void* data, double timeout, double rate)
 {
-  simgrid::kernel::activity::ActivityImplPtr comm = simcall_HANDLER_comm_irecv(
-      simcall, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
+  simgrid::kernel::activity::ActivityImplPtr comm = simgrid::kernel::activity::CommImpl::irecv(
+      receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
   simcall->mc_value_ = 0;
   comm->wait_for(simcall->issuer_, timeout);
 }
index 7d15267..5b131f0 100644 (file)
@@ -50,7 +50,7 @@ public:
   void copy_data();
 
   static ActivityImplPtr
-  isend(actor::ActorImpl*, MailboxImpl* mbox, double task_size, double rate, unsigned char* src_buff,
+  isend(actor::ActorImpl* src, MailboxImpl* mbox, double task_size, double rate, unsigned char* src_buff,
         size_t src_buff_size, bool (*match_fun)(void*, void*, CommImpl*),
         void (*clean_fun)(void*), // used to free the synchro in case of problem after a detached send
         void (*copy_data_fun)(CommImpl*, void*, size_t), // used to copy data if not default one
index 458135a..e793158 100644 (file)
@@ -410,6 +410,32 @@ std::string ActivityWaitanySimcall::to_string(int times_considered) const
   return res;
 }
 
+std::string CommIsendSimcall::to_string(int times_considered) const
+{
+  std::string res = SimcallObserver::to_string(times_considered) + "iSend(";
+  res += xbt::string_printf("src=[(%ld)%s (%s)]", get_issuer()->get_pid(), get_issuer()->get_host()->get_cname(),
+                            get_issuer()->get_cname());
+  res += XBT_LOG_ISENABLED(mc_observer, xbt_log_priority_verbose) ? xbt::string_printf(", buff=%p", src_buff_)
+                                                                  : "(verbose only)";
+  res += ", size=" +
+         (XBT_LOG_ISENABLED(mc_observer, xbt_log_priority_verbose) ? std::to_string(src_buff_size_) : "(verbose only)");
+  res += ")";
+  return res;
+}
+
+std::string CommIrecvSimcall::to_string(int times_considered) const
+{
+  std::string res = SimcallObserver::to_string(times_considered) + "iRecv(";
+  res += xbt::string_printf("dst=[(%ld)%s (%s)]", get_issuer()->get_pid(), get_issuer()->get_host()->get_cname(),
+                            get_issuer()->get_cname());
+  res += XBT_LOG_ISENABLED(mc_observer, xbt_log_priority_verbose) ? xbt::string_printf(", buff=%p", dst_buff_)
+                                                                  : "(verbose only)";
+  res += ", size=" + (XBT_LOG_ISENABLED(mc_observer, xbt_log_priority_verbose) ? std::to_string(*dst_buff_size_)
+                                                                               : "(verbose only)");
+  res += ")";
+  return res;
+}
+
 } // namespace actor
 } // namespace kernel
 } // namespace simgrid
index 77f94f8..a009e6b 100644 (file)
@@ -244,6 +244,100 @@ public:
   int get_value() const { return next_value_; }
 };
 
+class CommIsendSimcall : public ResultingSimcall<activity::ActivityImplPtr> {
+  activity::MailboxImpl* mbox_;
+  size_t payload_size_;
+  double rate_;
+  unsigned char* src_buff_;
+  size_t src_buff_size_;
+  void* payload_;
+  bool detached_;
+
+public:
+  bool (*match_fun_)(void*, void*, activity::CommImpl*);
+  void (*clean_fun_)(void*); // used to free the synchro in case of problem after a detached send
+  void (*copy_data_fun_)(activity::CommImpl*, void*, size_t); // used to copy data if not default one
+
+  CommIsendSimcall(ActorImpl* actor, activity::MailboxImpl* mbox, size_t payload_size, double rate,
+                   unsigned char* src_buff, size_t src_buff_size, bool (*match_fun)(void*, void*, activity::CommImpl*),
+                   void (*clean_fun)(void*), // used to free the synchro in case of problem after a detached send
+                   void (*copy_data_fun)(activity::CommImpl*, void*, size_t), // used to copy data if not default one
+                   void* payload, bool detached)
+      : ResultingSimcall(actor, nullptr)
+      , mbox_(mbox)
+      , payload_size_(payload_size)
+      , rate_(rate)
+      , src_buff_(src_buff)
+      , src_buff_size_(src_buff_size)
+      , payload_(payload)
+      , detached_(detached)
+      , match_fun_(match_fun)
+      , clean_fun_(clean_fun)
+      , copy_data_fun_(copy_data_fun)
+  {
+  }
+  CommIsendSimcall* clone() override
+  {
+    return new CommIsendSimcall(get_issuer(), mbox_, payload_size_, rate_, src_buff_, src_buff_size_, match_fun_,
+                                clean_fun_, copy_data_fun_, payload_, detached_);
+  }
+  bool is_visible() const override { return true; }
+  std::string to_string(int times_considered) const override;
+  std::string dot_label(int times_considered) const override
+  {
+    return SimcallObserver::dot_label(times_considered) + "iSend";
+  }
+  activity::MailboxImpl* get_mailbox() const { return mbox_; }
+  size_t get_payload_size() const { return payload_size_; }
+  double get_rate() const { return rate_; }
+  unsigned char* get_src_buff() const { return src_buff_; }
+  size_t get_src_buff_size() const { return src_buff_size_; }
+  void* get_payload() const { return payload_; }
+  bool is_detached() const { return detached_; }
+};
+
+class CommIrecvSimcall : public ResultingSimcall<activity::ActivityImplPtr> {
+  activity::MailboxImpl* mbox_;
+  unsigned char* dst_buff_;
+  size_t* dst_buff_size_;
+  void* payload_;
+  double rate_;
+
+public:
+  bool (*match_fun_)(void*, void*, activity::CommImpl*);
+  void (*copy_data_fun_)(activity::CommImpl*, void*, size_t); // used to copy data if not default one
+
+  CommIrecvSimcall(ActorImpl* actor, activity::MailboxImpl* mbox, unsigned char* dst_buff, size_t* dst_buff_size,
+                   bool (*match_fun)(void*, void*, activity::CommImpl*),
+                   void (*copy_data_fun)(activity::CommImpl*, void*, size_t), void* payload, double rate)
+      : ResultingSimcall(actor, nullptr)
+      , mbox_(mbox)
+      , dst_buff_(dst_buff)
+      , dst_buff_size_(dst_buff_size)
+      , payload_(payload)
+      , rate_(rate)
+      , match_fun_(match_fun)
+      , copy_data_fun_(copy_data_fun)
+  {
+  }
+  CommIrecvSimcall* clone() override
+  {
+    return new CommIrecvSimcall(get_issuer(), mbox_, dst_buff_, dst_buff_size_, match_fun_, copy_data_fun_, payload_,
+                                rate_);
+  }
+  bool is_visible() const override { return true; }
+  std::string to_string(int times_considered) const override;
+  std::string dot_label(int times_considered) const override
+  {
+    return SimcallObserver::dot_label(times_considered) + "iRecv";
+  }
+  activity::MailboxImpl* get_mailbox() const { return mbox_; }
+  double get_rate() const { return rate_; }
+  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_; }
+};
+
 } // namespace actor
 } // namespace kernel
 } // namespace simgrid
index 5e25c4c..b963b8e 100644 (file)
@@ -609,88 +609,23 @@ std::string Api::request_to_string(smx_simcall_t req, int value) const
 {
   xbt_assert(mc_model_checker != nullptr, "Must be called from MCer");
 
-  std::string type;
-  std::string args;
-
   smx_actor_t issuer = simcall_get_issuer(req);
 
   if (issuer->simcall_.observer_ != nullptr)
     return mc_model_checker->simcall_to_string(issuer->get_pid(), value);
-
-  switch (req->call_) {
-    case Simcall::COMM_ISEND:
-      type = "iSend";
-      args = "src=" + get_actor_string(issuer);
-      args += ", buff=" + pointer_to_string(simcall_comm_isend__get__src_buff(req));
-      args += ", size=" + buff_size_to_string(simcall_comm_isend__get__src_buff_size(req));
-      break;
-
-    case Simcall::COMM_IRECV: {
-      size_t* remote_size = simcall_comm_irecv__get__dst_buff_size(req);
-      size_t size         = 0;
-      if (remote_size)
-        mc_model_checker->get_remote_process().read_bytes(&size, sizeof(size), remote(remote_size));
-
-      type = "iRecv";
-      args = "dst=" + get_actor_string(issuer);
-      args += ", buff=" + pointer_to_string(simcall_comm_irecv__get__dst_buff(req));
-      args += ", size=" + buff_size_to_string(size);
-      break;
-    }
-
-    case Simcall::COMM_WAIT:
-      // See ActivityWaitSimcall::to_string(int times_considered)
-    case Simcall::COMM_TEST:
-      // See ActivityTestSimcall::to_string(int times_considered)
-    case Simcall::COMM_WAITANY:
-      // See ActivityWaitanySimcall::to_string(int times_considered)
-    case Simcall::COMM_TESTANY:
-      // See ActivityTestanySimcall::to_string(int times_considered)
-      break;
-
-    default:
-      type = SIMIX_simcall_name(*req);
-      args = "??";
-      break;
-  }
-
-  return "[" + get_actor_string(issuer) + "] " + type + "(" + args + ")";
+  else
+    return "[" + get_actor_string(issuer) + "] " + SIMIX_simcall_name(*req) + "(unknown?)";
 }
 
 std::string Api::request_get_dot_output(smx_simcall_t req, int value) const
 {
-  const smx_actor_t issuer = simcall_get_issuer(req);
-  const char* color        = get_color(issuer->get_pid() - 1);
-
-  std::string label;
-
   if (req->observer_ != nullptr) {
-    label = mc_model_checker->simcall_dot_label(issuer->get_pid(), value);
+    const smx_actor_t issuer = simcall_get_issuer(req);
+    const char* color        = get_color(issuer->get_pid() - 1);
+    return "label = \"" + mc_model_checker->simcall_dot_label(issuer->get_pid(), value) + "\", color = " + color +
+           ", fontcolor = " + color;
   } else
-    switch (req->call_) {
-      case Simcall::COMM_ISEND:
-        label = "[" + get_actor_dot_label(issuer) + "] iSend";
-        break;
-
-      case Simcall::COMM_IRECV:
-        label = "[" + get_actor_dot_label(issuer) + "] iRecv";
-        break;
-
-      case Simcall::COMM_WAIT:
-        // See ActivityWaitSimcall::dot_label(int times_considered)
-      case Simcall::COMM_TEST:
-        // See ActivityTestSimcall::dot_label(int times_considered)
-      case Simcall::COMM_WAITANY:
-        // See ActivityWaittanySimcall::dot_label(int times_considered)
-      case Simcall::COMM_TESTANY:
-        // See ActivityTestanySimcall::dot_label(int times_considered)
-        break;
-
-      default:
-        THROW_UNIMPLEMENTED;
-    }
-
-  return "label = \"" + label + "\", color = " + color + ", fontcolor = " + color;
+    return "UNIMPLEMENTED";
 }
 
 #if HAVE_SMPI