Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Clean surf cpu cas01
authorPaul Bédaride <paul.bedaride@gmail.com>
Thu, 13 Feb 2014 15:31:22 +0000 (16:31 +0100)
committerPaul Bédaride <paul.bedaride@gmail.com>
Mon, 17 Feb 2014 10:48:00 +0000 (11:48 +0100)
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/plugins/energy.cpp
src/surf/vm_workstation_hl13.cpp

index ab90f35..abc0385 100644 (file)
@@ -171,7 +171,7 @@ void CpuCas01Model::addTraces()
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
-    host->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
+    host->setStateEvent(tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host)));
   }
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
@@ -181,8 +181,7 @@ void CpuCas01Model::addTraces()
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
-    host->p_powerEvent =
-        tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
+    host->setPowerEvent(tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host)));
   }
 }
 
@@ -216,6 +215,25 @@ CpuCas01::~CpuCas01(){
     xbt_dynar_free(&p_powerPeakList);
 }
 
+void CpuCas01::setStateEvent(tmgr_trace_event_t stateEvent)
+{
+  p_stateEvent = stateEvent;
+}
+
+void CpuCas01::setPowerEvent(tmgr_trace_event_t powerEvent)
+{
+  p_powerEvent = powerEvent;
+}
+
+xbt_dynar_t CpuCas01::getPowerPeakList(){
+  return p_powerPeakList;
+}
+
+int CpuCas01::getPState()
+{
+  return m_pstate;
+}
+
 bool CpuCas01::isUsed()
 {
   return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
index 3f8ccb1..685cd4c 100644 (file)
@@ -44,18 +44,8 @@ public:
 /************
  * Resource *
  ************/
-/*
- * Energy-related properties for the cpu_cas01 model
- */
-typedef struct energy_cpu_cas01 {
-       xbt_dynar_t power_range_watts_list;             /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
-       double total_energy;                                    /*< Total energy consumed by the host */
-       double last_updated;                                    /*< Timestamp of the last energy update event*/
-} s_energy_cpu_cas01_t, *energy_cpu_cas01_t;
 
 class CpuCas01 : public Cpu {
-public://FIXME:
-  tmgr_trace_event_t p_stateEvent;
 public:
   CpuCas01(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak,
         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
@@ -70,9 +60,15 @@ public:
   double getPowerPeakAt(int pstate_index);
   int getNbPstates();
   void setPowerPeakAt(int pstate_index);
-
   bool isUsed();
+  void setStateEvent(tmgr_trace_event_t stateEvent);
+  void setPowerEvent(tmgr_trace_event_t stateEvent);
+  xbt_dynar_t getPowerPeakList();
 
+  int getPState();
+
+private:
+  tmgr_trace_event_t p_stateEvent;
   tmgr_trace_event_t p_powerEvent;
   xbt_dynar_t p_powerPeakList;                         /*< List of supported CPU capacities */
   int m_pstate;                                                                /*< Current pstate (index in the power_peak_list)*/
index 40a87b5..993ac0b 100644 (file)
@@ -112,7 +112,7 @@ double CpuEnergy::getCurrentWattsValue(double cpu_load)
                                                cpu->getName());*/
 
     /* retrieve the power values associated with the current pstate */
-    xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast<CpuCas01Ptr>(cpu)->m_pstate, xbt_dynar_t);
+    xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast<CpuCas01Ptr>(cpu)->getPState(), xbt_dynar_t);
 
     /* min_power corresponds to the idle power (cpu load = 0) */
     /* max_power is the power consumed at 100% cpu load       */
index 4bea656..054e349 100644 (file)
@@ -251,8 +251,8 @@ WorkstationVMHL13::WorkstationVMHL13(WorkstationVMModelPtr model, const char* na
    * Do xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu) if you get the resource. */
 
   p_cpu = static_cast<CpuCas01ModelPtr>(surf_cpu_model_vm)->createResource(name, // name
-      sub_cpu->p_powerPeakList,        // host->power_peak,
-      sub_cpu->m_pstate,
+      sub_cpu->getPowerPeakList(),        // host->power_peak,
+      sub_cpu->getPState(),
       1,                          // host->power_scale,
       NULL,                       // host->power_trace,
       1,                          // host->core_amount,