X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/725c769707a505cb0a66620ca7bfce85fe107e8e..3f20dab4d9cff3906de20b1e7ffdcd54827b7c28:/src/surf/network_im.c diff --git a/src/surf/network_im.c b/src/surf/network_im.c index 164d55fb2b..8b62c880fc 100644 --- a/src/surf/network_im.c +++ b/src/surf/network_im.c @@ -41,10 +41,13 @@ double sg_bandwidth_factor = 1.0; /* default value; can be set by model or double sg_weight_S_parameter = 0.0; /* default value; can be set by model or from command line */ double sg_tcp_gamma = 0.0; -int sg_network_fullduplex = 0; +int sg_network_crosstraffic = 0; xbt_dict_t gap_lookup = NULL; +e_UM_t network_update_mechanism = UM_UNDEFINED; +static int selective_update = 0; + typedef struct network_link_CM02_im { s_surf_resource_lmm_t lmm_resource; /* must remain first to be added to a trace */ @@ -62,7 +65,6 @@ static xbt_swag_t im_net_modified_set = NULL; static xbt_heap_t im_net_action_heap = NULL; xbt_swag_t keep_track = NULL; extern int sg_maxmin_selective_update; -extern e_UM_t update_mechanism; #ifdef HAVE_SMPI static void gap_append(double size, const link_CM02_im_t link, surf_action_network_CM02_im_t action); @@ -225,8 +227,7 @@ static void im_net_parse_link_init(sg_platf_link_cbarg_t link) link->state, link->state_trace, link->policy, - NULL); /* FIXME: We need to deep copy the properties or - * we won't be able to free it */ + link->properties); xbt_free(link_id); } else{ @@ -321,7 +322,7 @@ static int im_net_action_unref(surf_action_t action) lmm_variable_free(network_im_maxmin_system, ((surf_action_network_CM02_im_t) action)->variable); } - if(update_mechanism == UM_FULL){// remove action from the heap + if(network_update_mechanism == UM_LAZY){// remove action from the heap heap_remove((surf_action_network_CM02_im_t) action); xbt_swag_remove(action, im_net_modified_set); } @@ -341,7 +342,7 @@ static int im_net_action_unref(surf_action_t action) static void im_net_action_cancel(surf_action_t action) { surf_network_model->action_state_set(action, SURF_ACTION_FAILED); - if(update_mechanism == UM_FULL){// remove action from the heap + if(network_update_mechanism == UM_LAZY){// remove action from the heap xbt_swag_remove(action, im_net_modified_set); heap_remove((surf_action_network_CM02_im_t) action); } @@ -361,7 +362,7 @@ static int im_net_get_link_latency_limited(surf_action_t action) double im_net_action_get_remains(surf_action_t action) { - if(update_mechanism == UM_FULL)/* update remains before return it */ + if(network_update_mechanism == UM_LAZY)/* update remains before return it */ update_action_remaining(surf_get_clock()); return action->remains; } @@ -402,7 +403,7 @@ static void update_action_remaining(double now){ } } -static double net_share_resources(double now) +static double net_share_resources_full(double now) { s_surf_action_network_CM02_im_t s_action; surf_action_network_CM02_im_t action = NULL; @@ -439,7 +440,7 @@ static double net_share_resources(double now) return min; } -static double im_net_share_resources(double now) +static double net_share_resources_lazy(double now) { surf_action_network_CM02_im_t action = NULL; double min=-1; @@ -513,20 +514,7 @@ static double im_net_share_resources(double now) return min; } -static double generic_net_share_resources(double now) -{ - if(update_mechanism == UM_FULL) - return im_net_share_resources(now); - else if (update_mechanism == UM_LAZY) - { - return net_share_resources(now); - } else { - xbt_die("Invalide update mechanism!"); - return 0; - } -} - -static void net_update_actions_state(double now, double delta) +static void net_update_actions_state_full(double now, double delta) { double deltap = 0.0; surf_action_network_CM02_im_t action = NULL; @@ -603,7 +591,7 @@ static void net_update_actions_state(double now, double delta) return; } -static void im_net_update_actions_state(double now, double delta) +static void net_update_actions_state_lazy(double now, double delta) { surf_action_network_CM02_im_t action = NULL; @@ -639,19 +627,7 @@ static void im_net_update_actions_state(double now, double delta) return; } -static void generic_net_update_actions_state(double now, double delta) -{ - if(update_mechanism == UM_FULL) - im_net_update_actions_state(now,delta); - else if (update_mechanism == UM_LAZY) - { - net_update_actions_state(now,delta); - } else { - xbt_die("Invalide update mechanism!"); - } -} - -static void im_net_update_resource_state(void *id, +static void net_update_resource_state(void *id, tmgr_trace_event_t event_type, double value, double date) { @@ -783,7 +759,7 @@ static surf_action_t im_net_communicate(const char *src_name, xbt_dynar_t route=xbt_dynar_new(global_routing->size_of_link,NULL); routing_get_route_and_latency(src_name, dst_name, &route, &latency); - if (sg_network_fullduplex == 1) { + if (sg_network_crosstraffic == 1) { // FIXME: fill route directly (unclear: check with blame who put the FIXME) routing_get_route_and_latency(dst_name, src_name, &back_route,NULL); } @@ -804,6 +780,15 @@ static surf_action_t im_net_communicate(const char *src_name, break; } } + if (sg_network_crosstraffic == 1) { + xbt_dynar_foreach(back_route, i, link) { + if (link->lmm_resource.state_current == SURF_RESOURCE_OFF) { + failed = 1; + break; + } + } + } + action = surf_action_new(sizeof(s_surf_action_network_CM02_im_t), size, surf_network_model, failed); @@ -814,7 +799,7 @@ static surf_action_t im_net_communicate(const char *src_name, xbt_swag_insert(action, action->generic_action.state_set); action->rate = rate; - if(update_mechanism == UM_FULL){ + if(network_update_mechanism == UM_LAZY){ action->index_heap = -1; action->latency = 0.0; action->weight = 0.0; @@ -868,7 +853,7 @@ static surf_action_t im_net_communicate(const char *src_name, action->variable = lmm_variable_new(network_im_maxmin_system, action, 0.0, -1.0, constraints_per_variable); - if(update_mechanism == UM_FULL){ + if(network_update_mechanism == UM_LAZY){ // add to the heap the event when the latency is payed XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency + action->last_update); heap_insert(action, action->latency + action->last_update, LATENCY); @@ -906,7 +891,7 @@ static surf_action_t im_net_communicate(const char *src_name, action->variable, 1.0); } - if (sg_network_fullduplex == 1) { + if (sg_network_crosstraffic == 1) { XBT_DEBUG("Fullduplex active adding backward flow using 5%c", '%'); xbt_dynar_foreach(back_route, i, link) { lmm_expand(network_im_maxmin_system, link->lmm_resource.constraint, @@ -962,7 +947,7 @@ static void im_net_action_suspend(surf_action_t action) ((surf_action_network_CM02_im_t) action)->variable, 0.0); - if(update_mechanism == UM_FULL)// remove action from the heap + if(network_update_mechanism == UM_LAZY)// remove action from the heap heap_remove((surf_action_network_CM02_im_t) action); } @@ -975,7 +960,7 @@ static void im_net_action_resume(surf_action_t action) ((surf_action_network_CM02_im_t) action)->weight); ((surf_action_network_CM02_im_t) action)->suspended = 0; - if(update_mechanism == UM_FULL)// remove action from the heap + if(network_update_mechanism == UM_LAZY)// remove action from the heap heap_remove((surf_action_network_CM02_im_t) action); } } @@ -988,7 +973,7 @@ static int im_net_action_is_suspended(surf_action_t action) void im_net_action_set_max_duration(surf_action_t action, double duration) { action->max_duration = duration; - if(update_mechanism == UM_FULL)// remove action from the heap + if(network_update_mechanism == UM_LAZY)// remove action from the heap heap_remove((surf_action_network_CM02_im_t) action); } @@ -1007,7 +992,7 @@ static void im_net_finalize(void) lmm_system_free(network_im_maxmin_system); network_im_maxmin_system = NULL; - if(update_mechanism == UM_FULL){ + if(network_update_mechanism == UM_LAZY){ xbt_heap_free(im_net_action_heap); xbt_swag_free(im_net_modified_set); } @@ -1075,7 +1060,6 @@ static void gap_remove(surf_action_network_CM02_im_t action) { static void im_surf_network_model_init_internal(void) { s_surf_action_network_CM02_im_t comm; - surf_network_model = surf_model_init(); surf_network_model->name = "network"; @@ -1088,11 +1072,16 @@ static void im_surf_network_model_init_internal(void) #endif surf_network_model->model_private->resource_used = im_net_resource_used; - surf_network_model->model_private->share_resources = generic_net_share_resources; - surf_network_model->model_private->update_actions_state = - generic_net_update_actions_state; + if(network_update_mechanism == UM_LAZY) { + surf_network_model->model_private->share_resources = net_share_resources_lazy; + surf_network_model->model_private->update_actions_state = net_update_actions_state_lazy; + } else if(network_update_mechanism == UM_FULL) { + surf_network_model->model_private->share_resources = net_share_resources_full; + surf_network_model->model_private->update_actions_state = net_update_actions_state_full; + } + surf_network_model->model_private->update_resource_state = - im_net_update_resource_state; + net_update_resource_state; surf_network_model->model_private->finalize = im_net_finalize; surf_network_model->suspend = im_net_action_suspend; @@ -1111,8 +1100,8 @@ static void im_surf_network_model_init_internal(void) surf_network_model->extension.network.create_resource = im_net_create_resource; - if (!network_im_maxmin_system) - network_im_maxmin_system = lmm_system_new(); + if (!network_im_maxmin_system) + network_im_maxmin_system = lmm_system_new(selective_update); routing_model_create(sizeof(link_CM02_im_t), im_net_create_resource("__loopback__", @@ -1120,8 +1109,7 @@ static void im_surf_network_model_init_internal(void) SURF_RESOURCE_ON, NULL, SURF_LINK_FATPIPE, NULL)); - if(update_mechanism == UM_FULL){ - sg_maxmin_selective_update = 1; + if(network_update_mechanism == UM_LAZY){ im_net_action_heap = xbt_heap_new(8,NULL); xbt_heap_set_update_callback(im_net_action_heap, im_net_action_update_index_heap); im_net_modified_set = @@ -1129,6 +1117,23 @@ static void im_surf_network_model_init_internal(void) } } +static void set_update_mechanism(void) { + char *optim = xbt_cfg_get_string(_surf_cfg_set, "network/optim"); + int select = xbt_cfg_get_int(_surf_cfg_set, "network/maxmin_selective_update"); + + if(!strcmp(optim,"Full")) { + network_update_mechanism = UM_FULL; + selective_update = select; + } else if (!strcmp(optim,"Lazy")) { + network_update_mechanism = UM_LAZY; + selective_update = 1; + xbt_assert((select==1) || (xbt_cfg_is_default_value(_surf_cfg_set,"network/maxmin_selective_update")), + "Disabling selective update while using the lazy update mechanism is dumb!"); + } else { + xbt_die("Unsupported optimization (%s) for this model",optim); + } +} + /************************************************************************/ /* New model based on LV08 and experimental results of MPI ping-pongs */ /************************************************************************/ @@ -1137,6 +1142,8 @@ void surf_network_model_init_SMPI(void) if (surf_network_model) return; + set_update_mechanism(); + im_surf_network_model_init_internal(); im_latency_factor_callback = &smpi_latency_factor; im_bandwidth_factor_callback = &smpi_bandwidth_factor; @@ -1147,7 +1154,6 @@ void surf_network_model_init_SMPI(void) xbt_cfg_setdefault_double(_surf_cfg_set, "network/sender_gap", 10e-6); xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775); - } /************************************************************************/ @@ -1155,18 +1161,24 @@ void surf_network_model_init_SMPI(void) /************************************************************************/ void im_surf_network_model_init_LegrandVelho(void) { + char *model = xbt_cfg_get_string(_surf_cfg_set, "network/model"); if (surf_network_model) return; + + if(!strcmp(model,"LV08_fullupdate")) { + XBT_WARN("[*Deprecated*. Use --cfg=network/model:LV08 with option --cfg=network/optim:Full instead.]"); + } + set_update_mechanism(); + im_surf_network_model_init_internal(); im_net_define_callbacks(); xbt_dynar_push(model_list, &surf_network_model); network_im_solve = lmm_solve; - xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4); - xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor", - 0.92); - xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775); + xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4); // 13.01 when callibration is done without phase effects + xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",0.92);// 0.97 when callibration is done without phase effects + xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775); // 20537 when callibration is done without phase effects } /***************************************************************************/ @@ -1185,16 +1197,24 @@ void surf_network_model_init_CM02(void) if (surf_network_model) return; + + set_update_mechanism(); im_surf_network_model_init_internal(); im_net_define_callbacks(); xbt_dynar_push(model_list, &surf_network_model); network_im_solve = lmm_solve; + + xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 1.0); + xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor", 1.0); + xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 0.0); } void surf_network_model_init_Reno(void) { if (surf_network_model) return; + + set_update_mechanism(); im_surf_network_model_init_internal(); im_net_define_callbacks(); @@ -1214,6 +1234,8 @@ void surf_network_model_init_Reno2(void) { if (surf_network_model) return; + + set_update_mechanism(); im_surf_network_model_init_internal(); im_net_define_callbacks(); @@ -1233,6 +1255,8 @@ void surf_network_model_init_Vegas(void) { if (surf_network_model) return; + + set_update_mechanism(); im_surf_network_model_init_internal(); im_net_define_callbacks();