Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] Factorize some CPU registration code in sg_host_surfcpu_register() (DRY)
[simgrid.git] / src / surf / cpu_cas01.cpp
index d7a4faf..a4579f2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2011, 2013-2014. The SimGrid Team.
+/* Copyright (c) 2009-2011, 2013-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -35,8 +35,8 @@ void surf_cpu_model_init_Cas01()
 
   Model *model_pm = surf_cpu_model_pm;
   Model *model_vm = surf_cpu_model_vm;
-  xbt_dynar_push(model_list, &model_pm);
-  xbt_dynar_push(model_list, &model_vm);
+  xbt_dynar_push(all_existing_models, &model_pm);
+  xbt_dynar_push(all_existing_models, &model_vm);
 }
 
 CpuCas01Model::CpuCas01Model() : CpuModel()
@@ -114,8 +114,7 @@ Cpu *CpuCas01Model::createCpu(const char *name, xbt_dynar_t power_peak,
   xbt_assert(core > 0, "Invalid number of cores %d. Must be larger than 0", core);
 
   cpu = new CpuCas01(this, name, power_peak, pstate, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
-  sg_host_surfcpu_set(host, cpu);
-
+  sg_host_surfcpu_register(host, cpu);
   return cpu;
 }
 
@@ -165,7 +164,8 @@ CpuCas01::CpuCas01(CpuCas01Model *model, const char *name, xbt_dynar_t powerPeak
                          xbt_dict_t properties)
 : Cpu(model, name, properties,
          lmm_constraint_new(model->getMaxminSystem(), this, core * powerScale * xbt_dynar_get_as(powerPeak, pstate, double)),
-         core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale) {
+         core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale,
+    stateInitial) {
   p_powerEvent = NULL;
   p_powerPeakList = powerPeak;
   m_pstate = pstate;
@@ -173,7 +173,6 @@ CpuCas01::CpuCas01(CpuCas01Model *model, const char *name, xbt_dynar_t powerPeak
   XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_powerPeak, m_pstate);
 
   m_core = core;
-  setState(stateInitial);
   if (powerTrace)
     p_powerEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, this);