From: navarro Date: Tue, 22 May 2012 15:24:32 +0000 (+0200) Subject: Merge of cpu_update_actions_state_full and net_update_actions_state_full X-Git-Tag: v3_8~694^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e882557cb5cd83578fc02fd6726299daf884ecaa Merge ... cpu_update_actions_state_full and net_update_actions_state_full --- diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 0ec928dc03..23ab22055b 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -316,6 +316,8 @@ typedef struct surf_model { int (*get_latency_limited) (surf_action_t action); /**< Return 1 if action is limited by latency, 0 otherwise */ #endif + void (*gap_remove) (surf_action_lmm_t action); + surf_model_private_t model_private; union extension { diff --git a/src/surf/cpu_cas01.c b/src/surf/cpu_cas01.c index 578416f45f..7025ee52b7 100644 --- a/src/surf/cpu_cas01.c +++ b/src/surf/cpu_cas01.c @@ -162,45 +162,7 @@ static void cpu_update_actions_state_lazy(double now, double delta) static void cpu_update_actions_state_full(double now, double delta) { - surf_action_cpu_Cas01_t action = NULL; - surf_action_cpu_Cas01_t next_action = NULL; - xbt_swag_t running_actions = surf_cpu_model->states.running_action_set; - xbt_swag_foreach_safe(action, next_action, running_actions) { -#ifdef HAVE_TRACING - if (TRACE_is_enabled()) { - cpu_Cas01_t x = - lmm_constraint_id(lmm_get_cnst_from_var - (surf_cpu_model->model_private->maxmin_system, - GENERIC_LMM_ACTION(action).variable, 0)); - - TRACE_surf_host_set_utilization(x->generic_resource.name, - ((surf_action_t)action)->category, - lmm_variable_getvalue(GENERIC_LMM_ACTION(action). - variable), - now - delta, - delta); - TRACE_last_timestamp_to_dump = now - delta; - } -#endif - double_update(&(GENERIC_ACTION(action).remains), - lmm_variable_getvalue(GENERIC_LMM_ACTION(action). - variable) * delta); - if (GENERIC_LMM_ACTION(action).generic_action.max_duration != - NO_MAX_DURATION) - double_update(&(GENERIC_ACTION(action).max_duration), delta); - if ((GENERIC_ACTION(action).remains <= 0) && - (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) > - 0)) { - GENERIC_ACTION(action).finish = surf_get_clock(); - surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE); - } else if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) && - (GENERIC_ACTION(action).max_duration <= 0)) { - GENERIC_ACTION(action).finish = surf_get_clock(); - surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE); - } - } - - return; + generic_update_actions_state_full(now, delta, surf_cpu_model); } static void cpu_update_resource_state(void *id, diff --git a/src/surf/network.c b/src/surf/network.c index 50524f2292..99d03beebe 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -154,7 +154,6 @@ static double (*bandwidth_constraint_callback) (double, double, double) = static void (*gap_append) (double, const link_CM02_t, surf_action_network_CM02_t) = NULL; -static void (*gap_remove) (surf_action_network_CM02_t) = NULL; static void *net_create_resource(const char *name, double bw_initial, @@ -347,83 +346,7 @@ static double net_share_resources_lazy(double now) static void net_update_actions_state_full(double now, double delta) { - double deltap = 0.0; - surf_action_network_CM02_t action = NULL; - surf_action_network_CM02_t next_action = NULL; - xbt_swag_t running_actions = - surf_network_model->states.running_action_set; - /* - xbt_swag_t failed_actions = - surf_network_model->states.failed_action_set; - */ - - xbt_swag_foreach_safe(action, next_action, running_actions) { - deltap = delta; - if (action->latency > 0) { - if (action->latency > deltap) { - double_update(&(action->latency), deltap); - deltap = 0.0; - } else { - double_update(&(deltap), action->latency); - action->latency = 0.0; - } - if ((action->latency == 0.0) && !(GENERIC_LMM_ACTION(action).suspended)) - lmm_update_variable_weight(surf_network_model->model_private->maxmin_system, GENERIC_LMM_ACTION(action).variable, - action->weight); - } -#ifdef HAVE_TRACING - if (TRACE_is_enabled()) { - int n = lmm_get_number_of_cnst_from_var(surf_network_model->model_private->maxmin_system, GENERIC_LMM_ACTION(action).variable); - unsigned int i; - for (i = 0; i < n; i++){ - lmm_constraint_t constraint = lmm_get_cnst_from_var(surf_network_model->model_private->maxmin_system, - GENERIC_LMM_ACTION(action).variable, - i); - link_CM02_t link = lmm_constraint_id(constraint); - TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name, - ((surf_action_t)action)->category, - (lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable)* - lmm_get_cnst_weight_from_var(surf_network_model->model_private->maxmin_system, - GENERIC_LMM_ACTION(action).variable, - i)), - now - delta, - delta); - } - } -#endif - if (!lmm_get_number_of_cnst_from_var - (surf_network_model->model_private->maxmin_system, GENERIC_LMM_ACTION(action).variable)) { - /* There is actually no link used, hence an infinite bandwidth. - * This happens often when using models like vivaldi. - * In such case, just make sure that the action completes immediately. - */ - double_update(&(GENERIC_ACTION(action).remains), - GENERIC_ACTION(action).remains); - } - double_update(&(GENERIC_ACTION(action).remains), - lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable) * deltap); - if (((surf_action_t)action)->max_duration != NO_MAX_DURATION) - double_update(&(((surf_action_t)action)->max_duration), delta); - - if ((GENERIC_ACTION(action).remains <= 0) && - (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) > 0)) { - ((surf_action_t)action)->finish = surf_get_clock(); - surf_network_model->action_state_set((surf_action_t) action, - SURF_ACTION_DONE); - - if (gap_remove) - gap_remove(action); - } else if ((((surf_action_t)action)->max_duration != NO_MAX_DURATION) - && (((surf_action_t)action)->max_duration <= 0)) { - ((surf_action_t)action)->finish = surf_get_clock(); - surf_network_model->action_state_set((surf_action_t) action, - SURF_ACTION_DONE); - if (gap_remove) - gap_remove(action); - } - } - - return; + generic_update_actions_state_full(now, delta, surf_network_model); } static void net_update_actions_state_lazy(double now, double delta) @@ -767,10 +690,11 @@ static void smpi_gap_append(double size, const link_CM02_t link, } } -static void smpi_gap_remove(surf_action_network_CM02_t action) +static void smpi_gap_remove(surf_action_lmm_t lmm_action) { xbt_fifo_t fifo; size_t size; + surf_action_network_CM02_t action = (surf_action_network_CM02_t)(lmm_action); if (sg_sender_gap > 0.0 && action->sender.link_name && action->sender.fifo_item) { @@ -882,6 +806,8 @@ static void surf_network_model_init_internal(void) xbt_swag_new(xbt_swag_offset(comm, generic_lmm_action.action_list_hookup)); surf_network_model->model_private->maxmin_system->keep_track = surf_network_model->model_private->modified_set; } + + surf_network_model->gap_remove = NULL; } /************************************************************************/ @@ -906,7 +832,7 @@ void surf_network_model_init_SMPI(void) bandwidth_factor_callback = &smpi_bandwidth_factor; bandwidth_constraint_callback = &smpi_bandwidth_constraint; gap_append = &smpi_gap_append; - gap_remove = &smpi_gap_remove; + surf_network_model->gap_remove = &smpi_gap_remove; net_define_callbacks(); xbt_dynar_push(model_list, &surf_network_model); network_solve = lmm_solve; diff --git a/src/surf/surf_action.c b/src/surf/surf_action.c index c9b21c5c11..90d1878604 100644 --- a/src/surf/surf_action.c +++ b/src/surf/surf_action.c @@ -291,15 +291,16 @@ void surf_action_set_category(surf_action_t action, void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now) { double delta = 0.0; + surf_model_t model = action->generic_action.model_type; - if(action->generic_action.model_type == surf_network_model) + if(model == surf_network_model) { if (action->suspended != 0) return; } else { - xbt_assert(action->generic_action.state_set == surf_cpu_model->states.running_action_set, + xbt_assert(action->generic_action.state_set == model->states.running_action_set, "You're updating an action that is not running."); /* bogus priority, skip it */ @@ -315,10 +316,10 @@ void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now) action->last_value * delta); #ifdef HAVE_TRACING - if (action->generic_action.model_type == surf_cpu_model && TRACE_is_enabled()) { + if (model == surf_cpu_model && TRACE_is_enabled()) { surf_resource_t cpu = lmm_constraint_id(lmm_get_cnst_from_var - (surf_cpu_model->model_private->maxmin_system, + (model->model_private->maxmin_system, action->variable, 0)); TRACE_surf_host_set_utilization(cpu->name, action->generic_action.category, @@ -331,7 +332,7 @@ void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now) action->generic_action.remains); } - if(action->generic_action.model_type == surf_network_model) + if(model == surf_network_model) { if (((surf_action_t)action)->max_duration != NO_MAX_DURATION) double_update(&(((surf_action_t)action)->max_duration), delta); @@ -339,16 +340,16 @@ void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now) if ((((surf_action_t)action)->remains <= 0) && (lmm_get_variable_weight(action->variable) > 0)) { ((surf_action_t)action)->finish = surf_get_clock(); - surf_network_model->action_state_set((surf_action_t) action, + model->action_state_set((surf_action_t) action, SURF_ACTION_DONE); - surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t)action); + surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action); } else if (((((surf_action_t)action)->max_duration != NO_MAX_DURATION) && (((surf_action_t)action)->max_duration <= 0))) { ((surf_action_t)action)->finish = surf_get_clock(); - surf_network_model->action_state_set((surf_action_t) action, + model->action_state_set((surf_action_t) action, SURF_ACTION_DONE); - surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t)action); + surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action); } } @@ -458,3 +459,104 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo #endif return; } + +void generic_update_actions_state_full(double now, double delta, surf_model_t model) +{ + surf_action_lmm_t action = NULL; + surf_action_lmm_t next_action = NULL; + xbt_swag_t running_actions = model->states.running_action_set; + + xbt_swag_foreach_safe(action, next_action, running_actions) { + + if(model == surf_network_model) + { + double deltap = 0.0; + deltap = delta; + if (((surf_action_network_CM02_t)action)->latency > 0) { + if (((surf_action_network_CM02_t)action)->latency > deltap) { + double_update(&(((surf_action_network_CM02_t)action)->latency), deltap); + deltap = 0.0; + } else { + double_update(&(deltap), ((surf_action_network_CM02_t)action)->latency); + ((surf_action_network_CM02_t)action)->latency = 0.0; + } + if ((((surf_action_network_CM02_t)action)->latency == 0.0) && !(action->suspended)) + lmm_update_variable_weight(model->model_private->maxmin_system, action->variable, + ((surf_action_network_CM02_t)action)->weight); + } + #ifdef HAVE_TRACING + if (TRACE_is_enabled()) { + int n = lmm_get_number_of_cnst_from_var(model->model_private->maxmin_system, action->variable); + unsigned int i; + for (i = 0; i < n; i++){ + lmm_constraint_t constraint = lmm_get_cnst_from_var(model->model_private->maxmin_system, + action->variable, + i); + link_CM02_t link = lmm_constraint_id(constraint); + TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name, + ((surf_action_t)action)->category, + (lmm_variable_getvalue(action->variable)* + lmm_get_cnst_weight_from_var(model->model_private->maxmin_system, + action->variable, + i)), + now - delta, + delta); + } + } + #endif + if (!lmm_get_number_of_cnst_from_var + (model->model_private->maxmin_system, action->variable)) { + /* There is actually no link used, hence an infinite bandwidth. + * This happens often when using models like vivaldi. + * In such case, just make sure that the action completes immediately. + */ + double_update(&(action->generic_action.remains), + action->generic_action.remains); + } + } + else + { +#ifdef HAVE_TRACING + if (TRACE_is_enabled()) { + surf_resource_t x = + lmm_constraint_id(lmm_get_cnst_from_var + (model->model_private->maxmin_system, + action->variable, 0)); + + TRACE_surf_host_set_utilization(x->name, + ((surf_action_t)action)->category, + lmm_variable_getvalue(action->variable), + now - delta, + delta); + TRACE_last_timestamp_to_dump = now - delta; + } +#endif + } + + double_update(&(action->generic_action.remains), + lmm_variable_getvalue(action->variable) * delta); + + + if (action->generic_action.max_duration != NO_MAX_DURATION) + double_update(&(action->generic_action.max_duration), delta); + + + if ((action->generic_action.remains <= 0) && + (lmm_get_variable_weight(action->variable) > 0)) { + action->generic_action.finish = surf_get_clock(); + surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE); + + if (model->gap_remove && model == surf_network_model) + model->gap_remove(action); + } else if ((action->generic_action.max_duration != NO_MAX_DURATION) && + (action->generic_action.max_duration <= 0)) { + action->generic_action.finish = surf_get_clock(); + surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE); + + if (model->gap_remove && model == surf_network_model) + model->gap_remove(action); + } + } + + return; +} diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 65f4dab7aa..60a4e68429 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -94,6 +94,7 @@ void surf_action_set_category(surf_action_t action, double surf_action_get_remains(surf_action_t action); void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now); void generic_update_actions_state_lazy(double now, double delta, surf_model_t model); +void generic_update_actions_state_full(double now, double delta, surf_model_t model); FILE *surf_fopen(const char *name, const char *mode);