X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/033b1246e6eb1fc4e6322dc561de751dc53d29e4..f19e50a635804ae911ec9ba2ddaff531b0f315d2:/src/surf/network.c diff --git a/src/surf/network.c b/src/surf/network.c index cdaddf0f51..0779efeadf 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -26,7 +26,6 @@ #undef GENERIC_ACTION #define GENERIC_ACTION(action) action->generic_action - XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf, "Logging specific to the SURF network module"); @@ -34,6 +33,15 @@ surf_model_t surf_network_model = NULL; static lmm_system_t network_maxmin_system = NULL; static void (*network_solve) (lmm_system_t) = NULL; +xbt_dynar_t smpi_bw_factor = NULL; +xbt_dynar_t smpi_lat_factor = NULL; + +typedef struct s_smpi_factor *smpi_factor_t; +typedef struct s_smpi_factor { + long factor; + double value; +} s_smpi_factor_t; + double sg_sender_gap = 0.0; double sg_latency_factor = 1.0; /* default value; can be set by model or from command line */ double sg_bandwidth_factor = 1.0; /* default value; can be set by model or from command line */ @@ -45,7 +53,7 @@ int sg_network_crosstraffic = 0; xbt_dict_t gap_lookup = NULL; e_UM_t network_update_mechanism = UM_UNDEFINED; -static int selective_update = 0; +static int net_selective_update = 0; static int net_action_is_suspended(surf_action_t action); static void update_action_remaining(double now); @@ -98,41 +106,67 @@ static double constant_bandwidth_constraint(double rate, double bound, return rate; } - /**********************/ /* SMPI callbacks */ /**********************/ -static double smpi_latency_factor(double size) +static xbt_dynar_t parse_factor(const char *smpi_coef_string) { - /* 1 B <= size <= 1 KiB */ - if (size <= 1024.0) { - return 1.0056; - } - - /* 2 KiB <= size <= 32 KiB */ - if (size <= 32768.0) { - return 1.8805; - } - - /* 64 KiB <= size <= 4 MiB */ - return 22.7111; + char *value = NULL; + unsigned int iter = 0; + s_smpi_factor_t fact; + xbt_dynar_t smpi_factor, radical_elements, radical_elements2 = NULL; + + smpi_factor = xbt_dynar_new(sizeof(s_smpi_factor_t), NULL); + radical_elements = xbt_str_split(smpi_coef_string, ";"); + xbt_dynar_foreach(radical_elements, iter, value) { + + radical_elements2 = xbt_str_split(value, ":"); + if(xbt_dynar_length(radical_elements2) != 2) + xbt_die("Malformed radical for smpi factor!"); + fact.factor = atol(xbt_dynar_get_as(radical_elements2,0,char*)); + fact.value = atof(xbt_dynar_get_as(radical_elements2,1,char*)); + xbt_dynar_push_as(smpi_factor,s_smpi_factor_t,fact); + XBT_DEBUG("smpi_factor:\t%ld : %f",fact.factor,fact.value); + xbt_dynar_free(&radical_elements2); + } + xbt_dynar_free(&radical_elements); + return smpi_factor; } static double smpi_bandwidth_factor(double size) { - /* 1 B <= size <= 1 KiB */ - if (size <= 1024.0) { - return 0.2758; - } - - /* 2 KiB <= size <= 32 KiB */ - if (size <= 32768.0) { - return 0.5477; - } + if(!smpi_bw_factor) + smpi_bw_factor = parse_factor( xbt_cfg_get_string(_surf_cfg_set,"smpi/bw_factor") ); + + unsigned int iter = 0; + s_smpi_factor_t fact; + xbt_dynar_foreach(smpi_bw_factor, iter, fact) { + if(size >= fact.factor){ + XBT_DEBUG("%lf >= %ld return %f",size,fact.factor,fact.value); + return fact.value; + } + } + + return 1.0; +} - /* 64 KiB <= size <= 4 MiB */ - return 0.9359; +static double smpi_latency_factor(double size) +{ + if(!smpi_lat_factor) + smpi_lat_factor = parse_factor( xbt_cfg_get_string(_surf_cfg_set,"smpi/lat_factor") ); + + unsigned int iter = 0; + s_smpi_factor_t fact; + xbt_dynar_foreach(smpi_lat_factor, iter, fact) { + if(size >= fact.factor){ + XBT_DEBUG("%lf >= %ld return %f",size,fact.factor,fact.value); + return fact.value; + } + } + + return 1.0; } +/**--------- -----------*/ static double smpi_bandwidth_constraint(double rate, double bound, double size) @@ -325,6 +359,7 @@ static int net_action_unref(surf_action_t action) static void net_action_cancel(surf_action_t action) { + XBT_DEBUG("cancel action %p",action); surf_network_model->action_state_set(action, SURF_ACTION_FAILED); if(network_update_mechanism == UM_LAZY){// remove action from the heap xbt_swag_remove(action, net_modified_set); @@ -338,7 +373,7 @@ void net_action_recycle(surf_action_t action) } #ifdef HAVE_LATENCY_BOUND_TRACKING -static int net_get_link_latency_limited(surf_action_t action) +int net_get_link_latency_limited(surf_action_t action) { return action->latency_limited; } @@ -579,7 +614,7 @@ static void net_update_actions_state_lazy(double now, double delta) XBT_DEBUG("Action %p: finish", action); GENERIC_ACTION(action).finish = surf_get_clock(); - // if I am wearing a latency heat + // if I am wearing a latency hat if( action->hat == LATENCY){ lmm_update_variable_weight(network_maxmin_system, action->variable, action->weight); @@ -930,6 +965,11 @@ static void net_finalize(void) xbt_heap_free(net_action_heap); xbt_swag_free(net_modified_set); } + + if(smpi_bw_factor) + xbt_dynar_free(&smpi_bw_factor); + if(smpi_lat_factor) + xbt_dynar_free(&smpi_lat_factor); } static void smpi_gap_append(double size, const link_CM02_t link, surf_action_network_CM02_t action) { @@ -995,6 +1035,9 @@ static void surf_network_model_init_internal(void) #ifdef HAVE_LATENCY_BOUND_TRACKING surf_network_model->get_latency_limited = net_get_link_latency_limited; #endif +#ifdef HAVE_TRACING + surf_network_model->set_category = net_action_set_category; +#endif surf_network_model->model_private->resource_used = net_resource_used; if(network_update_mechanism == UM_LAZY) { @@ -1026,7 +1069,7 @@ static void surf_network_model_init_internal(void) net_create_resource; if (!network_maxmin_system) - network_maxmin_system = lmm_system_new(selective_update); + network_maxmin_system = lmm_system_new(net_selective_update); routing_model_create(sizeof(link_CM02_t), net_create_resource("__loopback__", @@ -1043,15 +1086,19 @@ static void surf_network_model_init_internal(void) } static void set_update_mechanism(void) { +#ifdef HAVE_TRACING + TRACE_set_network_update_mechanism (); +#endif + 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; + net_selective_update = select; } else if (!strcmp(optim,"Lazy")) { network_update_mechanism = UM_LAZY; - selective_update = 1; + net_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 { @@ -1117,9 +1164,9 @@ void surf_network_model_init_LegrandVelho(void) xbt_dynar_push(model_list, &surf_network_model); network_solve = lmm_solve; - 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 + xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 13.01); + xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",0.97); + xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 20537); } /***************************************************************************/