From: Gabriel Corona Date: Thu, 17 Dec 2015 12:53:05 +0000 (+0100) Subject: [surf] Move sg_host_surfcpu_register() out of createCpu() X-Git-Tag: v3_13~1434^2~3 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5af8a8f19bfb5554ab98db4e8feed057d3b49e7c [surf] Move sg_host_surfcpu_register() out of createCpu() --- diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 7aac612325..afeb09aeae 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -106,14 +106,10 @@ Cpu *CpuCas01Model::createCpu(const char *name, xbt_dynar_t speedPeak, 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); - - 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; } diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 0eeb532ce1..352b1ea68a 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -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"); - 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); - sg_host_surfcpu_register(host, cpu); return cpu; } @@ -977,4 +975,3 @@ double CpuTiAction::getRemains() } #endif /* SURF_MODEL_CPUTI_H_ */ - diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index 6d92e97c61..0fc243c5a0 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -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); - 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); - sg_host_surfcpu_register(sg_host, cpu); return cpu; } diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 206a1ee60c..8efd18df47 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -70,6 +70,7 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host) 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()) diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index c0f76ca122..85f83f6456 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -6,6 +6,8 @@ #include +#include + #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)); - 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; @@ -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, + 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 ? */