Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Save a cast per action completion
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 2 Apr 2019 18:47:14 +0000 (20:47 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 2 Apr 2019 18:47:14 +0000 (20:47 +0200)
Action::get_data() and Action::set_data() remain because of SimDag ...

include/simgrid/kernel/resource/Action.hpp
src/kernel/activity/CommImpl.cpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/IoImpl.cpp
src/kernel/activity/SleepImpl.cpp
src/kernel/activity/SynchroRaw.cpp
src/simix/smx_global.cpp

index ca85918..92ca580 100644 (file)
@@ -130,6 +130,11 @@ public:
   /** @brief Set the user data associated to the current action */
   void set_data(void* data) { data_ = data; }
 
+  /** @brief Get the user data associated to the current action */
+  activity::ActivityImpl* get_activity() const { return activity_; }
+  /** @brief Set the user data associated to the current action */
+  void set_activity(activity::ActivityImpl* activity) { activity_ = activity; }
+
   /** @brief Get the cost of the current action */
   double get_cost() const { return cost_; }
   /** @brief Set the cost of the current action */
@@ -209,7 +214,8 @@ private:
 
   double cost_;
   simgrid::kernel::resource::Model* model_;
-  void* data_ = nullptr; /**< for your convenience */
+  void* data_                       = nullptr; /**< for your convenience */
+  activity::ActivityImpl* activity_ = nullptr;
 
   /* LMM */
   double last_update_                                = 0;
index 5f19980..5852dad 100644 (file)
@@ -218,7 +218,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, simgrid::kernel::activity:
     comm->finish();
   } else { /* we need a sleep action (even when there is no timeout) to be notified of host failures */
     simgrid::kernel::resource::Action* sleep = simcall->issuer->get_host()->pimpl_cpu->sleep(timeout);
-    sleep->set_data(comm);
+    sleep->set_activity(comm);
 
     if (simcall->issuer == comm->src_actor_)
       comm->src_timeout_ = sleep;
@@ -422,7 +422,7 @@ CommImpl* CommImpl::start()
     s4u::Host* receiver = dst_actor_->get_host();
 
     surf_action_ = surf_network_model->communicate(sender, receiver, size_, rate_);
-    surf_action_->set_data(this);
+    surf_action_->set_activity(this);
     surf_action_->set_category(get_tracing_category());
     state_ = SIMIX_RUNNING;
 
index c1b58d5..0e4d8ed 100644 (file)
@@ -76,7 +76,7 @@ ExecImpl& ExecImpl::set_timeout(double timeout)
 {
   if (timeout > 0 && not MC_is_active() && not MC_record_replay_is_active()) {
     timeout_detector_ = hosts_.front()->pimpl_cpu->sleep(timeout);
-    timeout_detector_->set_data(this);
+    timeout_detector_->set_activity(this);
   }
   return *this;
 }
@@ -116,7 +116,7 @@ ExecImpl* ExecImpl::start()
     } else {
       surf_action_ = surf_host_model->execute_parallel(hosts_, flops_amounts_.data(), bytes_amounts_.data(), -1);
     }
-    surf_action_->set_data(this);
+    surf_action_->set_activity(this);
   }
 
   XBT_DEBUG("Create execute synchro %p: %s", this, get_cname());
@@ -231,13 +231,13 @@ ActivityImpl* ExecImpl::migrate(s4u::Host* to)
     resource::Action* old_action = this->surf_action_;
     resource::Action* new_action = to->pimpl_cpu->execution_start(old_action->get_cost());
     new_action->set_remains(old_action->get_remains());
-    new_action->set_data(this);
+    new_action->set_activity(this);
     new_action->set_priority(old_action->get_priority());
 
     // FIXME: the user-defined bound seem to not be kept by LMM, that seem to overwrite it for the multi-core modeling.
     // I hope that the user did not provide any.
 
-    old_action->set_data(nullptr);
+    old_action->set_activity(nullptr);
     old_action->cancel();
     old_action->unref();
     this->surf_action_ = new_action;
index 8684066..7c23fbb 100644 (file)
@@ -59,7 +59,7 @@ IoImpl* IoImpl::start()
 {
   state_       = SIMIX_RUNNING;
   surf_action_ = storage_->io_start(size_, type_);
-  surf_action_->set_data(this);
+  surf_action_->set_activity(this);
 
   XBT_DEBUG("Create IO synchro %p %s", this, get_cname());
   IoImpl::on_start(*this);
index 16e321d..d236948 100644 (file)
@@ -33,7 +33,7 @@ SleepImpl& SleepImpl::set_duration(double duration)
 SleepImpl* SleepImpl::start()
 {
   surf_action_ = host_->pimpl_cpu->sleep(duration_);
-  surf_action_->set_data(this);
+  surf_action_->set_activity(this);
   XBT_DEBUG("Create sleep synchronization %p", this);
   return this;
 }
index 3b56ef8..de052c1 100644 (file)
@@ -34,7 +34,7 @@ RawImpl& RawImpl::set_timeout(double timeout)
 RawImpl* RawImpl::start()
 {
   surf_action_ = host_->pimpl_cpu->sleep(timeout_);
-  surf_action_->set_data(this);
+  surf_action_->set_activity(this);
   return this;
 }
 
index b463c5a..bcca356 100644 (file)
@@ -313,15 +313,15 @@ static void SIMIX_wake_processes()
     XBT_DEBUG("Handling the processes whose action failed (if any)");
     while ((action = model->extract_failed_action())) {
       XBT_DEBUG("   Handling Action %p",action);
-      SIMIX_simcall_exit(static_cast<simgrid::kernel::activity::ActivityImpl*>(action->get_data()));
+      SIMIX_simcall_exit(action->get_activity());
     }
     XBT_DEBUG("Handling the processes whose action terminated normally (if any)");
     while ((action = model->extract_done_action())) {
       XBT_DEBUG("   Handling Action %p",action);
-      if (action->get_data() == nullptr)
+      if (action->get_activity() == nullptr)
         XBT_DEBUG("probably vcpu's action %p, skip", action);
       else
-        SIMIX_simcall_exit(static_cast<simgrid::kernel::activity::ActivityImpl*>(action->get_data()));
+        SIMIX_simcall_exit(action->get_activity());
     }
   }
 }