Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try to speed up the refcounting madness by using std::move
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 3 Jul 2017 19:48:08 +0000 (21:48 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 4 Jul 2017 00:14:07 +0000 (02:14 +0200)
include/simgrid/s4u/Actor.hpp
include/simgrid/s4u/forward.hpp
include/simgrid/simix.h
src/s4u/s4u_actor.cpp
src/simix/ActorImpl.cpp
src/simix/smx_network.cpp

index 524f508..1168847 100644 (file)
@@ -153,17 +153,9 @@ public:
   Actor(Actor const&) = delete;
   Actor& operator=(Actor const&) = delete;
 
-  // ***** Reference count (delegated to pimpl_) *****
-  friend void intrusive_ptr_add_ref(Actor* actor)
-  {
-    xbt_assert(actor != nullptr);
-    SIMIX_process_ref(actor->pimpl_);
-  }
-  friend void intrusive_ptr_release(Actor* actor)
-  {
-    xbt_assert(actor != nullptr);
-    SIMIX_process_unref(actor->pimpl_);
-  }
+  // ***** Reference count *****
+  friend void intrusive_ptr_add_ref(Actor * actor);
+  friend void intrusive_ptr_release(Actor * actor);
 
   // ***** Actor creation *****
   /** Retrieve a reference to myself */
index 237a5eb..ec485ba 100644 (file)
@@ -13,6 +13,8 @@ namespace simgrid {
 namespace s4u {
 
 class Actor;
+XBT_PUBLIC(void) intrusive_ptr_release(Actor* actor);
+XBT_PUBLIC(void) intrusive_ptr_add_ref(Actor* actor);
 using ActorPtr = boost::intrusive_ptr<Actor>;
 
 class Activity;
index f134c43..152fccc 100644 (file)
@@ -189,8 +189,6 @@ XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data);
 XBT_PUBLIC(void*) SIMIX_host_self_get_data();
 
 /********************************* Process ************************************/
-XBT_PUBLIC(smx_actor_t) SIMIX_process_ref(smx_actor_t process);
-XBT_PUBLIC(void) SIMIX_process_unref(smx_actor_t process);
 XBT_PUBLIC(int) SIMIX_process_count();
 XBT_PUBLIC(smx_actor_t) SIMIX_process_self();
 XBT_PUBLIC(const char*) SIMIX_process_self_get_name();
index eb588ca..3b27ed8 100644 (file)
@@ -44,6 +44,17 @@ ActorPtr Actor::createActor(const char* name, s4u::Host* host, const char* funct
   return actor->iface();
 }
 
+void intrusive_ptr_add_ref(Actor* actor)
+{
+  xbt_assert(actor != nullptr);
+  intrusive_ptr_add_ref(actor->pimpl_);
+}
+void intrusive_ptr_release(Actor* actor)
+{
+  xbt_assert(actor != nullptr);
+  intrusive_ptr_release(actor->pimpl_);
+}
+
 // ***** Actor methods *****
 
 void Actor::join() {
index d4b3934..d0f4ae7 100644 (file)
@@ -38,21 +38,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix, "Logging specific to SIMIX
 
 unsigned long simix_process_maxpid = 0;
 
-/** Increase the refcount for this process */
-smx_actor_t SIMIX_process_ref(smx_actor_t process)
-{
-  if (process != nullptr)
-    intrusive_ptr_add_ref(process);
-  return process;
-}
-
-/** Decrease the refcount for this process */
-void SIMIX_process_unref(smx_actor_t process)
-{
-  if (process != nullptr)
-    intrusive_ptr_release(process);
-}
-
 /**
  * \brief Returns the current agent.
  *
index 07f4c3c..d4a4781 100644 (file)
@@ -41,9 +41,8 @@ _find_matching_comm(boost::circular_buffer_space_optimized<smx_activity_t>* dequ
   void* other_user_data = nullptr;
 
   for(auto it = deque->begin(); it != deque->end(); it++){
-    smx_activity_t synchro = *it;
     simgrid::kernel::activity::CommImplPtr comm =
-        boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(std::move(synchro));
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(std::move(*it));
 
     if (comm->type == SIMIX_COMM_SEND) {
       other_user_data = comm->src_data;
@@ -59,7 +58,7 @@ _find_matching_comm(boost::circular_buffer_space_optimized<smx_activity_t>* dequ
       comm->mbox_cpy = comm->mbox;
 #endif
       comm->mbox = nullptr;
-      return comm;
+      return std::move(comm);
     }
     XBT_DEBUG("Sorry, communication synchro %p does not match our needs:"
               " its type is %d but we are looking for a comm of type %d (or maybe the filtering didn't match)",
@@ -189,8 +188,8 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *
 
     XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication");
     //find a match in the list of already received comms
-    other_comm = _find_matching_comm(&mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro,
-                                     /*remove_matching*/ true);
+    other_comm = std::move(_find_matching_comm(&mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro,
+                                               /*remove_matching*/ true));
     //if not found, assume the receiver came first, register it to the mailbox in the classical way
     if (not other_comm) {
       XBT_DEBUG("We have messages in the permanent receive list, but not the one we are looking for, pushing request into list");