From: Frederic Suter Date: Tue, 2 Apr 2019 18:47:14 +0000 (+0200) Subject: Save a cast per action completion X-Git-Tag: v3.22.1~16 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0184f298bc4cc735d2cf2604e430d85d350d4b7c Save a cast per action completion Action::get_data() and Action::set_data() remain because of SimDag ... --- diff --git a/include/simgrid/kernel/resource/Action.hpp b/include/simgrid/kernel/resource/Action.hpp index ca8591819c..92ca580c08 100644 --- a/include/simgrid/kernel/resource/Action.hpp +++ b/include/simgrid/kernel/resource/Action.hpp @@ -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; diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 5f1998093f..5852dad6d7 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -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; diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index c1b58d5157..0e4d8ed443 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -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; diff --git a/src/kernel/activity/IoImpl.cpp b/src/kernel/activity/IoImpl.cpp index 8684066824..7c23fbb623 100644 --- a/src/kernel/activity/IoImpl.cpp +++ b/src/kernel/activity/IoImpl.cpp @@ -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); diff --git a/src/kernel/activity/SleepImpl.cpp b/src/kernel/activity/SleepImpl.cpp index 16e321daa6..d236948db8 100644 --- a/src/kernel/activity/SleepImpl.cpp +++ b/src/kernel/activity/SleepImpl.cpp @@ -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; } diff --git a/src/kernel/activity/SynchroRaw.cpp b/src/kernel/activity/SynchroRaw.cpp index 3b56ef8ff5..de052c10c9 100644 --- a/src/kernel/activity/SynchroRaw.cpp +++ b/src/kernel/activity/SynchroRaw.cpp @@ -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; } diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index b463c5a153..bcca356024 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -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(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(action->get_data())); + SIMIX_simcall_exit(action->get_activity()); } } }