Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
finish the conversion C++ of simix::MailboxImpl
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 12 Feb 2017 20:48:53 +0000 (21:48 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 12 Feb 2017 21:21:50 +0000 (22:21 +0100)
12 files changed:
include/simgrid/s4u/Actor.hpp
include/simgrid/simix.h
src/s4u/s4u_mailbox.cpp
src/simix/MailboxImpl.cpp
src/simix/MailboxImpl.hpp
src/simix/libsmx.cpp
src/simix/popping_accessors.h
src/simix/popping_bodies.cpp
src/simix/popping_enum.h
src/simix/popping_generated.cpp
src/simix/simcalls.in
src/smpi/smpi_global.cpp

index 40db256..56c644e 100644 (file)
@@ -134,6 +134,7 @@ namespace s4u {
 XBT_PUBLIC_CLASS Actor {
   friend Mailbox;
   friend simgrid::simix::ActorImpl;
+  friend simgrid::simix::MailboxImpl;
   simix::ActorImpl* pimpl_ = nullptr;
 
   /** Wrap a (possibly non-copyable) single-use task into a `std::function` */
index 053849a..02d8112 100644 (file)
@@ -291,11 +291,6 @@ XBT_PUBLIC(void) simcall_process_join(smx_actor_t process, double timeout);
 XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration);
 
 /************************** Comunication simcalls *****************************/
-/***** Rendez-vous points *****/
-
-XBT_PUBLIC(void) simcall_mbox_set_receiver(smx_mailbox_t mbox , smx_actor_t process);
-
-/***** Communication simcalls *****/
 
 XBT_PUBLIC(void) simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size,
                                      double rate, void *src_buff,
index 9e5f3f4..ed78c03 100644 (file)
@@ -47,7 +47,9 @@ smx_activity_t Mailbox::front()
 }
 
 void Mailbox::setReceiver(ActorPtr actor) {
-  simcall_mbox_set_receiver(pimpl_, actor == nullptr ? nullptr : actor->pimpl_);
+  simix::kernelImmediate([this, actor]() {
+    this->pimpl_->setReceiver(actor);
+  });
 }
 
 /** @brief get the receiver (process associated to the mailbox) */
index 9936448..7a19d18 100644 (file)
@@ -8,34 +8,19 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_mailbox, simix, "Mailbox implementation");
 
-static void SIMIX_mbox_free(void* data);
-static xbt_dict_t mailboxes = xbt_dict_new_homogeneous(SIMIX_mbox_free);
+static xbt_dict_t mailboxes = xbt_dict_new_homogeneous([](void* data) {
+  delete static_cast<smx_mailbox_t>(data);
+});
 
 void SIMIX_mailbox_exit()
 {
   xbt_dict_free(&mailboxes);
 }
-void SIMIX_mbox_free(void* data)
-{
-  XBT_DEBUG("mbox free %p", data);
-  smx_mailbox_t mbox = static_cast<smx_mailbox_t>(data);
-  delete mbox;
-}
 
 /******************************************************************************/
 /*                           Rendez-Vous Points                               */
 /******************************************************************************/
 
-/**
- *  \brief set the receiver of the rendez vous point to allow eager sends
- *  \param mbox The rendez-vous point
- *  \param process The receiving process
- */
-void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t process)
-{
-  mbox->permanent_receiver = process;
-}
-
 namespace simgrid {
 namespace simix {
 /** @brief Returns the mailbox of that name, or nullptr */
@@ -56,6 +41,13 @@ MailboxImpl* MailboxImpl::byNameOrCreate(const char* name)
   }
   return mbox;
 }
+/** @brief set the receiver of the mailbox to allow eager sends
+ *  \param actor The receiving dude
+ */
+void MailboxImpl::setReceiver(s4u::ActorPtr actor)
+{
+  this->permanent_receiver = actor.get()->getImpl();
+}
 /** @brief Pushes a communication activity into a mailbox
  *  @param activity What to add
  */
index bd9c49b..4fb573f 100644 (file)
@@ -28,6 +28,7 @@ public:
 
   static MailboxImpl* byNameOrNull(const char* name);
   static MailboxImpl* byNameOrCreate(const char* name);
+  void setReceiver(s4u::ActorPtr actor);
   void push(smx_activity_t synchro);
   void remove(smx_activity_t activity);
   simgrid::s4u::Mailbox piface_; // Our interface
@@ -42,6 +43,4 @@ public:
 
 XBT_PRIVATE void SIMIX_mailbox_exit();
 
-XBT_PRIVATE void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t proc);
-
 #endif /* SIMIX_MAILBOXIMPL_H */
index a580e9a..bbc509c 100644 (file)
@@ -367,11 +367,6 @@ e_smx_state_t simcall_process_sleep(double duration)
   return (e_smx_state_t) simcall_BODY_process_sleep(duration);
 }
 
-void simcall_mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t process)
-{
-  simcall_BODY_mbox_set_receiver(mbox, process);
-}
-
 /**
  * \ingroup simix_comm_management
  */
index 5070dfd..fadfc1b 100644 (file)
@@ -284,19 +284,6 @@ static inline void simcall_process_restart__set__result(smx_simcall_t simcall, s
     simgrid::simix::marshal<smx_actor_t>(simcall->result, result);
 }
 
-static inline smx_mailbox_t simcall_mbox_set_receiver__get__mbox(smx_simcall_t simcall) {
-  return simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]);
-}
-static inline void simcall_mbox_set_receiver__set__mbox(smx_simcall_t simcall, smx_mailbox_t arg) {
-    simgrid::simix::marshal<smx_mailbox_t>(simcall->args[0], arg);
-}
-static inline smx_actor_t simcall_mbox_set_receiver__get__receiver(smx_simcall_t simcall) {
-  return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[1]);
-}
-static inline void simcall_mbox_set_receiver__set__receiver(smx_simcall_t simcall, smx_actor_t arg) {
-    simgrid::simix::marshal<smx_actor_t>(simcall->args[1], arg);
-}
-
 static inline smx_mailbox_t simcall_comm_iprobe__get__mbox(smx_simcall_t simcall) {
   return simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]);
 }
index 0bcb22d..ccdeaaf 100644 (file)
@@ -143,12 +143,6 @@ inline static smx_actor_t simcall_BODY_process_restart(smx_actor_t process) {
     return simcall<smx_actor_t, smx_actor_t>(SIMCALL_PROCESS_RESTART, process);
   }
   
-inline static void simcall_BODY_mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t receiver) {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) SIMIX_mbox_set_receiver(mbox, receiver);
-    return simcall<void, smx_mailbox_t, smx_actor_t>(SIMCALL_MBOX_SET_RECEIVER, mbox, receiver);
-  }
-  
 inline static smx_activity_t simcall_BODY_comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag, simix_match_func_t match_fun, void* data) {
     /* Go to that function to follow the code flow through the simcall barrier */
     if (0) simcall_HANDLER_comm_iprobe(&SIMIX_process_self()->simcall, mbox, type, src, tag, match_fun, data);
index 27a3f57..40a7405 100644 (file)
@@ -36,7 +36,6 @@ typedef enum {
   SIMCALL_PROCESS_ON_EXIT,
   SIMCALL_PROCESS_AUTO_RESTART_SET,
   SIMCALL_PROCESS_RESTART,
-  SIMCALL_MBOX_SET_RECEIVER,
   SIMCALL_COMM_IPROBE,
   SIMCALL_COMM_SEND,
   SIMCALL_COMM_ISEND,
index 689f2ef..9c7bb30 100644 (file)
@@ -42,7 +42,6 @@ const char* simcall_names[] = {
     "SIMCALL_PROCESS_ON_EXIT",
     "SIMCALL_PROCESS_AUTO_RESTART_SET",
     "SIMCALL_PROCESS_RESTART",
-    "SIMCALL_MBOX_SET_RECEIVER",
     "SIMCALL_COMM_IPROBE",
     "SIMCALL_COMM_SEND",
     "SIMCALL_COMM_ISEND",
@@ -184,11 +183,6 @@ case SIMCALL_PROCESS_RESTART:
       SIMIX_simcall_answer(simcall);
       break;
 
-case SIMCALL_MBOX_SET_RECEIVER:
-      SIMIX_mbox_set_receiver(simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]), simgrid::simix::unmarshal<smx_actor_t>(simcall->args[1]));
-      SIMIX_simcall_answer(simcall);
-      break;
-
 case SIMCALL_COMM_IPROBE:
       simgrid::simix::marshal<smx_activity_t>(simcall->result, simcall_HANDLER_comm_iprobe(simcall, simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[0]), simgrid::simix::unmarshal<int>(simcall->args[1]), simgrid::simix::unmarshal<int>(simcall->args[2]), simgrid::simix::unmarshal<int>(simcall->args[3]), simgrid::simix::unmarshal<simix_match_func_t>(simcall->args[4]), simgrid::simix::unmarshal<void*>(simcall->args[5])));
       SIMIX_simcall_answer(simcall);
index 77ce2e8..8a565e7 100644 (file)
@@ -57,8 +57,6 @@ void          process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void
 void          process_auto_restart_set(smx_actor_t process, int auto_restart) [[nohandler]];
 smx_actor_t process_restart(smx_actor_t process);
 
-void          mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t receiver) [[nohandler]];
-
 smx_activity_t comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag, simix_match_func_t match_fun, void* data);
 void          comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout) [[block]];
 smx_activity_t comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, int detached);
index a36fe01..b7b181c 100644 (file)
@@ -145,7 +145,7 @@ void smpi_process_init(int *argc, char ***argv)
     data->argc = argc;
     data->argv = argv;
     // set the process attached to the mailbox
-    simcall_mbox_set_receiver(data->mailbox_small->getImpl(), proc);
+    data->mailbox_small->setReceiver(simgrid::s4u::Actor::self());
     XBT_DEBUG("<%d> New process in the game: %p", index, proc);
   }
   xbt_assert(smpi_process_data(),