X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/95f98f86ddeb28cea15e126929f48d196160a316..e0d3b66cb9e29820cb06538de0c803f58e942794:/src/surf/surf.cpp diff --git a/src/surf/surf.cpp b/src/surf/surf.cpp index b46787d441..4c1ff82683 100644 --- a/src/surf/surf.cpp +++ b/src/surf/surf.cpp @@ -1,8 +1,9 @@ #include "surf_private.h" #include "surf.hpp" -#include "network.hpp" -#include "cpu.hpp" +#include "network_interface.hpp" +#include "cpu_interface.hpp" #include "workstation.hpp" +#include "vm_workstation.hpp" #include "simix/smx_host_private.h" #include "surf_routing.hpp" #include "simgrid/sg_config.h" @@ -14,6 +15,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (kernel)"); } + + /********* * Utils * *********/ @@ -73,8 +76,12 @@ static void remove_watched_host(void *key) xbt_dynar_free(&hosts); }*/ +/* model_list_invoke contains only surf_workstation and surf_vm_workstation. + * The callback functions of cpu_model and network_model will be called from + * those of these workstation models. */ +xbt_dynar_t model_list = NULL; /* for destroying all models correctly */ +xbt_dynar_t model_list_invoke = NULL; /* for invoking callbacks */ -xbt_dynar_t model_list = NULL; tmgr_history_t history = NULL; lmm_system_t maxmin_system = NULL; xbt_dynar_t surf_path = NULL; @@ -136,6 +143,13 @@ s_surf_model_description_t surf_workstation_model_description[] = { {NULL, NULL, NULL} /* this array must be NULL terminated */ }; +s_surf_model_description_t surf_vm_workstation_model_description[] = { + {"default", + "Default vm workstation model.)", + surf_vm_workstation_model_init_current_default}, + {NULL, NULL, NULL} /* this array must be NULL terminated */ +}; + s_surf_model_description_t surf_optimization_mode_description[] = { {"Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining).", @@ -160,11 +174,10 @@ s_surf_model_description_t surf_storage_model_description[] = { static xbt_parmap_t surf_parmap = NULL; /* parallel map on models */ #endif -static double *surf_mins = NULL; /* return value of share_resources for each model */ -static int surf_min_index; /* current index in surf_mins */ -static double min; /* duration determined by surf_solve */ - double NOW = 0; +double *surf_mins = NULL; /* return value of share_resources for each model */ +int surf_min_index; /* current index in surf_mins */ +double surf_min; /* duration determined by surf_solve */ double surf_get_clock(void) { @@ -301,7 +314,7 @@ static XBT_INLINE void surf_cpu_free(void *r) static XBT_INLINE void surf_link_free(void *r) { - delete dynamic_cast(static_cast(r)); + delete dynamic_cast(static_cast(r)); } static XBT_INLINE void surf_workstation_free(void *r) @@ -338,7 +351,9 @@ void surf_init(int *argc, char **argv) xbt_init(argc, argv); if (!model_list) - model_list = xbt_dynar_new(sizeof(surf_model_private_t), NULL); + model_list = xbt_dynar_new(sizeof(ModelPtr), NULL); + if (!model_list_invoke) + model_list_invoke = xbt_dynar_new(sizeof(ModelPtr), NULL); if (!history) history = tmgr_history_new(); @@ -368,6 +383,7 @@ void surf_exit(void) xbt_dynar_foreach(model_list, iter, model) delete model; xbt_dynar_free(&model_list); + xbt_dynar_free(&model_list_invoke); routing_exit(); if (maxmin_system) { @@ -381,9 +397,11 @@ void surf_exit(void) #ifdef CONTEXT_THREADS xbt_parmap_destroy(surf_parmap); +#endif + xbt_free(surf_mins); surf_mins = NULL; -#endif + xbt_dynar_free(&host_that_restart); xbt_dynar_free(&surf_path); @@ -406,11 +424,11 @@ void surf_exit(void) *********/ Model::Model(string name) - : m_name(name), m_resOnCB(0), m_resOffCB(0), - m_actSuspendCB(0), m_actCancelCB(0), m_actResumeCB(0), - p_maxminSystem(0) + : p_maxminSystem(0), m_name(name), + m_resOnCB(0), m_resOffCB(0), + m_actCancelCB(0), m_actSuspendCB(0), m_actResumeCB(0) { - ActionPtr action; + ActionPtr action = NULL; p_readyActionSet = xbt_swag_new(xbt_swag_offset(*action, p_stateHookup)); p_runningActionSet = xbt_swag_new(xbt_swag_offset(*action, p_stateHookup)); p_failedActionSet = xbt_swag_new(xbt_swag_offset(*action, p_stateHookup)); @@ -512,7 +530,7 @@ double Model::shareResourcesLazy(double now) return min; } -double Model::shareResourcesFull(double now) { +double Model::shareResourcesFull(double /*now*/) { THROW_UNIMPLEMENTED; } @@ -584,12 +602,12 @@ void Model::updateActionsState(double now, double delta) xbt_die("Invalid cpu update mechanism!"); } -void Model::updateActionsStateLazy(double now, double delta) +void Model::updateActionsStateLazy(double /*now*/, double /*delta*/) { } -void Model::updateActionsStateFull(double now, double delta) +void Model::updateActionsStateFull(double /*now*/, double /*delta*/) { } @@ -651,13 +669,12 @@ void Model::notifyActionSuspend(ActionPtr a) ************/ Resource::Resource(surf_model_t model, const char *name, xbt_dict_t props) - : m_name(xbt_strdup(name)), m_running(true), p_model(model), m_properties(props) + : m_name(xbt_strdup(name)), m_properties(props), p_model(model), m_running(true) {} -Resource::Resource(){ - //FIXME:free(m_name); - //FIXME:xbt_dict_free(&m_properties); -} +Resource::Resource() +: m_name(NULL), m_properties(NULL), p_model(NULL) +{} const char *Resource::getName() { @@ -674,6 +691,11 @@ e_surf_resource_state_t Resource::getState() return p_stateCurrent; } +void Resource::setState(e_surf_resource_state_t state) +{ + p_stateCurrent = state; +} + bool Resource::isOn() { return m_running; @@ -695,15 +717,13 @@ void Resource::turnOff() } } -ResourceLmm::ResourceLmm(surf_model_t model, const char *name, xbt_dict_t props, - lmm_system_t system, +ResourceLmm::ResourceLmm(lmm_system_t system, double constraint_value, tmgr_history_t history, e_surf_resource_state_t state_init, tmgr_trace_t state_trace, double metric_peak, tmgr_trace_t metric_trace) - : Resource(model, name, props) { p_constraint = lmm_constraint_new(system, this, constraint_value); p_stateCurrent = state_init; @@ -713,6 +733,8 @@ ResourceLmm::ResourceLmm(surf_model_t model, const char *name, xbt_dict_t props, p_power.peak = metric_peak; if (metric_trace) p_power.event = tmgr_history_add_trace(history, metric_trace, 0.0, 0, static_cast(this)); + else + p_power.event = NULL; } /********** @@ -731,9 +753,15 @@ const char *surf_action_state_names[6] = { Action::Action(){} Action::Action(ModelPtr model, double cost, bool failed): - m_cost(cost), p_model(model), m_failed(failed), m_remains(cost), - m_refcount(1), m_priority(1.0), m_maxDuration(NO_MAX_DURATION), - m_start(surf_get_clock()), m_finish(-1.0) + m_priority(1.0), + m_failed(failed), + m_start(surf_get_clock()), m_finish(-1.0), + m_remains(cost), + m_maxDuration(NO_MAX_DURATION), + m_cost(cost), + p_model(model), + m_refcount(1), + p_data(NULL) { #ifdef HAVE_TRACING p_category = NULL; @@ -978,7 +1006,7 @@ void ActionLmm::updateRemainingLazy(double now) double_update(&m_remains, m_lastValue * delta); #ifdef HAVE_TRACING - if (p_model == static_cast(surf_cpu_model) && TRACE_is_enabled()) { + if (p_model == static_cast(surf_cpu_model_pm) && TRACE_is_enabled()) { ResourcePtr cpu = static_cast(lmm_constraint_id(lmm_get_cnst_from_var(p_model->p_maxminSystem, p_variable, 0))); TRACE_surf_host_set_utilization(cpu->m_name, p_category, m_lastValue, m_lastUpdate, now - m_lastUpdate); }