Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make similarities between CommImpl and ExecImpl more explicit
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 7 Dec 2017 23:00:47 +0000 (00:00 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 8 Dec 2017 22:17:36 +0000 (23:17 +0100)
src/kernel/activity/CommImpl.cpp
src/kernel/activity/CommImpl.hpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/simix/ActorImpl.cpp
src/simix/libsmx.cpp
src/simix/smx_host.cpp
src/simix/smx_network.cpp

index c5b8e12..c4f8b52 100644 (file)
@@ -41,16 +41,16 @@ simgrid::kernel::activity::CommImpl::~CommImpl()
 void simgrid::kernel::activity::CommImpl::suspend()
 {
   /* FIXME: shall we suspend also the timeout synchro? */
-  if (surf_comm)
-    surf_comm->suspend();
+  if (surfAction_)
+    surfAction_->suspend();
   /* in the other case, the action will be suspended on creation, in SIMIX_comm_start() */
 }
 
 void simgrid::kernel::activity::CommImpl::resume()
 {
   /*FIXME: check what happen with the timeouts */
-  if (surf_comm)
-    surf_comm->resume();
+  if (surfAction_)
+    surfAction_->resume();
   /* in the other case, the synchro were not really suspended yet, see SIMIX_comm_suspend() and SIMIX_comm_start() */
 }
 
@@ -64,22 +64,22 @@ void simgrid::kernel::activity::CommImpl::cancel()
   } else if (not MC_is_active() /* when running the MC there are no surf actions */
              && not MC_record_replay_is_active() && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
 
-    surf_comm->cancel();
+    surfAction_->cancel();
   }
 }
 
 /**  @brief get the amount remaining from the communication */
 double simgrid::kernel::activity::CommImpl::remains()
 {
-  return surf_comm->getRemains();
+  return surfAction_->getRemains();
 }
 
 /** @brief This is part of the cleanup process, probably an internal command */
 void simgrid::kernel::activity::CommImpl::cleanupSurf()
 {
-  if (surf_comm) {
-    surf_comm->unref();
-    surf_comm = nullptr;
+  if (surfAction_) {
+    surfAction_->unref();
+    surfAction_ = nullptr;
   }
 
   if (src_timeout) {
@@ -104,7 +104,7 @@ void simgrid::kernel::activity::CommImpl::post()
     state = SIMIX_SRC_HOST_FAILURE;
   else if (dst_timeout && dst_timeout->getState() == simgrid::surf::Action::State::failed)
     state = SIMIX_DST_HOST_FAILURE;
-  else if (surf_comm && surf_comm->getState() == simgrid::surf::Action::State::failed) {
+  else if (surfAction_ && surfAction_->getState() == simgrid::surf::Action::State::failed) {
     state = SIMIX_LINK_FAILURE;
   } else
     state = SIMIX_DONE;
index 8480bb9..842d407 100644 (file)
@@ -46,7 +46,7 @@ expectations of the other side, too. See  */
   void (*copy_data_fun)(smx_activity_t, void*, size_t) = nullptr;
 
   /* Surf action data */
-  surf_action_t surf_comm   = nullptr; /* The Surf communication action encapsulated */
+  surf_action_t surfAction_ = nullptr; /* The Surf communication action encapsulated */
   surf_action_t src_timeout = nullptr; /* Surf's actions to instrument the timeouts */
   surf_action_t dst_timeout = nullptr; /* Surf's actions to instrument the timeouts */
   smx_actor_t src_proc      = nullptr;
index fb8d2ba..afb1832 100644 (file)
@@ -21,29 +21,29 @@ simgrid::kernel::activity::ExecImpl::ExecImpl(const char* name, sg_host_t host)
 
 simgrid::kernel::activity::ExecImpl::~ExecImpl()
 {
-  if (surf_exec)
-    surf_exec->unref();
+  if (surfAction_)
+    surfAction_->unref();
   if (timeoutDetector)
     timeoutDetector->unref();
   XBT_DEBUG("Destroy exec %p", this);
 }
 void simgrid::kernel::activity::ExecImpl::suspend()
 {
-  XBT_VERB("This exec is suspended (remain: %f)", surf_exec->getRemains());
-  if (surf_exec)
-    surf_exec->suspend();
+  XBT_VERB("This exec is suspended (remain: %f)", surfAction_->getRemains());
+  if (surfAction_)
+    surfAction_->suspend();
 }
 
 void simgrid::kernel::activity::ExecImpl::resume()
 {
-  XBT_VERB("This exec is resumed (remain: %f)", surf_exec->getRemains());
-  if (surf_exec)
-    surf_exec->resume();
+  XBT_VERB("This exec is resumed (remain: %f)", surfAction_->getRemains());
+  if (surfAction_)
+    surfAction_->resume();
 }
 
 double simgrid::kernel::activity::ExecImpl::remains()
 {
-  return surf_exec->getRemains();
+  return surfAction_->getRemains();
 }
 
 void simgrid::kernel::activity::ExecImpl::post()
@@ -52,7 +52,7 @@ void simgrid::kernel::activity::ExecImpl::post()
                                  /* If the host running the synchro failed, notice it. This way, the asking
                                   * process can be killed if it runs on that host itself */
     state = SIMIX_FAILED;
-  } else if (surf_exec->getState() == simgrid::surf::Action::State::failed) {
+  } else if (surfAction_->getState() == simgrid::surf::Action::State::failed) {
     /* If the host running the synchro didn't fail, then the synchro was canceled */
     state = SIMIX_CANCELED;
   } else if (timeoutDetector && timeoutDetector->getState() == simgrid::surf::Action::State::done) {
@@ -61,9 +61,9 @@ void simgrid::kernel::activity::ExecImpl::post()
     state = SIMIX_DONE;
   }
 
-  if (surf_exec) {
-    surf_exec->unref();
-    surf_exec = nullptr;
+  if (surfAction_) {
+    surfAction_->unref();
+    surfAction_ = nullptr;
   }
   if (timeoutDetector) {
     timeoutDetector->unref();
index 4ef5bf7..63e3dcb 100644 (file)
@@ -24,10 +24,10 @@ public:
   void post() override;
   double remains();
 
-  sg_host_t host_ =
-      nullptr; /* The host where the execution takes place. If nullptr, then this is a parallel exec (and only surf
+  /* The host where the execution takes place. If nullptr, then this is a parallel exec (and only surf
                   knows the hosts) */
-  surf_action_t surf_exec       = nullptr; /* The Surf execution action encapsulated */
+  sg_host_t host_               = nullptr;
+  surf_action_t surfAction_     = nullptr; /* The Surf execution action encapsulated */
   surf::Action* timeoutDetector = nullptr;
 };
 }
index 4e82f6b..fdcb034 100644 (file)
@@ -500,10 +500,10 @@ void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) {
         boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(process->waiting_synchro);
 
     if (exec != nullptr) {
-      if (exec->surf_exec) {
-        exec->surf_exec->cancel();
-        exec->surf_exec->unref();
-        exec->surf_exec = nullptr;
+      if (exec->surfAction_) {
+        exec->surfAction_->cancel();
+        exec->surfAction_->unref();
+        exec->surfAction_ = nullptr;
       }
     } else if (comm != nullptr) {
       process->comms.remove(process->waiting_synchro);
@@ -552,8 +552,8 @@ void SIMIX_process_throw(smx_actor_t process, xbt_errcat_t cat, int value, const
 
     simgrid::kernel::activity::ExecImplPtr exec =
         boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(process->waiting_synchro);
-    if (exec != nullptr && exec->surf_exec)
-      exec->surf_exec->cancel();
+    if (exec != nullptr && exec->surfAction_)
+      exec->surfAction_->cancel();
 
     simgrid::kernel::activity::CommImplPtr comm =
         boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(process->waiting_synchro);
index d774d3c..9281dca 100644 (file)
@@ -112,12 +112,12 @@ void simcall_execution_cancel(smx_activity_t execution)
 {
   simgrid::kernel::activity::ExecImplPtr exec =
       boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(execution);
-  if (not exec->surf_exec)
+  if (not exec->surfAction_)
     return;
   simgrid::simix::kernelImmediate([exec] {
     XBT_DEBUG("Cancel synchro %p", exec.get());
-    if (exec->surf_exec)
-      exec->surf_exec->cancel();
+    if (exec->surfAction_)
+      exec->surfAction_->cancel();
   });
 }
 
@@ -137,8 +137,8 @@ void simcall_execution_set_priority(smx_activity_t execution, double priority)
 
     simgrid::kernel::activity::ExecImplPtr exec =
         boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(execution);
-    if (exec->surf_exec)
-      exec->surf_exec->setSharingWeight(priority);
+    if (exec->surfAction_)
+      exec->surfAction_->setSharingWeight(priority);
   });
 }
 
@@ -155,8 +155,8 @@ void simcall_execution_set_bound(smx_activity_t execution, double bound)
   simgrid::simix::kernelImmediate([execution, bound] {
     simgrid::kernel::activity::ExecImplPtr exec =
         boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(execution);
-    if (exec->surf_exec)
-      static_cast<simgrid::surf::CpuAction*>(exec->surf_exec)->setBound(bound);
+    if (exec->surfAction_)
+      exec->surfAction_->setBound(bound);
   });
 }
 
index 60f61ca..3808ea6 100644 (file)
@@ -164,12 +164,12 @@ SIMIX_execution_start(smx_actor_t issuer, const char* name, double flops_amount,
   /* set surf's action */
   if (not MC_is_active() && not MC_record_replay_is_active()) {
 
-    exec->surf_exec = issuer->host->pimpl_cpu->execution_start(flops_amount);
-    exec->surf_exec->setData(exec.get());
-    exec->surf_exec->setSharingWeight(priority);
+    exec->surfAction_ = issuer->host->pimpl_cpu->execution_start(flops_amount);
+    exec->surfAction_->setData(exec.get());
+    exec->surfAction_->setSharingWeight(priority);
 
     if (bound > 0)
-      static_cast<simgrid::surf::CpuAction*>(exec->surf_exec)->setBound(bound);
+      static_cast<simgrid::surf::CpuAction*>(exec->surfAction_)->setBound(bound);
   }
 
   XBT_DEBUG("Create execute synchro %p: %s", exec.get(), exec->name.c_str());
@@ -198,8 +198,8 @@ SIMIX_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_li
     /* set surf's synchro */
     sg_host_t* host_list_cpy = new sg_host_t[host_nb];
     std::copy_n(host_list, host_nb, host_list_cpy);
-    exec->surf_exec = surf_host_model->executeParallelTask(host_nb, host_list_cpy, flops_amount, bytes_amount, rate);
-    exec->surf_exec->setData(exec.get());
+    exec->surfAction_ = surf_host_model->executeParallelTask(host_nb, host_list_cpy, flops_amount, bytes_amount, rate);
+    exec->surfAction_->setData(exec.get());
     if (timeout > 0) {
       exec->timeoutDetector = host_list[0]->pimpl_cpu->sleep(timeout);
       exec->timeoutDetector->setData(exec.get());
@@ -280,13 +280,13 @@ void SIMIX_set_category(smx_activity_t synchro, const char *category)
   simgrid::kernel::activity::ExecImplPtr exec =
       boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro);
   if (exec != nullptr) {
-    exec->surf_exec->setCategory(category);
+    exec->surfAction_->setCategory(category);
     return;
   }
 
   simgrid::kernel::activity::CommImplPtr comm =
       boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
   if (comm != nullptr) {
-    comm->surf_comm->setCategory(category);
+    comm->surfAction_->setCategory(category);
   }
 }
index 173e0af..b455657 100644 (file)
@@ -196,7 +196,7 @@ SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void* dst_buff, size_
       other_comm = std::move(this_synchro);
       mbox->push(other_comm);
     } else {
-      if (other_comm->surf_comm && other_comm->remains() < 1e-12) {
+      if (other_comm->surfAction_ && other_comm->remains() < 1e-12) {
         XBT_DEBUG("comm %p has been already sent, and is finished, destroy it", other_comm.get());
         other_comm->state = SIMIX_DONE;
         other_comm->type = SIMIX_COMM_DONE;
@@ -455,15 +455,15 @@ static inline void SIMIX_comm_start(simgrid::kernel::activity::CommImplPtr comm)
     simgrid::s4u::Host* sender   = comm->src_proc->host;
     simgrid::s4u::Host* receiver = comm->dst_proc->host;
 
-    comm->surf_comm = surf_network_model->communicate(sender, receiver, comm->task_size, comm->rate);
-    comm->surf_comm->setData(comm.get());
+    comm->surfAction_ = surf_network_model->communicate(sender, receiver, comm->task_size, comm->rate);
+    comm->surfAction_->setData(comm.get());
     comm->state = SIMIX_RUNNING;
 
     XBT_DEBUG("Starting communication %p from '%s' to '%s' (surf_action: %p)", comm.get(), sender->getCname(),
-              receiver->getCname(), comm->surf_comm);
+              receiver->getCname(), comm->surfAction_);
 
     /* If a link is failed, detect it immediately */
-    if (comm->surf_comm->getState() == simgrid::surf::Action::State::failed) {
+    if (comm->surfAction_->getState() == simgrid::surf::Action::State::failed) {
       XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure", sender->getCname(),
                 receiver->getCname());
       comm->state = SIMIX_LINK_FAILURE;
@@ -482,7 +482,7 @@ static inline void SIMIX_comm_start(simgrid::kernel::activity::CommImplPtr comm)
                   "communication",
                   comm->dst_proc->getCname(), comm->dst_proc->host->getCname());
 
-      comm->surf_comm->suspend();
+      comm->surfAction_->suspend();
     }
   }
 }