Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make the energy plugin usable with ptask (but not DVFS) (fix #27)
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 25 Dec 2015 18:31:14 +0000 (19:31 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 25 Dec 2015 18:31:18 +0000 (19:31 +0100)
- Move the DVFS mechanism higher in the CPU hierarchy
- Remove all static_casts to CpuCas01 in energy plugin
- Make sure that ptaskL07 can execute sequential tasks

DVFS is still not working: the speedPeak changes have no impact on
ptask actions. I don't understand maxmin enough and need the help of
@alegrand, sorry.

13 files changed:
examples/msg/energy/consumption/energy_consumption.c
examples/msg/energy/consumption/energy_consumption.tesh
src/simix/smx_host.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.cpp
src/surf/host_ptask_L07.cpp
src/surf/host_ptask_L07.hpp
src/surf/plugins/energy.cpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.hpp

index 8f928ae..e058370 100644 (file)
@@ -41,8 +41,8 @@ int dvfs(int argc, char *argv[])
 
   // Run a task
   start = MSG_get_clock();
-  XBT_INFO("Run a task for 100E6 flops");
   task1 = MSG_task_create ("t1", 100E6, 0, NULL);
+  XBT_INFO("Run a task of %.0E flops",MSG_task_get_flops_amount(task1));
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
   XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW depending on load; Energy dissipated=%.0f J",
@@ -54,15 +54,15 @@ int dvfs(int argc, char *argv[])
   // ========= Change power peak =========
   int pstate=2;
   MSG_host_set_pstate(host, pstate);
-  XBT_INFO("========= Requesting pstate %d (speed should be of %.2f flop/s and is of %.2f flop/s)",
+  XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)",
                  pstate,
                  MSG_host_get_power_peak_at(host, pstate),
                  MSG_host_get_current_power_peak(host));
 
   // Run a second task
   start = MSG_get_clock();
-  XBT_INFO("Run a task for 100E6 flops");
   task1 = MSG_task_create ("t2", 100E6, 0, NULL);
+  XBT_INFO("Run a task of %.0E flops",MSG_task_get_flops_amount(task1));
   MSG_task_execute (task1);
   MSG_task_destroy(task1);
   XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
index 017188a..d7cc2ee 100644 (file)
@@ -8,10 +8,33 @@ $ $SG_TEST_EXENV energy/consumption/energy_consumption$EXEEXT ${srcdir:=.}/../pl
 > [  0.000000] (1:dvfs_test@MyHost1) Initial peak speed=1E+08 flop/s; Energy dissipated =0E+00 J
 > [  0.000000] (1:dvfs_test@MyHost1) Sleep for 10 seconds
 > [ 10.000000] (1:dvfs_test@MyHost1) Done sleeping (duration: 10.00 s). Current peak speed=1E+08; Energy dissipated=1000.00 J
-> [ 10.000000] (1:dvfs_test@MyHost1) Run a task for 100E6 flops
+> [ 10.000000] (1:dvfs_test@MyHost1) Run a task of 1E+08 flops
 > [ 11.000000] (1:dvfs_test@MyHost1) Task done (duration: 1.00 s). Current peak speed=1E+08 flop/s; Current consumption: from 100W to 200W depending on load; Energy dissipated=1200 J
-> [ 11.000000] (1:dvfs_test@MyHost1) ========= Requesting pstate 2 (speed should be of 20000000.00 flop/s and is of 20000000.00 flop/s)
-> [ 11.000000] (1:dvfs_test@MyHost1) Run a task for 100E6 flops
+> [ 11.000000] (1:dvfs_test@MyHost1) ========= Requesting pstate 2 (speed should be of 2E+07 flop/s and is of 2E+07 flop/s)
+> [ 11.000000] (1:dvfs_test@MyHost1) Run a task of 1E+08 flops
+> [ 16.000000] (1:dvfs_test@MyHost1) Task done (duration: 5.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=1950 J
+> [ 16.000000] (1:dvfs_test@MyHost1) Sleep for 4 seconds
+> [ 20.000000] (1:dvfs_test@MyHost1) Done sleeping (duration: 4.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=2310 J
+> [ 20.000000] (1:dvfs_test@MyHost1) Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated 2000 J so far.
+> [ 30.000000] (0:@) Total simulation time: 30.00
+> [ 30.000000] (0:@) Total energy of host MyHost1: 3210.000000 Joules
+> [ 30.000000] (0:@) Total energy of host MyHost2: 2100.000000 Joules
+> [ 30.000000] (0:@) Total energy of host MyHost3: 3000.000000 Joules
+> [ 30.000000] (1:dvfs_test@MyHost1) Done sleeping (duration: 10.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=3210 J
+
+p Test the same with the ptask model
+
+$ $SG_TEST_EXENV energy/consumption/energy_consumption$EXEEXT ${srcdir:=.}/../platforms/energy_platform.xml ${srcdir:=.}/energy/consumption/deployment_consumption.xml --cfg=host/model:ptask_L07 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:@) Configuration change: Set 'host/model' to 'ptask_L07'
+> [  0.000000] (0:@) Switching to the L07 model to handle parallel tasks.
+> [  0.000000] (1:dvfs_test@MyHost1) Energetic profile: 100.0:200.0, 93.0:170.0, 90.0:150.0
+> [  0.000000] (1:dvfs_test@MyHost1) Initial peak speed=1E+08 flop/s; Energy dissipated =0E+00 J
+> [  0.000000] (1:dvfs_test@MyHost1) Sleep for 10 seconds
+> [ 10.000000] (1:dvfs_test@MyHost1) Done sleeping (duration: 10.00 s). Current peak speed=1E+08; Energy dissipated=1000.00 J
+> [ 10.000000] (1:dvfs_test@MyHost1) Run a task of 1E+08 flops
+> [ 11.000000] (1:dvfs_test@MyHost1) Task done (duration: 1.00 s). Current peak speed=1E+08 flop/s; Current consumption: from 100W to 200W depending on load; Energy dissipated=1200 J
+> [ 11.000000] (1:dvfs_test@MyHost1) ========= Requesting pstate 2 (speed should be of 2E+07 flop/s and is of 2E+07 flop/s)
+> [ 11.000000] (1:dvfs_test@MyHost1) Run a task of 1E+08 flops
 > [ 16.000000] (1:dvfs_test@MyHost1) Task done (duration: 5.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=1950 J
 > [ 16.000000] (1:dvfs_test@MyHost1) Sleep for 4 seconds
 > [ 20.000000] (1:dvfs_test@MyHost1) Done sleeping (duration: 4.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=2310 J
index dce8607..92b2b5b 100644 (file)
@@ -324,7 +324,11 @@ smx_synchro_t SIMIX_process_execute(smx_process_t issuer, const char *name,
 
     /* Note (hypervisor): for multicore, the bound value being passed to the
      * surf layer should not be zero (i.e., unlimited). It should be the
-     * capacity of a CPU core. */
+     * capacity of a CPU core.
+     *
+     * FIXME: this should probably not be part of Simix but of Surf directly.
+     * That bound is part of the performance model, not of the synchronization
+     */
     if (bound == 0)
       surf_cpu_action_set_bound(synchro->execution.surf_exec, sg_host_get_speed(issuer->host));
     else
index c767a73..014f9da 100644 (file)
@@ -156,21 +156,12 @@ CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::Host *host, xbt_dynar_t speedP
                          int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
                          e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace)
 : Cpu(model, host,
-         lmm_constraint_new(model->getMaxminSystem(), this, core * speedScale * xbt_dynar_get_as(speedPeak, pstate, double)),
-         core, xbt_dynar_get_as(speedPeak, pstate, double), speedScale,
+       lmm_constraint_new(model->getMaxminSystem(), this, core * speedScale * xbt_dynar_get_as(speedPeak, pstate, double)),
+       speedPeak, pstate,
+       core, xbt_dynar_get_as(speedPeak, pstate, double), speedScale,
     stateInitial) {
   p_speedEvent = NULL;
 
-  // Copy the power peak array:
-  p_speedPeakList = xbt_dynar_new(sizeof(double), nullptr);
-  unsigned long n = xbt_dynar_length(speedPeak);
-  for (unsigned long i = 0; i != n; ++i) {
-    double value = xbt_dynar_get_as(speedPeak, i, double);
-    xbt_dynar_push(p_speedPeakList, &value);
-  }
-
-  m_pstate = pstate;
-
   XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_speedPeak, m_pstate);
 
   m_core = core;
@@ -201,11 +192,6 @@ xbt_dynar_t CpuCas01::getSpeedPeakList(){
   return p_speedPeakList;
 }
 
-int CpuCas01::getPState()
-{
-  return m_pstate;
-}
-
 bool CpuCas01::isUsed()
 {
   return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
@@ -322,34 +308,6 @@ double CpuCas01::getCurrentPowerPeak()
   return m_speedPeak;
 }
 
-double CpuCas01::getPowerPeakAt(int pstate_index)
-{
-  xbt_dynar_t plist = p_speedPeakList;
-  xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
-
-  return xbt_dynar_get_as(plist, pstate_index, double);
-}
-
-int CpuCas01::getNbPstates()
-{
-  return xbt_dynar_length(p_speedPeakList);
-}
-
-void CpuCas01::setPstate(int pstate_index)
-{
-  xbt_dynar_t plist = p_speedPeakList;
-  xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
-
-  double new_pstate = xbt_dynar_get_as(plist, pstate_index, double);
-  m_pstate = pstate_index;
-  m_speedPeak = new_pstate;
-}
-
-int CpuCas01::getPstate()
-{
-  return m_pstate;
-}
-
 /**********
  * Action *
  **********/
index 66dd3f7..294b8d7 100644 (file)
@@ -56,22 +56,14 @@ public:
   CpuAction *sleep(double duration);
 
   double getCurrentPowerPeak();
-  double getPowerPeakAt(int pstate_index);
-  int getNbPstates();
-  void setPstate(int pstate_index);
-  int  getPstate();
-  bool isUsed();
+  bool isUsed() override;
   void setStateEvent(tmgr_trace_event_t stateEvent);
   void setPowerEvent(tmgr_trace_event_t stateEvent);
   xbt_dynar_t getSpeedPeakList();
 
-  int getPState();
-
 private:
   tmgr_trace_event_t p_stateEvent;
   tmgr_trace_event_t p_speedEvent;
-  xbt_dynar_t p_speedPeakList;       /*< List of supported CPU capacities (pstate related) */
-  int m_pstate;                      /*< Current pstate (index in the speedPeakList)*/
 };
 
 /**********
index 0bb5ed6..a935630 100644 (file)
@@ -4,6 +4,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include <xbt/dynar.h>
 #include "cpu_interface.hpp"
 #include "plugins/energy.hpp"
 
@@ -144,7 +145,8 @@ Cpu::Cpu()
 
 
 Cpu::Cpu(Model *model, simgrid::Host *host,
-         int core, double speedPeak, double speedScale,
+            xbt_dynar_t speedPeakList, int pstate,
+                int core, double speedPeak, double speedScale,
          e_surf_resource_state_t stateInitial)
  : Resource(model, host->getName().c_str(), stateInitial)
  , m_core(core)
@@ -153,10 +155,21 @@ Cpu::Cpu(Model *model, simgrid::Host *host,
  , m_host(host)
 {
   host->extension_set(Cpu::EXTENSION_ID, this);
+
+  // Copy the power peak array:
+  p_speedPeakList = xbt_dynar_new(sizeof(double), nullptr);
+  unsigned long n = xbt_dynar_length(speedPeakList);
+  for (unsigned long i = 0; i != n; ++i) {
+    double value = xbt_dynar_get_as(speedPeakList, i, double);
+    xbt_dynar_push(p_speedPeakList, &value);
+  }
+
+  m_pstate = pstate;
 }
 
-Cpu::Cpu(Model *model, simgrid::Host *host,
-        lmm_constraint_t constraint, int core, double speedPeak,
+Cpu::Cpu(Model *model, simgrid::Host *host, lmm_constraint_t constraint,
+             xbt_dynar_t speedPeakList, int pstate,
+                 int core, double speedPeak,
         double speedScale, e_surf_resource_state_t stateInitial)
  : Resource(model, host->getName().c_str(), constraint, stateInitial)
  , m_core(core)
@@ -165,6 +178,17 @@ Cpu::Cpu(Model *model, simgrid::Host *host,
  , m_host(host)
 {
   host->extension_set(Cpu::EXTENSION_ID, this);
+
+  // Copy the power peak array:
+  p_speedPeakList = xbt_dynar_new(sizeof(double), nullptr);
+  unsigned long n = xbt_dynar_length(speedPeakList);
+  for (unsigned long i = 0; i != n; ++i) {
+    double value = xbt_dynar_get_as(speedPeakList, i, double);
+    xbt_dynar_push(p_speedPeakList, &value);
+  }
+
+  m_pstate = pstate;
+
   /* Currently, we assume that a VM does not have a multicore CPU. */
   if (core > 1)
     xbt_assert(model == surf_cpu_model_pm);
@@ -182,14 +206,18 @@ Cpu::Cpu(Model *model, simgrid::Host *host,
   }
 }
 
-Cpu::Cpu(Model *model, simgrid::Host *host,
-  lmm_constraint_t constraint, int core, double speedPeak, double speedScale)
-: Cpu(model, host, constraint, core, speedPeak, speedScale, SURF_RESOURCE_ON)
-{}
+Cpu::Cpu(Model *model, simgrid::Host *host, lmm_constraint_t constraint,
+  xbt_dynar_t speedPeakList, int pstate,
+  int core, double speedPeak, double speedScale)
+: Cpu(model, host, constraint, speedPeakList, pstate, core, speedPeak, speedScale, SURF_RESOURCE_ON)
+{
+       xbt_assert(0,"FIXME: this constructor could be removed");
+}
 
 Cpu::Cpu(Model *model, simgrid::Host *host,
+  xbt_dynar_t speedPeakList, int pstate,
   int core, double speedPeak, double speedScale)
-: Cpu(model, host, core, speedPeak, speedScale, SURF_RESOURCE_ON)
+: Cpu(model, host, speedPeakList, pstate, core, speedPeak, speedScale, SURF_RESOURCE_ON)
 {}
 
 Cpu::~Cpu()
@@ -209,6 +237,35 @@ double Cpu::getCurrentPowerPeak()
   return m_speedPeak;
 }
 
+int Cpu::getNbPStates()
+{
+  return xbt_dynar_length(p_speedPeakList);
+}
+
+void Cpu::setPState(int pstate_index)
+{
+  xbt_dynar_t plist = p_speedPeakList;
+  xbt_assert(pstate_index <= (int)xbt_dynar_length(plist),
+                 "Invalid parameters for CPU %s (pstate %d > length of pstates %d)", getName(), pstate_index, (int)xbt_dynar_length(plist));
+
+  double new_peak_speed = xbt_dynar_get_as(plist, pstate_index, double);
+  m_pstate = pstate_index;
+  m_speedPeak = new_peak_speed;
+}
+
+int Cpu::getPState()
+{
+  return m_pstate;
+}
+
+double Cpu::getPowerPeakAt(int pstate_index)
+{
+  xbt_dynar_t plist = p_speedPeakList;
+  xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
+
+  return xbt_dynar_get_as(plist, pstate_index, double);
+}
+
 double Cpu::getSpeed(double load)
 {
   return load * m_speedPeak;
index 4f1b156..a393754 100644 (file)
@@ -89,8 +89,9 @@ public:
    * @param speedScale The speed scale of this Cpu in [0;1] (available amount)
    * @param stateInitial whether it is created running or crashed
    */
-  Cpu(simgrid::surf::Model *model, simgrid::Host *host,
-         lmm_constraint_t constraint, int core, double speedPeak, double speedScale,
+  Cpu(simgrid::surf::Model *model, simgrid::Host *host, lmm_constraint_t constraint,
+         xbt_dynar_t speedPeakList, int pstate,
+         int core, double speedPeak, double speedScale,
          e_surf_resource_state_t stateInitial);
 
   /**
@@ -104,12 +105,15 @@ public:
    * @param stateInitial whether it is created running or crashed
    */
   Cpu(simgrid::surf::Model *model, simgrid::Host *host,
+      xbt_dynar_t speedPeakList, int pstate,
          int core, double speedPeak, double speedScale,
          e_surf_resource_state_t stateInitial);
 
+  Cpu(simgrid::surf::Model *model, simgrid::Host *host, lmm_constraint_t constraint,
+         xbt_dynar_t speedPeakList, int pstate,
+         int core, double speedPeak, double speedScale);
   Cpu(simgrid::surf::Model *model, simgrid::Host *host,
-         lmm_constraint_t constraint, int core, double speedPeak, double speedScale);
-  Cpu(simgrid::surf::Model *model, simgrid::Host *host,
+         xbt_dynar_t speedPeakList, int pstate,
          int core, double speedPeak, double speedScale);
 
   ~Cpu();
@@ -142,11 +146,11 @@ public:
   /** @brief Get the current Cpu power peak */
   virtual double getCurrentPowerPeak();
 
-  virtual double getPowerPeakAt(int pstate_index)=0;
+  virtual double getPowerPeakAt(int pstate_index);
 
-  virtual int getNbPstates()=0;
-  virtual void setPstate(int pstate_index)=0;
-  virtual int  getPstate()=0;
+  virtual int getNbPStates();
+  virtual void setPState(int pstate_index);
+  virtual int  getPState();
 
   void addTraces(void);
   simgrid::Host* getHost() { return m_host; }
@@ -157,6 +161,9 @@ public:
   double m_speedScale;           /*< Percentage of CPU available according to the trace, in [O,1] */
   simgrid::Host* m_host;
 
+  xbt_dynar_t p_speedPeakList = NULL; /*< List of supported CPU capacities (pstate related) */
+  int m_pstate = 0;                   /*< Current pstate (index in the speedPeakList)*/
+
   /* Note (hypervisor): */
   lmm_constraint_t *p_constraintCore=NULL;
   void **p_constraintCoreId=NULL;
index a72268a..6ea0152 100644 (file)
@@ -551,7 +551,7 @@ void CpuTiModel::addTraces()
 CpuTi::CpuTi(CpuTiModel *model, simgrid::Host *host, xbt_dynar_t speedPeak,
         int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace)
-  : Cpu(model, host, core, 0, speedScale, stateInitial)
+  : Cpu(model, host, NULL, pstate, core, 0, speedScale, stateInitial)
 {
   p_speedEvent = NULL;
   m_speedScale = speedScale;
index 700aa0c..dcf61d6 100644 (file)
@@ -53,9 +53,10 @@ namespace surf {
 HostL07Model::HostL07Model() : HostModel() {
   if (!ptask_maxmin_system)
        ptask_maxmin_system = lmm_system_new(1);
+  p_maxminSystem = ptask_maxmin_system;
   surf_host_model = NULL;
-  surf_network_model = new NetworkL07Model(this);
-  surf_cpu_model_pm = new CpuL07Model(this);
+  surf_network_model = new NetworkL07Model(this,ptask_maxmin_system);
+  surf_cpu_model_pm = new CpuL07Model(this,ptask_maxmin_system);
 
   routing_model_create(surf_network_model->createLink("__loopback__",
                                                          498000000, NULL,
@@ -71,12 +72,32 @@ HostL07Model::~HostL07Model() {
   delete surf_network_model;
   ptask_host_count = 0;
 
-  if (ptask_maxmin_system) {
-    lmm_system_free(ptask_maxmin_system);
-    ptask_maxmin_system = NULL;
-  }
+  ptask_maxmin_system = NULL; // freed as part of ~Model (it's also stored as p_maxminSystem)
+}
+
+CpuL07Model::CpuL07Model(HostL07Model *hmodel,lmm_system_t sys)
+       : CpuModel()
+       , p_hostModel(hmodel)
+       {
+         p_maxminSystem = sys;
+       }
+CpuL07Model::~CpuL07Model() {
+       surf_cpu_model_pm = NULL;
+       p_maxminSystem = NULL; // Avoid multi-free
+}
+NetworkL07Model::NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys)
+       : NetworkModel()
+       , p_hostModel(hmodel)
+       {
+         p_maxminSystem = sys;
+       }
+NetworkL07Model::~NetworkL07Model()
+{
+       surf_network_model = NULL;
+       p_maxminSystem = NULL; // Avoid multi-free
 }
 
+
 double HostL07Model::shareResources(double /*now*/)
 {
   L07Action *action;
@@ -180,7 +201,7 @@ Action *HostL07Model::executeParallelTask(int host_nb,
   L07Action *action = new L07Action(this, 1, 0);
   unsigned int cpt;
   int nb_link = 0;
-  int nb_host = 0;
+  int nb_used_host = 0; /* Only the hosts with something to compute (>0 flops) are counted) */
   double latency = 0.0;
 
   action->p_edgeList->reserve(host_nb);
@@ -220,7 +241,7 @@ Action *HostL07Model::executeParallelTask(int host_nb,
 
   for (int i = 0; i < host_nb; i++)
     if (flops_amount[i] > 0)
-      nb_host++;
+      nb_used_host++;
 
   XBT_DEBUG("Creating a parallel task (%p) with %d cpus and %d links.",
          action, host_nb, nb_link);
@@ -262,7 +283,7 @@ Action *HostL07Model::executeParallelTask(int host_nb,
     }
   }
 
-  if (nb_link + nb_host == 0) {
+  if (nb_link + nb_used_host == 0) {
     action->setCost(1.0);
     action->setRemains(0.0);
   }
@@ -289,14 +310,13 @@ Action *NetworkL07Model::communicate(RoutingEdge *src, RoutingEdge *dst,
   return res;
 }
 
-Cpu *CpuL07Model::createCpu(simgrid::Host *host,  xbt_dynar_t powerPeak,
+Cpu *CpuL07Model::createCpu(simgrid::Host *host,  xbt_dynar_t powerPeakList,
                           int pstate, double power_scale,
                           tmgr_trace_t power_trace, int core,
                           e_surf_resource_state_t state_initial,
                           tmgr_trace_t state_trace)
 {
-  double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
-  CpuL07 *cpu = new CpuL07(this, host, power_initial, power_scale, power_trace,
+  CpuL07 *cpu = new CpuL07(this, host, powerPeakList, pstate, power_scale, power_trace,
                          core, state_initial, state_trace);
   return cpu;
 }
@@ -387,13 +407,16 @@ void HostL07Model::addTraces()
 /************
  * Resource *
  ************/
+
 CpuL07::CpuL07(CpuL07Model *model, simgrid::Host *host,
-                    double speedInitial, double speedScale, tmgr_trace_t speedTrace,
-                          int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace)
- : Cpu(model, host, lmm_constraint_new(ptask_maxmin_system, this, speedInitial * speedScale),
-          core, speedInitial, speedScale, state_initial)
+                    xbt_dynar_t speedPeakList, int pstate,
+                                double speedScale, tmgr_trace_t speedTrace,
+                        int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace)
+ : Cpu(model, host, speedPeakList, pstate,
+          core, xbt_dynar_get_as(speedPeakList,pstate,double), speedScale, state_initial)
 {
   xbt_assert(m_speedScale > 0, "Power has to be >0");
+  p_constraint = lmm_constraint_new(ptask_maxmin_system, this, xbt_dynar_get_as(speedPeakList,pstate,double) * speedScale);
 
   if (speedTrace)
     p_speedEvent = tmgr_history_add_trace(history, speedTrace, 0.0, 0, this);
index 5b8c107..370dd71 100644 (file)
@@ -55,10 +55,10 @@ public:
 
 class CpuL07Model : public CpuModel {
 public:
-  CpuL07Model(HostL07Model *hmodel) : CpuModel() {p_hostModel = hmodel;};
-  ~CpuL07Model() {surf_cpu_model_pm = NULL;};
+  CpuL07Model(HostL07Model *hmodel,lmm_system_t sys);
+  ~CpuL07Model();
 
-  Cpu *createCpu(simgrid::Host *host,  xbt_dynar_t speedPeak,
+  Cpu *createCpu(simgrid::Host *host,  xbt_dynar_t speedPeakList,
                           int pstate, double speedScale,
                           tmgr_trace_t speedTrace, int core,
                           e_surf_resource_state_t state_initial,
@@ -70,8 +70,8 @@ public:
 
 class NetworkL07Model : public NetworkModel {
 public:
-  NetworkL07Model(HostL07Model *hmodel) : NetworkModel() {p_hostModel = hmodel;};
-  ~NetworkL07Model() {surf_network_model = NULL;};
+  NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys);
+  ~NetworkL07Model();
   Link* createLink(const char *name,
                  double bw_initial,
                  tmgr_trace_t bw_trace,
@@ -98,20 +98,14 @@ class CpuL07 : public Cpu {
   tmgr_trace_event_t p_stateEvent;
   tmgr_trace_event_t p_speedEvent;
 public:
-  CpuL07(CpuL07Model *model, simgrid::Host *host,
-                double power_scale, double power_initial, tmgr_trace_t power_trace,
+  CpuL07(CpuL07Model *model, simgrid::Host *host, xbt_dynar_t speedPeakList, int pstate,
+                double power_scale, tmgr_trace_t power_trace,
      int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace);
   ~CpuL07();
   bool isUsed() override;
   void updateState(tmgr_trace_event_t event_type, double value, double date) override;
   Action *execute(double size) override;
   Action *sleep(double duration) override;
-
-  double getCurrentPowerPeak() override {THROW_UNIMPLEMENTED;};
-  double getPowerPeakAt(int /*pstate_index*/) override {THROW_UNIMPLEMENTED;};
-  int getNbPstates() override {THROW_UNIMPLEMENTED;};
-  void setPstate(int /*pstate_index*/) override {THROW_UNIMPLEMENTED;};
-  int  getPstate() override {THROW_UNIMPLEMENTED;};
 };
 
 class LinkL07 : public Link {
index 1ee70cf..f8d8910 100644 (file)
@@ -5,7 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <src/surf/plugins/energy.hpp>
-#include <src/surf/cpu_cas01.hpp>
+#include <src/surf/cpu_interface.hpp>
 #include <src/surf/virtual_machine.hpp>
 
 /** @addtogroup SURF_plugin_energy
@@ -185,14 +185,14 @@ HostEnergy::~HostEnergy(){
 double HostEnergy::getWattMinAt(int pstate) {
   xbt_dynar_t power_range_list = power_range_watts_list;
   xbt_assert(power_range_watts_list, "No power range properties specified for host %s", host->getName());
-  xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast<simgrid::surf::CpuCas01*>(host->p_cpu)->getPState(), xbt_dynar_t);
+  xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, host->p_cpu->getPState(), xbt_dynar_t);
   double min_power = xbt_dynar_get_as(current_power_values, 0, double);
   return min_power;
 }
 double HostEnergy::getWattMaxAt(int pstate) {
   xbt_dynar_t power_range_list = power_range_watts_list;
   xbt_assert(power_range_watts_list, "No power range properties specified for host %s", host->getName());
-  xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast<simgrid::surf::CpuCas01*>(host->p_cpu)->getPState(), xbt_dynar_t);
+  xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, host->p_cpu->getPState(), xbt_dynar_t);
   double max_power = xbt_dynar_get_as(current_power_values, 1, double);
   return max_power;
 }
@@ -203,10 +203,11 @@ double HostEnergy::getCurrentWattsValue(double cpu_load)
        xbt_dynar_t power_range_list = power_range_watts_list;
        xbt_assert(power_range_watts_list, "No power range properties specified for host %s", host->getName());
 
+       int pstate = host->p_cpu->getPState();
+       xbt_assert(pstate < (int)xbt_dynar_length(power_range_list),
+                       "pstate %d >= power range amound %d",pstate,(int)xbt_dynar_length(power_range_list));
     /* retrieve the power values associated with the current pstate */
-    xbt_dynar_t current_power_values = xbt_dynar_get_as( power_range_list,
-      static_cast<simgrid::surf::CpuCas01*>(host->p_cpu)->getPState(),
-      xbt_dynar_t);
+    xbt_dynar_t current_power_values = xbt_dynar_get_as( power_range_list, pstate, xbt_dynar_t);
 
     /* min_power corresponds to the idle power (cpu load = 0) */
     /* max_power is the power consumed at 100% cpu load       */
index c709cca..5dc27ce 100644 (file)
@@ -283,14 +283,14 @@ double surf_host_get_power_peak_at(sg_host_t host, int pstate_index){
 }
 
 int surf_host_get_nb_pstates(sg_host_t host){
-  return sg_host_surfcpu(host)->getNbPstates();
+  return sg_host_surfcpu(host)->getNbPStates();
 }
 
 void surf_host_set_pstate(sg_host_t host, int pstate_index){
-       sg_host_surfcpu(host)->setPstate(pstate_index);
+       sg_host_surfcpu(host)->setPState(pstate_index);
 }
 int surf_host_get_pstate(sg_host_t host){
-  return sg_host_surfcpu(host)->getPstate();
+  return sg_host_surfcpu(host)->getPState();
 }
 
 using simgrid::energy::HostEnergy;
index 8599ee8..0c16aaf 100644 (file)
@@ -488,7 +488,7 @@ private:
 public: /* LMM */
   /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component */
   lmm_constraint_t getConstraint();
-private:
+protected:
   lmm_constraint_t p_constraint;
 };