Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify a bit the CPU creation API
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 24 Feb 2016 08:13:29 +0000 (09:13 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 24 Feb 2016 08:13:31 +0000 (09:13 +0100)
pstate and initiallyOn are not passed anymore to the constructor. They
default respectively to 0 and true. You can change the values after
creation if you want.

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/cpu_ti.hpp
src/surf/ptask_L07.cpp
src/surf/ptask_L07.hpp
src/surf/sg_platf.cpp
src/surf/vm_hl13.cpp

index 3f1ab84..0f52a6e 100644 (file)
@@ -83,15 +83,12 @@ CpuCas01Model::~CpuCas01Model()
 }
 
 Cpu *CpuCas01Model::createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeak,
-                      int pstate, double speedScale,
-                          tmgr_trace_t speedTrace, int core,
-                          int initiallyOn,
-                          tmgr_trace_t state_trace)
+    double speedScale, tmgr_trace_t speedTrace, int core, tmgr_trace_t state_trace)
 {
   xbt_assert(xbt_dynar_getfirst_as(speedPeak, double) > 0.0,
       "Speed has to be >0.0. Did you forget to specify the mandatory power attribute?");
   xbt_assert(core > 0, "Invalid number of cores %d. Must be larger than 0", core);
-  Cpu *cpu = new CpuCas01(this, host, speedPeak, pstate, speedScale, speedTrace, core, initiallyOn, state_trace);
+  Cpu *cpu = new CpuCas01(this, host, speedPeak, speedScale, speedTrace, core, state_trace);
   return cpu;
 }
 
@@ -104,13 +101,11 @@ double CpuCas01Model::next_occuring_event_full(double /*now*/)
  * Resource *
  ************/
 CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak,
-                         int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
-                         int initiallyOn, tmgr_trace_t stateTrace)
+    double speedScale, tmgr_trace_t speedTrace, int core,  tmgr_trace_t stateTrace)
 : Cpu(model, host,
-  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,
-    initiallyOn) {
+    lmm_constraint_new(model->getMaxminSystem(), this, core * speedScale * xbt_dynar_get_as(speedPeak, 0/*pstate*/, double)),
+    speedPeak, core, xbt_dynar_get_as(speedPeak, 0/*pstate*/, double), speedScale)
+{
 
   XBT_DEBUG("CPU create: peak=%f, pstate=%d", p_speed.peak, m_pstate);
 
index d2022aa..f0f5864 100644 (file)
@@ -27,11 +27,8 @@ public:
   CpuCas01Model();
   ~CpuCas01Model();
 
-  Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeak, int pstate,
-                   double speedScale,
-                          tmgr_trace_t speedTrace, int core,
-                          int initiallyOn,
-                          tmgr_trace_t state_trace) override;
+  Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeak, double speedScale,
+      tmgr_trace_t speedTrace, int core, tmgr_trace_t state_trace) override;
   double next_occuring_event_full(double now) override;
   ActionList *p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
 };
@@ -43,8 +40,7 @@ public:
 class CpuCas01 : public Cpu {
 public:
   CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak,
-        int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
-        int initiallyOn, tmgr_trace_t stateTrace) ;
+      double speedScale, tmgr_trace_t speedTrace, int core, tmgr_trace_t stateTrace) ;
   ~CpuCas01();
   void apply_event(tmgr_trace_iterator_t event, double value) override;
   CpuAction *execution_start(double size) override;
index 50b4ee1..c9a152e 100644 (file)
@@ -128,18 +128,14 @@ void CpuModel::updateActionsStateFull(double now, double delta)
  * Resource *
  ************/
 Cpu::Cpu(Model *model, simgrid::s4u::Host *host,
-       xbt_dynar_t speedPeakList, int pstate,
-     int core, double speedPeak, double speedScale,
-     int initiallyOn)
- : Cpu(model, host, NULL/*constraint*/, speedPeakList, pstate, core, speedPeak, speedScale, initiallyOn)
+    xbt_dynar_t speedPeakList, int core, double speedPeak, double speedScale)
+ : Cpu(model, host, NULL/*constraint*/, speedPeakList, core, speedPeak, speedScale)
 {
 }
 
 Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint,
-        xbt_dynar_t speedPeakList, int pstate,
-      int core, double speedPeak,
-        double speedScale, int initiallyOn)
- : Resource(model, host->name().c_str(), constraint, initiallyOn)
+    xbt_dynar_t speedPeakList, int core, double speedPeak, double speedScale)
+ : Resource(model, host->name().c_str(), constraint)
  , m_core(core)
  , m_host(host)
 {
@@ -156,8 +152,6 @@ Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint,
     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);
index 6e8e71a..2b02b27 100644 (file)
@@ -44,17 +44,14 @@ public:
    *
    * @param host The host that will have this CPU
    * @param speedPeak The peak spead (max speed in Flops)
-   * @param pstate [TODO]
    * @param speedScale The speed scale (in [O;1] available speed from peak)
    * @param speedTrace Trace variations
    * @param core The number of core of this Cpu
-   * @param initiallyOn [TODO]
    * @param state_trace [TODO]
    */
   virtual Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeak,
-                          int pstate, double speedScale,
+                          double speedScale,
                           tmgr_trace_t speedTrace, int core,
-                          int initiallyOn,
                           tmgr_trace_t state_trace)=0;
 
   void updateActionsStateLazy(double now, double delta);
@@ -79,17 +76,14 @@ public:
    * @param host The host in which this Cpu should be plugged
    * @param constraint The lmm constraint associated to this Cpu if it is part of a LMM component
    * @param speedPeakList [TODO]
-   * @param pstate [TODO]
    * @param core The number of core of this Cpu
    * @param speedPeak The speed peak of this Cpu in flops (max speed)
    * @param speedScale The speed scale of this Cpu in [0;1] (available amount)
-   * @param initiallyOn whether it is created running or crashed
    */
   Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host,
     lmm_constraint_t constraint,
-    xbt_dynar_t speedPeakList, int pstate,
-    int core, double speedPeak, double speedScale,
-    int initiallyOn);
+    xbt_dynar_t speedPeakList,
+    int core, double speedPeak, double speedScale);
 
   /**
    * @brief Cpu constructor
@@ -97,16 +91,13 @@ public:
    * @param model The CpuModel associated to this Cpu
    * @param host The host in which this Cpu should be plugged
    * @param speedPeakList [TODO]
-   * @param pstate
    * @param core The number of core of this Cpu
    * @param speedPeak The speed peak of this Cpu in flops (max speed)
    * @param speedScale The speed scale of this Cpu in [0;1] (available amount)
-   * @param initiallyOn whether it is created running or crashed
    */
   Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host,
-      xbt_dynar_t speedPeakList, int pstate,
-    int core, double speedPeak, double speedScale,
-    int initiallyOn);
+      xbt_dynar_t speedPeakList,
+    int core, double speedPeak, double speedScale);
 
   ~Cpu();
 
index 2cc517e..766ed5d 100644 (file)
@@ -415,19 +415,16 @@ CpuTiModel::~CpuTiModel()
 }
 
 Cpu *CpuTiModel::createCpu(simgrid::s4u::Host *host,
-                         xbt_dynar_t speedPeak,
-                         int pstate,
-                           double speedScale,
-                           tmgr_trace_t speedTrace,
-                           int core,
-                           int initiallyOn,
-                           tmgr_trace_t stateTrace)
+    xbt_dynar_t speedPeak,
+    double speedScale,
+    tmgr_trace_t speedTrace,
+    int core,
+    tmgr_trace_t stateTrace)
 {
   xbt_assert(core==1,"Multi-core not handled with this model yet");
   xbt_assert(xbt_dynar_getfirst_as(speedPeak, double) > 0.0,
       "Speed has to be >0.0. Did you forget to specify the mandatory speed attribute?");
-  CpuTi *cpu = new CpuTi(this, host, speedPeak, pstate, speedScale, speedTrace,
-               core, initiallyOn, stateTrace);
+  CpuTi *cpu = new CpuTi(this, host, speedPeak, speedScale, speedTrace, core, stateTrace);
   return cpu;
 }
 
@@ -471,9 +468,9 @@ void CpuTiModel::updateActionsState(double now, double /*delta*/)
  * Resource *
  ************/
 CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak,
-        int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
-        int initiallyOn, tmgr_trace_t stateTrace)
-  : Cpu(model, host, NULL, pstate, core, 0, speedScale, initiallyOn)
+        double speedScale, tmgr_trace_t speedTrace, int core,
+        tmgr_trace_t stateTrace)
+  : Cpu(model, host, NULL, core, 0, speedScale)
 {
   xbt_assert(core==1,"Multi-core not handled by this model yet");
   m_core = core;
index 1c5d3ec..c957662 100644 (file)
@@ -111,8 +111,8 @@ typedef boost::intrusive::list<CpuTiAction, ActionTiListOptions > ActionTiList;
 class CpuTi : public Cpu {
 public:
   CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak,
-        int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
-        int initiallyOn, tmgr_trace_t stateTrace) ;
+        double speedScale, tmgr_trace_t speedTrace, int core,
+        tmgr_trace_t stateTrace) ;
   ~CpuTi();
 
   void set_speed_trace(tmgr_trace_t trace) override;
@@ -149,10 +149,8 @@ class CpuTiModel : public CpuModel {
 public:
   CpuTiModel();
   ~CpuTiModel();
-  Cpu *createCpu(simgrid::s4u::Host *host,  xbt_dynar_t speedPeak,
-                          int pstate, double speedScale,
-                          tmgr_trace_t speedTrace, int core,
-                          int initiallyOn, tmgr_trace_t state_trace) override;
+  Cpu *createCpu(simgrid::s4u::Host *host,  xbt_dynar_t speedPeak,  double speedScale,
+      tmgr_trace_t speedTrace, int core, tmgr_trace_t state_trace) override;
   double next_occuring_event(double now) override;
   void updateActionsState(double now, double delta) override;
 
index 8754117..685709b 100644 (file)
@@ -296,13 +296,11 @@ Action *NetworkL07Model::communicate(NetCard *src, NetCard *dst,
 }
 
 Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host,  xbt_dynar_t powerPeakList,
-                          int pstate, double power_scale,
+                          double power_scale,
                           tmgr_trace_t power_trace, int core,
-                          int initiallyOn,
                           tmgr_trace_t state_trace)
 {
-  CpuL07 *cpu = new CpuL07(this, host, powerPeakList, pstate, power_scale, power_trace,
-                         core, initiallyOn, state_trace);
+  CpuL07 *cpu = new CpuL07(this, host, powerPeakList, power_scale, power_trace, core, state_trace);
   return cpu;
 }
 
@@ -333,13 +331,12 @@ Link* NetworkL07Model::createLink(const char *name,
  ************/
 
 CpuL07::CpuL07(CpuL07Model *model, simgrid::s4u::Host *host,
-               xbt_dynar_t speedPeakList, int pstate,
-         double speedScale, tmgr_trace_t speedTrace,
-             int core, int initiallyOn, tmgr_trace_t state_trace)
- : Cpu(model, host, speedPeakList, pstate,
-     core, xbt_dynar_get_as(speedPeakList,pstate,double), speedScale, initiallyOn)
+    xbt_dynar_t speedPeakList,
+    double speedScale, tmgr_trace_t speedTrace,
+    int core, tmgr_trace_t state_trace)
+ : Cpu(model, host, speedPeakList, core, xbt_dynar_get_as(speedPeakList,0,double), speedScale)
 {
-  p_constraint = lmm_constraint_new(model->getMaxminSystem(), this, xbt_dynar_get_as(speedPeakList,pstate,double) * speedScale);
+  p_constraint = lmm_constraint_new(model->getMaxminSystem(), this, xbt_dynar_get_as(speedPeakList,0,double) * speedScale);
 
   if (speedTrace)
     p_speed.event = future_evt_set->add_trace(speedTrace, 0.0, this);
index 1476127..f235b8c 100644 (file)
@@ -55,9 +55,8 @@ public:
   ~CpuL07Model();
 
   Cpu *createCpu(simgrid::s4u::Host *host,  xbt_dynar_t speedPeakList,
-                          int pstate, double speedScale,
+                          double speedScale,
                           tmgr_trace_t speedTrace, int core,
-                          int initiallyOn,
                           tmgr_trace_t state_trace) override;
   HostL07Model *p_hostModel;
 };
@@ -88,9 +87,9 @@ public:
 
 class CpuL07 : public Cpu {
 public:
-  CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate,
+  CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList,
      double power_scale, tmgr_trace_t power_trace,
-     int core, int initiallyOn, tmgr_trace_t state_trace);
+     int core, tmgr_trace_t state_trace);
   ~CpuL07();
   bool isUsed() override;
   void apply_event(tmgr_trace_iterator_t event, double value) override;
index a3ae7d8..1b6341f 100644 (file)
@@ -101,11 +101,16 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host)
 
   simgrid::surf::Cpu *cpu = surf_cpu_model_pm->createCpu( h,
       host->speed_peak,
-      host->pstate,
       host->speed_scale, host->speed_trace,
       host->core_amount,
-      host->initiallyOn, host->state_trace);
+      host->state_trace);
   surf_host_model->createHost(host->id, netcard, cpu, host->properties)->attach(h);
+
+  if (host->pstate != 0)
+    cpu->setPState(host->pstate);
+  if (! host->initiallyOn)
+    cpu->turnOff();
+
   simgrid::s4u::Host::onCreation(*h);
 
   if (TRACE_is_enabled() && TRACE_needs_platform())
index 6e8450f..07a646a 100644 (file)
@@ -132,12 +132,12 @@ VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t hos
 
   p_cpu = surf_cpu_model_vm->createCpu(host_VM, // the machine hosting the VM
       sub_cpu->getSpeedPeakList(),        // host->power_peak,
-      sub_cpu->getPState(),
       1,                          // host->power_scale,
       NULL,                       // host->power_trace,
       1,                          // host->core_amount,
-      1/*ON*/,                    // host->initiallyOn,
       NULL);                      // host->state_trace,
+  if (sub_cpu->getPState() != 0)
+    p_cpu->setPState(sub_cpu->getPState());
 
   /* We create cpu_action corresponding to a VM process on the host operating system. */
   /* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */