From: Frederic Suter Date: Wed, 6 Jun 2018 08:20:15 +0000 (+0200) Subject: factor attachment of state traces to resources X-Git-Tag: v3.20~148 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/cc12fd6403964b251d1e253b99bdedeb6086a242 factor attachment of state traces to resources It also opens the way to state traces for other resources, such as storage --- diff --git a/include/simgrid/kernel/resource/Resource.hpp b/include/simgrid/kernel/resource/Resource.hpp index 105e9d381c..3ae1096133 100644 --- a/include/simgrid/kernel/resource/Resource.hpp +++ b/include/simgrid/kernel/resource/Resource.hpp @@ -63,6 +63,8 @@ public: virtual void turn_on(); /** @brief Turn off the current Resource */ virtual void turn_off(); + /** @brief setup the trace file with states events (ON or OFF). Trace must contain boolean values. */ + virtual void set_state_trace(tmgr_trace_t trace); private: std::string name_; @@ -76,6 +78,9 @@ public: /* LMM */ private: kernel::lmm::Constraint* const constraint_ = nullptr; +public: + TraceEvent* state_event_ = nullptr; + protected: struct Metric { double peak; /**< The peak of the metric, ie its max value */ diff --git a/src/kernel/resource/Resource.cpp b/src/kernel/resource/Resource.cpp index 72899f059f..bcab6dbc16 100644 --- a/src/kernel/resource/Resource.cpp +++ b/src/kernel/resource/Resource.cpp @@ -6,6 +6,7 @@ #include "simgrid/kernel/resource/Resource.hpp" #include "src/kernel/lmm/maxmin.hpp" // Constraint #include "src/surf/surf_interface.hpp" +#include "src/surf/trace_mgr.hpp" namespace simgrid { namespace kernel { @@ -62,6 +63,13 @@ bool Resource::operator==(const Resource& other) const return name_ == other.name_; } +void Resource::set_state_trace(tmgr_trace_t trace) +{ + xbt_assert(state_event_ == nullptr, "Cannot set a second state trace to %s", get_cname()); + + state_event_ = future_evt_set->add_trace(trace, this); +} + kernel::lmm::Constraint* Resource::get_constraint() const { return constraint_; diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 98bb02c9c9..ace74b4b4e 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -134,12 +134,6 @@ int Cpu::get_core_count() return core_count_; } -void Cpu::set_state_trace(tmgr_trace_t trace) -{ - xbt_assert(state_event_ == nullptr, "Cannot set a second state trace to Host %s", host_->get_cname()); - - state_event_ = future_evt_set->add_trace(trace, this); -} void Cpu::set_speed_trace(tmgr_trace_t trace) { xbt_assert(speed_.event == nullptr, "Cannot set a second speed trace to Host %s", host_->get_cname()); diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 8eb5a34318..2d7fc3e64b 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -144,17 +144,12 @@ private: std::vector speed_per_pstate_; /*< List of supported CPU capacities (pstate related) */ public: - /** @brief Setup the trace file with states events (ON or OFF). - * Trace must contain boolean values (0 or 1). - */ - virtual void set_state_trace(tmgr_trace_t trace); /*< @brief Setup the trace file with availability events (peak speed changes due to external load). * Trace must contain relative values (ratio between 0 and 1) */ virtual void set_speed_trace(tmgr_trace_t trace); protected: - tmgr_trace_event_t state_event_ = nullptr; Metric speed_ = {1.0, 0, nullptr}; }; diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 4ca068a598..a01dfef276 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -190,16 +190,12 @@ void LinkImpl::on_bandwidth_change() s4u::Link::on_bandwidth_change(this->piface_); } -void LinkImpl::set_state_trace(tmgr_trace_t trace) -{ - xbt_assert(state_event_ == nullptr, "Cannot set a second state trace to Link %s", get_cname()); - state_event_ = future_evt_set->add_trace(trace, this); -} void LinkImpl::set_bandwidth_trace(tmgr_trace_t trace) { xbt_assert(bandwidth_.event == nullptr, "Cannot set a second bandwidth trace to Link %s", get_cname()); bandwidth_.event = future_evt_set->add_trace(trace, this); } + void LinkImpl::set_latency_trace(tmgr_trace_t trace) { xbt_assert(latency_.event == nullptr, "Cannot set a second latency trace to Link %s", get_cname()); diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index c69c2bfaa3..55e7511a13 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -147,8 +147,6 @@ public: void on_bandwidth_change(); - virtual void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). - Trace must contain boolean values. */ virtual void set_bandwidth_trace( tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to external load). Trace must contain percentages (value between 0 and 1). */ @@ -156,7 +154,6 @@ public: tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). Trace must contain absolute values */ - tmgr_trace_event_t state_event_ = nullptr; Metric latency_ = {1.0, 0, nullptr}; Metric bandwidth_ = {1.0, 0, nullptr};