Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
factor attachment of state traces to resources
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 6 Jun 2018 08:20:15 +0000 (10:20 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 6 Jun 2018 08:20:15 +0000 (10:20 +0200)
It also opens the way to state traces for other resources, such as
storage

include/simgrid/kernel/resource/Resource.hpp
src/kernel/resource/Resource.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp

index 105e9d3..3ae1096 100644 (file)
@@ -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 */
index 72899f0..bcab6db 100644 (file)
@@ -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_;
index 98bb02c..ace74b4 100644 (file)
@@ -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());
index 8eb5a34..2d7fc3e 100644 (file)
@@ -144,17 +144,12 @@ private:
   std::vector<double> 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};
 };
 
index 4ca068a..a01dfef 100644 (file)
@@ -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());
index c69c2bf..55e7511 100644 (file)
@@ -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};