Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] Move sg_host_surfcpu_register() out of createCpu()
authorGabriel Corona <gabriel.corona@loria.fr>
Thu, 17 Dec 2015 12:53:05 +0000 (13:53 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 17 Dec 2015 12:53:08 +0000 (13:53 +0100)
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.cpp
src/surf/host_ptask_L07.cpp
src/surf/sg_platf.cpp
src/surf/vm_hl13.cpp

index 7aac612..afeb09a 100644 (file)
@@ -106,14 +106,10 @@ Cpu *CpuCas01Model::createCpu(const char *name, xbt_dynar_t speedPeak,
                           tmgr_trace_t state_trace,
                           xbt_dict_t cpu_properties)
 {
                           tmgr_trace_t state_trace,
                           xbt_dict_t cpu_properties)
 {
-  Cpu *cpu = NULL;
-  sg_host_t host = sg_host_by_name(name);
   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);
   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 = new CpuCas01(this, name, speedPeak, pstate, speedScale, speedTrace, core, state_initial, state_trace, cpu_properties);
-  sg_host_surfcpu_register(host, cpu);
+  Cpu *cpu = new CpuCas01(this, name, speedPeak, pstate, speedScale, speedTrace, core, state_initial, state_trace, cpu_properties);
   return cpu;
 }
 
   return cpu;
 }
 
index 0eeb532..352b1ea 100644 (file)
@@ -446,12 +446,10 @@ Cpu *CpuTiModel::createCpu(const char *name,
                            xbt_dict_t cpuProperties)
 {
   xbt_assert(core==1,"Multi-core not handled with this model yet");
                            xbt_dict_t cpuProperties)
 {
   xbt_assert(core==1,"Multi-core not handled with this model yet");
-  sg_host_t host = sg_host_by_name(name);
   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, name, speedPeak, pstate, speedScale, speedTrace,
                           core, stateInitial, stateTrace, cpuProperties);
   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, name, speedPeak, pstate, speedScale, speedTrace,
                           core, stateInitial, stateTrace, cpuProperties);
-  sg_host_surfcpu_register(host, cpu);
   return cpu;
 }
 
   return cpu;
 }
 
@@ -977,4 +975,3 @@ double CpuTiAction::getRemains()
 }
 
 #endif /* SURF_MODEL_CPUTI_H_ */
 }
 
 #endif /* SURF_MODEL_CPUTI_H_ */
-
index 6d92e97..0fc243c 100644 (file)
@@ -314,12 +314,9 @@ Cpu *CpuL07Model::createCpu(const char *name,  xbt_dynar_t powerPeak,
                           xbt_dict_t cpu_properties)
 {
   double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
                           xbt_dict_t cpu_properties)
 {
   double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
-  sg_host_t sg_host = sg_host_by_name(name);
-
   CpuL07 *cpu = new CpuL07(this, name, cpu_properties,
                                     power_initial, power_scale, power_trace,
                          core, state_initial, state_trace);
   CpuL07 *cpu = new CpuL07(this, name, cpu_properties,
                                     power_initial, power_scale, power_trace,
                          core, state_initial, state_trace);
-  sg_host_surfcpu_register(sg_host, cpu);
   return cpu;
 }
 
   return cpu;
 }
 
index 206a1ee..8efd18d 100644 (file)
@@ -70,6 +70,7 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host)
         host->initial_state,
         host->state_trace,
         host->properties);
         host->initial_state,
         host->state_trace,
         host->properties);
+  sg_host_surfcpu_register(sg_host_by_name(host->id), cpu);
   surf_host_model->createHost(host->id, net, cpu);
 
   if (TRACE_is_enabled() && TRACE_needs_platform())
   surf_host_model->createHost(host->id, net, cpu);
 
   if (TRACE_is_enabled() && TRACE_needs_platform())
index c0f76ca..85f83f6 100644 (file)
@@ -6,6 +6,8 @@
 
 #include <algorithm>
 
 
 #include <algorithm>
 
+#include <simgrid/host.h>
+
 #include "cpu_cas01.hpp"
 #include "vm_hl13.hpp"
 
 #include "cpu_cas01.hpp"
 #include "vm_hl13.hpp"
 
@@ -179,7 +181,8 @@ VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props,
    * is still used by the physical machine. */
   sg_host_t sg_sub_ws = sg_host_by_name_or_create(sub_ws->getName());
   p_netElm = new RoutingEdgeWrapper(sg_host_edge(sg_sub_ws));
    * is still used by the physical machine. */
   sg_host_t sg_sub_ws = sg_host_by_name_or_create(sub_ws->getName());
   p_netElm = new RoutingEdgeWrapper(sg_host_edge(sg_sub_ws));
-  sg_host_edge_set(sg_host_by_name_or_create(name), p_netElm);
+  sg_host_t host = sg_host_by_name_or_create(name);
+  sg_host_edge_set(host, p_netElm);
 
   p_subWs = sub_ws;
   p_currentState = SURF_VM_STATE_CREATED;
 
   p_subWs = sub_ws;
   p_currentState = SURF_VM_STATE_CREATED;
@@ -197,6 +200,7 @@ VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props,
       SURF_RESOURCE_ON,           // host->initial_state,
       NULL,                       // host->state_trace,
       NULL);                       // host->properties,
       SURF_RESOURCE_ON,           // host->initial_state,
       NULL,                       // host->state_trace,
       NULL);                       // host->properties,
+  sg_host_surfcpu_register(host, p_cpu);
 
   /* 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 ? */
 
   /* 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 ? */