X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b197602d9f391f0020949e793fd191bb722af74a..347f9a2ca55bffc88bf965952b9be3a15535e908:/src/surf/cpu_interface.cpp diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index d99dad7aa3..10334fa25f 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -20,12 +20,12 @@ simgrid::surf::CpuModel *surf_cpu_model_vm; namespace simgrid { namespace surf { -simgrid::xbt::FacetLevel Cpu::LEVEL; +simgrid::xbt::Extension Cpu::EXTENSION_ID; -void Cpu::init() +void Cpu::classInit() { - if (!LEVEL.valid()) - LEVEL = simgrid::Host::add_level(); + if (!EXTENSION_ID.valid()) + EXTENSION_ID = simgrid::Host::extension_create(); } /************* @@ -38,10 +38,8 @@ Cpu *getActionCpu(CpuAction *action) { action->getVariable(), 0))); } -surf_callback(void, Cpu*) cpuCreatedCallbacks; -surf_callback(void, Cpu*) cpuDestructedCallbacks; -surf_callback(void, Cpu*, e_surf_resource_state_t, e_surf_resource_state_t) cpuStateChangedCallbacks; -surf_callback(void, CpuAction*, e_surf_action_state_t, e_surf_action_state_t) cpuActionStateChangedCallbacks; +simgrid::surf::signal cpuActionStateChangedCallbacks; + void cpu_add_traces(){ surf_cpu_model_pm->addTraces(); } @@ -145,10 +143,10 @@ Cpu::Cpu() } -Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, +Cpu::Cpu(Model *model, const char *name, int core, double speedPeak, double speedScale, e_surf_resource_state_t stateInitial) - : Resource(model, name, props, stateInitial) + : Resource(model, name, stateInitial) , m_core(core) , m_speedPeak(speedPeak) , m_speedScale(speedScale) @@ -156,10 +154,10 @@ Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, } -Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, +Cpu::Cpu(Model *model, const char *name, lmm_constraint_t constraint, int core, double speedPeak, double speedScale, e_surf_resource_state_t stateInitial) - : Resource(model, name, props, constraint, stateInitial) + : Resource(model, name, constraint, stateInitial) , m_core(core) , m_speedPeak(speedPeak) , m_speedScale(speedScale) @@ -181,18 +179,18 @@ Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, } } -Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, +Cpu::Cpu(Model *model, const char *name, lmm_constraint_t constraint, int core, double speedPeak, double speedScale) -: Cpu(model, name, props, constraint, core, speedPeak, speedScale, SURF_RESOURCE_ON) +: Cpu(model, name, constraint, core, speedPeak, speedScale, SURF_RESOURCE_ON) {} -Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, +Cpu::Cpu(Model *model, const char *name, int core, double speedPeak, double speedScale) -: Cpu(model, name, props, core, speedPeak, speedScale, SURF_RESOURCE_ON) +: Cpu(model, name, core, speedPeak, speedScale, SURF_RESOURCE_ON) {} -Cpu::~Cpu(){ - surf_callback_emit(cpuDestructedCallbacks, this); +Cpu::~Cpu() +{ if (p_constraintCoreId){ for (int i = 0; i < m_core; i++) { xbt_free(p_constraintCoreId[i]); @@ -224,22 +222,12 @@ int Cpu::getCore() return m_core; } -void Cpu::setState(e_surf_resource_state_t state) -{ - e_surf_resource_state_t old = Resource::getState(); - Resource::setState(state); - surf_callback_emit(cpuStateChangedCallbacks, this, old, state); -} - void Cpu::plug(simgrid::Host* host) { if (this->m_host != nullptr) - xbt_die("Aleady plugged into host %s", host->id().c_str()); - host->set_facet(this); + xbt_die("Already plugged into host %s", host->getName().c_str()); + host->extension_set(this); this->m_host = host; - simgrid::surf::cpuCreatedCallbacks(this); - simgrid::surf::cpuStateChangedCallbacks(this, - SURF_RESOURCE_ON, this->getState()); } /********** @@ -342,10 +330,12 @@ void CpuAction::setAffinity(Cpu *cpu, unsigned long mask) XBT_OUT(); } +simgrid::surf::signal CpuAction::onStateChange; + void CpuAction::setState(e_surf_action_state_t state){ e_surf_action_state_t old = getState(); Action::setState(state); - surf_callback_emit(cpuActionStateChangedCallbacks, this, old, state); + onStateChange(this, old, state); } }