From 3ae51afef71e5532eb01868d1dcf674e025c05d1 Mon Sep 17 00:00:00 2001 From: SUTER Frederic Date: Thu, 23 Dec 2021 15:37:35 +0100 Subject: [PATCH] Might be interesting to have start and finish time for Comm, Exec, and Io activities --- MANIFEST.in | 4 ++-- include/simgrid/s4u/Activity.hpp | 3 +++ include/simgrid/s4u/Exec.hpp | 2 -- src/kernel/EngineImpl.cpp | 5 +---- src/kernel/activity/ActivityImpl.hpp | 6 ++++++ src/kernel/activity/CommImpl.cpp | 1 + src/kernel/activity/ExecImpl.cpp | 2 -- src/kernel/activity/ExecImpl.hpp | 6 ------ src/kernel/activity/IoImpl.cpp | 1 + src/s4u/s4u_Activity.cpp | 9 +++++++++ src/s4u/s4u_Exec.cpp | 10 ---------- 11 files changed, 23 insertions(+), 26 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 70382b68d3..39c231346a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -207,8 +207,8 @@ include examples/cpp/dag-comm/s4u-dag-comm.tesh include examples/cpp/dag-failure/s4u-dag-failure.cpp include examples/cpp/dag-failure/s4u-dag-failure.tesh include examples/cpp/dag-from-dot/dag.dot -include examples/cpp/dag-from-dot/s4u_dag-frm-dot.cpp -include examples/cpp/dag-from-dot/s4u_dag-frm-dot.tesh +include examples/cpp/dag-from-dot/s4u_dag-from-dot.cpp +include examples/cpp/dag-from-dot/s4u_dag-from-dot.tesh include examples/cpp/dag-io/s4u-dag-io.cpp include examples/cpp/dag-io/s4u-dag-io.tesh include examples/cpp/dag-simple/s4u-dag-simple.cpp diff --git a/include/simgrid/s4u/Activity.hpp b/include/simgrid/s4u/Activity.hpp index 9875e12ffd..45caaae127 100644 --- a/include/simgrid/s4u/Activity.hpp +++ b/include/simgrid/s4u/Activity.hpp @@ -166,6 +166,9 @@ public: * It is forbidden to change the amount of work once the Activity is started */ Activity* set_remaining(double remains); + double get_start_time() const; + double get_finish_time() const; + /** Returns the internal implementation of this Activity */ kernel::activity::ActivityImpl* get_impl() const { return pimpl_.get(); } diff --git a/include/simgrid/s4u/Exec.hpp b/include/simgrid/s4u/Exec.hpp index 09af6ea48c..e030b5a9a1 100644 --- a/include/simgrid/s4u/Exec.hpp +++ b/include/simgrid/s4u/Exec.hpp @@ -85,8 +85,6 @@ public: Host* get_host() const; unsigned int get_host_number() const; - double get_start_time() const; - double get_finish_time() const; double get_cost() const; bool is_parallel() const { return parallel_; } bool is_assigned() const override; diff --git a/src/kernel/EngineImpl.cpp b/src/kernel/EngineImpl.cpp index b1904b4c4c..9017884f6c 100644 --- a/src/kernel/EngineImpl.cpp +++ b/src/kernel/EngineImpl.cpp @@ -433,10 +433,7 @@ void EngineImpl::wake_all_waiting_actors() const else { // If nobody told the interface that the activity is finished, that's because no actor waits on it (maestro // started it). SimDAG I see you! - // The finish time of an Exec has to be set before the emission of the on_completion signal by complete - auto* exec = dynamic_cast(action->get_activity()); - if (exec != nullptr) - exec->set_finish_time(action->get_finish_time()); + action->get_activity()->set_finish_time(action->get_finish_time()); if (action->get_activity()->get_actor() == maestro_) action->get_activity()->get_iface()->complete(s4u::Activity::State::FINISHED); diff --git a/src/kernel/activity/ActivityImpl.hpp b/src/kernel/activity/ActivityImpl.hpp index 5ba6e152aa..f136cc4ee2 100644 --- a/src/kernel/activity/ActivityImpl.hpp +++ b/src/kernel/activity/ActivityImpl.hpp @@ -35,6 +35,8 @@ public: resource::Action* surf_action_ = nullptr; actor::ActorImpl* actor_ = nullptr; s4u::Activity* piface_ = nullptr; + double start_time_ = -1.0; + double finish_time_ = -1.0; protected: void inline set_name(const std::string& name) @@ -54,6 +56,10 @@ public: void set_iface(s4u::Activity* iface) { piface_ = iface; } s4u::Activity* get_iface() { return piface_; } + double get_start_time() const { return start_time_; } + void set_finish_time(double finish_time) { finish_time_ = finish_time; } + double get_finish_time() const { return finish_time_; } + virtual bool test(); virtual void wait_for(actor::ActorImpl* issuer, double timeout); virtual ActivityImpl& set_timeout(double) { THROW_UNIMPLEMENTED; } diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 52b81a70cb..be78f3b225 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -310,6 +310,7 @@ CommImpl* CommImpl::start() surf_action_ = net_model->communicate(from_, to_, size_, rate_); surf_action_->set_activity(this); surf_action_->set_category(get_tracing_category()); + start_time_ = surf_action_->get_start_time(); state_ = State::RUNNING; on_start(*this); diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index d5a019c5d4..1edb6ad774 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -154,8 +154,6 @@ void ExecImpl::post() state_ = State::DONE; } - finish_time_ = surf_action_->get_finish_time(); - clean_action(); timeout_detector_.reset(); if (get_actor() != nullptr) { diff --git a/src/kernel/activity/ExecImpl.hpp b/src/kernel/activity/ExecImpl.hpp index c5780a2e3f..622940c7fa 100644 --- a/src/kernel/activity/ExecImpl.hpp +++ b/src/kernel/activity/ExecImpl.hpp @@ -20,8 +20,6 @@ class XBT_PUBLIC ExecImpl : public ActivityImpl_T { nullptr, [](resource::Action* a) { a->unref(); }}; double sharing_penalty_ = 1.0; double bound_ = 0.0; - double start_time_ = -1.0; - double finish_time_ = -1.0; std::vector hosts_; std::vector flops_amounts_; std::vector bytes_amounts_; @@ -37,10 +35,6 @@ public: void set_cb_id(unsigned int cb_id) { cb_id_ = cb_id; } - double get_start_time() const { return start_time_; } - void set_finish_time(double finish_time) { finish_time_ = finish_time; } - double get_finish_time() const { return finish_time_; } - ExecImpl& set_flops_amount(double flop_amount); ExecImpl& set_host(s4u::Host* host); s4u::Host* get_host() const { return hosts_.front(); } diff --git a/src/kernel/activity/IoImpl.cpp b/src/kernel/activity/IoImpl.cpp index 874ea95a11..2d27c1af10 100644 --- a/src/kernel/activity/IoImpl.cpp +++ b/src/kernel/activity/IoImpl.cpp @@ -79,6 +79,7 @@ IoImpl* IoImpl::start() disk_->get_host()->get_netpoint()->get_englobing_zone()->get_disk_model()->io_start(disk_, size_, type_); surf_action_->set_sharing_penalty(sharing_penalty_); surf_action_->set_activity(this); + start_time_ = surf_action_->get_start_time(); XBT_DEBUG("Create IO synchro %p %s", this, get_cname()); diff --git a/src/s4u/s4u_Activity.cpp b/src/s4u/s4u_Activity.cpp index 1ea5899a7c..8c22f5871e 100644 --- a/src/s4u/s4u_Activity.cpp +++ b/src/s4u/s4u_Activity.cpp @@ -10,6 +10,7 @@ #include #include +#include "src/kernel/activity/ActivityImpl.hpp" #include "src/kernel/actor/ActorImpl.hpp" #include "src/kernel/actor/SimcallObserver.hpp" @@ -116,6 +117,14 @@ double Activity::get_remaining() const else return pimpl_->get_remaining(); } +double Activity::get_start_time() const +{ + return pimpl_->get_start_time(); +} +double Activity::get_finish_time() const +{ + return pimpl_->get_finish_time(); +} Activity* Activity::set_remaining(double remains) { diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index 4efdc11290..c74229193b 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -159,16 +159,6 @@ unsigned int Exec::get_host_number() const return static_cast(pimpl_.get())->get_host_number(); } -double Exec::get_start_time() const -{ - return static_cast(pimpl_.get())->get_start_time(); -} - -double Exec::get_finish_time() const -{ - return static_cast(pimpl_.get())->get_finish_time(); -} - /** @brief Change the host on which this activity takes place. * * The activity cannot be terminated already (but it may be started). */ -- 2.20.1