Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make the energy plugin usable with ptask (but not DVFS) (fix #27)
[simgrid.git] / src / surf / cpu_cas01.cpp
index 1535c15..014f9da 100644 (file)
@@ -99,7 +99,7 @@ CpuCas01Model::~CpuCas01Model()
   delete p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
 }
 
-Cpu *CpuCas01Model::createCpu(const char *name, xbt_dynar_t speedPeak,
+Cpu *CpuCas01Model::createCpu(simgrid::Host *host, xbt_dynar_t speedPeak,
                                  int pstate, double speedScale,
                           tmgr_trace_t speedTrace, int core,
                           e_surf_resource_state_t state_initial,
@@ -108,7 +108,7 @@ Cpu *CpuCas01Model::createCpu(const char *name, xbt_dynar_t speedPeak,
   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, name, speedPeak, pstate, speedScale, speedTrace, core, state_initial, state_trace);
+  Cpu *cpu = new CpuCas01(this, host, speedPeak, pstate, speedScale, speedTrace, core, state_initial, state_trace);
   return cpu;
 }
 
@@ -152,25 +152,16 @@ void CpuCas01Model::addTraces()
 /************
  * Resource *
  ************/
-CpuCas01::CpuCas01(CpuCas01Model *model, const char *name, xbt_dynar_t speedPeak,
+CpuCas01::CpuCas01(CpuCas01Model *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, name,
-         lmm_constraint_new(model->getMaxminSystem(), this, core * speedScale * xbt_dynar_get_as(speedPeak, pstate, double)),
-         core, xbt_dynar_get_as(speedPeak, pstate, double), speedScale,
+: 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,
     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 *
  **********/