X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b23e1eb029a107cdc16abd13f0f4d3f0650f642a..93b7899156ac9fee75c4a6a8b65b92b265d61d4f:/src/surf/cpu_interface.cpp diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index bc366f94be..0142878a73 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -14,8 +14,20 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf, int autoload_surf_cpu_model = 1; void_f_void_t surf_cpu_model_init_preparse = NULL; -CpuModel *surf_cpu_model_pm; -CpuModel *surf_cpu_model_vm; +simgrid::surf::CpuModel *surf_cpu_model_pm; +simgrid::surf::CpuModel *surf_cpu_model_vm; + +namespace simgrid { +namespace surf { + +simgrid::xbt::FacetLevel Cpu::LEVEL; + +void Cpu::init() +{ + if (!LEVEL.valid()) + LEVEL = simgrid::Host::add_level(); +} + /************* * Callbacks * *************/ @@ -30,7 +42,6 @@ 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; - void cpu_add_traces(){ surf_cpu_model_pm->addTraces(); } @@ -38,6 +49,7 @@ void cpu_add_traces(){ /********* * Model * *********/ + void CpuModel::updateActionsStateLazy(double now, double /*delta*/) { CpuAction *action; @@ -128,28 +140,26 @@ void CpuModel::updateActionsStateFull(double now, double delta) /************ * Resource * ************/ - -Cpu::Cpu(){ +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) - , p_constraintCore(NULL) - , p_constraintCoreId(NULL) { } -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) @@ -158,8 +168,6 @@ Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, if (core > 1) xbt_assert(model == surf_cpu_model_pm); - p_constraintCore = NULL; - p_constraintCoreId = NULL; if (model->getUpdateMechanism() != UM_UNDEFINED) { p_constraintCore = xbt_new(lmm_constraint_t, core); p_constraintCoreId = xbt_new(void*, core); @@ -173,14 +181,14 @@ 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(){ @@ -223,6 +231,17 @@ void Cpu::setState(e_surf_resource_state_t 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); + this->m_host = host; + simgrid::surf::cpuCreatedCallbacks(this); + simgrid::surf::cpuStateChangedCallbacks(this, + SURF_RESOURCE_ON, this->getState()); +} + /********** * Action * **********/ @@ -328,3 +347,6 @@ void CpuAction::setState(e_surf_action_state_t state){ Action::setState(state); surf_callback_emit(cpuActionStateChangedCallbacks, this, old, state); } + +} +}