X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/07ce716b44d53a070fc2358ec727bb1975198200..b24e3ced733a04e94b8045ddc66a8bcae0b69422:/src/surf/network.c diff --git a/src/surf/network.c b/src/surf/network.c index 384734d90a..dcdd47789a 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -1,6 +1,5 @@ -/* $Id$ */ - -/* Copyright (c) 2004 Arnaud Legrand. All rights reserved. */ +/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team. + * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -16,11 +15,76 @@ surf_model_t surf_network_model = NULL; static lmm_system_t network_maxmin_system = NULL; static void (*network_solve) (lmm_system_t) = NULL; -double latency_factor = 1.0; /* default value */ -double bandwidth_factor = 1.0; /* default value */ -double weight_S_parameter = 0.0; /* default value */ +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 */ +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; + + +/******************************************************************************/ +/* Factors callbacks */ +/******************************************************************************/ +static double constant_latency_factor(double size) +{ + return sg_latency_factor; +} + +static double constant_bandwidth_factor(double size) +{ + return sg_bandwidth_factor; +} + +static double constant_bandwidth_constraint(double rate, double bound, double size) +{ + return rate; +} + +/**********************/ +/* SMPI callbacks */ +/**********************/ +static double smpi_latency_factor(double size) +{ + /* 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; +} + +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; + } + + /* 64 KiB <= size <= 4 MiB */ + return 0.9359; +} + +static double smpi_bandwidth_constraint(double rate, double bound, double size) +{ + return rate < 0 ? bound : min(bound, rate * smpi_bandwidth_factor(size)); +} + + +static double (*latency_factor_callback)(double) = &constant_latency_factor; +static double (*bandwidth_factor_callback)(double) = &constant_bandwidth_factor; +static double (*bandwidth_constraint_callback)(double, double, double) = &constant_bandwidth_constraint; static link_CM02_t net_link_new(char *name, @@ -38,7 +102,7 @@ static link_CM02_t net_link_new(char *name, surf_resource_lmm_new(sizeof(s_link_CM02_t), surf_network_model, name, properties, network_maxmin_system, - bandwidth_factor * bw_initial, + sg_bandwidth_factor * bw_initial, history, state_initial, state_trace, bw_initial, bw_trace); @@ -56,6 +120,9 @@ static link_CM02_t net_link_new(char *name, xbt_dict_set(surf_network_model->resource_set, name, nw_link, surf_resource_free); +#ifdef HAVE_TRACING + TRACE_surf_link_declaration (name, bw_initial, lat_initial); +#endif return nw_link; } @@ -181,6 +248,8 @@ static int net_action_unref(surf_action_t action) static void net_action_cancel(surf_action_t action) { + surf_network_model->action_state_set((surf_action_t) action, + SURF_ACTION_FAILED); return; } @@ -189,6 +258,11 @@ static void net_action_recycle(surf_action_t action) return; } +static int net_get_link_latency(surf_action_t action) +{ + return action->latency_limited; +} + static double net_action_get_remains(surf_action_t action) { return action->remains; @@ -209,6 +283,11 @@ static double net_share_resources(double now) #define VARIABLE(action) (*((lmm_variable_t*)(((char *) (action)) + xbt_swag_offset(s_action, variable) ))) xbt_swag_foreach(action, running_actions) { + if( lmm_is_variable_limited_by_latency(action->variable) ){ + (action->generic_action).latency_limited = 1; + }else{ + (action->generic_action).latency_limited = 0; + } if (action->latency > 0) { if (min < 0) min = action->latency; @@ -232,6 +311,17 @@ static void net_update_actions_state(double now, double delta) */ xbt_swag_foreach_safe(action, next_action, running_actions) { + +#ifdef HAVE_TRACING + xbt_dynar_t route = used_routing->get_route(action->src, action->dst); + link_CM02_t link; + unsigned int i; + xbt_dynar_foreach(route, i, link) { + TRACE_surf_link_set_utilization (link->lmm_resource.generic_resource.name, + action->generic_action.data, lmm_variable_getvalue(action->variable), now-delta, delta); + } +#endif + deltap = delta; if (action->latency > 0) { if (action->latency > deltap) { @@ -277,7 +367,7 @@ static void net_update_resource_state(void *id, if (event_type == nw_link->lmm_resource.power.event) { double delta = - weight_S_parameter / value - weight_S_parameter / + sg_weight_S_parameter / value - sg_weight_S_parameter / (nw_link->lmm_resource.power.peak * nw_link->lmm_resource.power.scale); lmm_variable_t var = NULL; lmm_element_t elem = NULL; @@ -286,10 +376,13 @@ static void net_update_resource_state(void *id, nw_link->lmm_resource.power.peak = value; lmm_update_constraint_bound(network_maxmin_system, nw_link->lmm_resource.constraint, - bandwidth_factor * + sg_bandwidth_factor * (nw_link->lmm_resource.power.peak * nw_link->lmm_resource.power.scale)); - if (weight_S_parameter > 0) { +#ifdef HAVE_TRACING + TRACE_surf_link_set_bandwidth (date, nw_link->lmm_resource.generic_resource.name, sg_bandwidth_factor * (nw_link->lmm_resource.power.peak * nw_link->lmm_resource.power.scale)); +#endif + if (sg_weight_S_parameter > 0) { while ((var = lmm_get_var_from_cnst (network_maxmin_system, nw_link->lmm_resource.constraint, &elem))) { @@ -318,11 +411,18 @@ static void net_update_resource_state(void *id, if (action->rate < 0) lmm_update_variable_bound(network_maxmin_system, action->variable, sg_tcp_gamma / (2.0 * action->lat_current)); - else + else{ lmm_update_variable_bound(network_maxmin_system, action->variable, min(action->rate, sg_tcp_gamma / (2.0 * action->lat_current))); + + if(action->rate < sg_tcp_gamma / (2.0 * action->lat_current) ){ + INFO0("Flow is limited BYBANDWIDTH"); + }else{ + INFO1("Flow is limited BYLATENCY, latency of flow is %f",action->lat_current); + } + } if (!(action->suspended)) lmm_update_variable_weight(network_maxmin_system, action->variable, action->weight); @@ -360,17 +460,28 @@ static void net_update_resource_state(void *id, return; } + static surf_action_t net_communicate(const char *src_name, const char *dst_name, int src, int dst, double size, double rate) { + unsigned int i; + link_CM02_t link; + int failed = 0; surf_action_network_CM02_t action = NULL; + double bandwidth_bound; /* LARGE PLATFORMS HACK: Add a link_CM02_t *link and a int link_nb to network_card_CM02_t. It will represent local links for this node Use the cluster_id for ->id */ xbt_dynar_t route = used_routing->get_route(src, dst); + xbt_dynar_t back_route = NULL; + int constraints_per_variable = 0; + + if( sg_network_fullduplex == 1){ + back_route = used_routing->get_route(dst, src); + } + /* LARGE PLATFORMS HACK: total_route_size = route_size + src->link_nb + dst->nb */ - unsigned int i; XBT_IN4("(%s,%s,%g,%g)", src_name, dst_name, size, rate); /* LARGE PLATFORMS HACK: @@ -379,8 +490,6 @@ static surf_action_t net_communicate(const char *src_name, const char *dst_name, "You're trying to send data from %s to %s but there is no connection between these two hosts.", src_name, dst_name); - link_CM02_t link; - int failed = 0; xbt_dynar_foreach(route, i, link) { if (link->lmm_resource.state_current == SURF_RESOURCE_OFF) { failed = 1; @@ -390,34 +499,45 @@ static surf_action_t net_communicate(const char *src_name, const char *dst_name, action = surf_action_new(sizeof(s_surf_action_network_CM02_t), size, surf_network_model, failed); + (action->generic_action).latency_limited = 0; xbt_swag_insert(action, action->generic_action.state_set); action->rate = rate; action->latency = 0.0; action->weight = 0.0; + bandwidth_bound = -1.0; xbt_dynar_foreach(route, i, link) { action->latency += link->lat_current; action->weight += link->lat_current + - weight_S_parameter / + sg_weight_S_parameter / (link->lmm_resource.power.peak * link->lmm_resource.power.scale); + if(bandwidth_bound < 0.0) + bandwidth_bound = (*bandwidth_factor_callback)(size) * (link->lmm_resource.power.peak * link->lmm_resource.power.scale); + else + bandwidth_bound = min(bandwidth_bound, (*bandwidth_factor_callback)(size) * (link->lmm_resource.power.peak * link->lmm_resource.power.scale)); } /* LARGE PLATFORMS HACK: Add src->link and dst->link latencies */ action->lat_current = action->latency; - action->latency *= latency_factor; + action->latency *= (*latency_factor_callback)(size); + action->rate = (*bandwidth_constraint_callback)(action->rate, bandwidth_bound, size); /* LARGE PLATFORMS HACK: lmm_variable_new(..., total_route_size) */ + if(back_route != NULL){ + constraints_per_variable = xbt_dynar_length(route)+xbt_dynar_length(back_route); + }else{ + constraints_per_variable = xbt_dynar_length(route); + } + if (action->latency > 0) action->variable = - lmm_variable_new(network_maxmin_system, action, 0.0, -1.0, - xbt_dynar_length(route)); + lmm_variable_new(network_maxmin_system, action, 0.0, -1.0,constraints_per_variable); else action->variable = - lmm_variable_new(network_maxmin_system, action, 1.0, -1.0, - xbt_dynar_length(route)); + lmm_variable_new(network_maxmin_system, action, 1.0, -1.0,constraints_per_variable); if (action->rate < 0) { if (action->lat_current > 0) @@ -441,9 +561,20 @@ static surf_action_t net_communicate(const char *src_name, const char *dst_name, lmm_expand(network_maxmin_system, link->lmm_resource.constraint, action->variable, 1.0); } - /* LARGE PLATFORMS HACK: + + if( sg_network_fullduplex == 1){ + DEBUG1("Fullduplex active adding backward flow using 5%c", '%'); + xbt_dynar_foreach(back_route, i, link) { + lmm_expand(network_maxmin_system, link->lmm_resource.constraint, + action->variable, .05); + } + } /* LARGE PLATFORMS HACK: expand also with src->link and dst->link */ + /* saving the src and dst of this communication */ + action->src = src; + action->dst = dst; + XBT_OUT; return (surf_action_t) action; @@ -455,11 +586,6 @@ static double net_get_link_bandwidth(const void *link) return lmm->power.peak * lmm->power.scale; } -static double net_get_link_latency(const void *link) -{ - return ((link_CM02_t) link)->lat_current; -} - static int net_link_shared(const void *link) { return lmm_constraint_is_shared(((surf_resource_lmm_t) link)->constraint); @@ -494,6 +620,38 @@ static void net_action_set_max_duration(surf_action_t action, double duration) action->max_duration = duration; } + +/** + * FIXME : this should be done in the binding code !! + */ +void network_create_resource(char *name, + double initial_bandwidth,double initial_latency) +{ + + char* name_link; + double bw_initial; + tmgr_trace_t bw_trace; + double lat_initial; + tmgr_trace_t lat_trace; + e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON; + e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED; + tmgr_trace_t state_trace; + + name_link = xbt_strdup(name); + bw_initial = initial_bandwidth; + bw_trace = tmgr_trace_new(""); + lat_initial = initial_latency; + lat_trace = tmgr_trace_new(""); + // FIXME Hard Coded Values + //state_initial_link = SURF_RESOURCE_ON; + //policy_initial_link = SURF_LINK_SHARED; + state_trace = tmgr_trace_new(""); + + net_link_new(name_link, bw_initial, bw_trace, + lat_initial, lat_trace, state_initial_link, state_trace, + policy_initial_link, xbt_dict_new()); +} + static void net_finalize(void) { surf_model_exit(surf_network_model); @@ -513,6 +671,7 @@ static void surf_network_model_init_internal(void) surf_network_model->action_cancel = net_action_cancel; surf_network_model->action_recycle = net_action_recycle; surf_network_model->get_remains = net_action_get_remains; + surf_network_model->get_latency_limited = net_get_link_latency; surf_network_model->model_private->resource_used = net_resource_used; surf_network_model->model_private->share_resources = net_share_resources; @@ -530,8 +689,9 @@ static void surf_network_model_init_internal(void) surf_network_model->extension.network.communicate = net_communicate; surf_network_model->extension.network.get_link_bandwidth = net_get_link_bandwidth; - surf_network_model->extension.network.get_link_latency = net_get_link_latency; surf_network_model->extension.network.link_shared = net_link_shared; + surf_network_model->extension.network.create_resource = network_create_resource; + surf_network_model->extension.network.add_traces = net_add_traces; if (!network_maxmin_system) network_maxmin_system = lmm_system_new(); @@ -543,6 +703,30 @@ static void surf_network_model_init_internal(void) NULL)); } + + +/************************************************************************/ +/* New model based on LV08 and experimental results of MPI ping-pongs */ +/************************************************************************/ +void surf_network_model_init_SMPI(const char *filename) +{ + + if (surf_network_model) + return; + surf_network_model_init_internal(); + latency_factor_callback = &smpi_latency_factor; + bandwidth_factor_callback = &smpi_bandwidth_factor; + bandwidth_constraint_callback = &smpi_bandwidth_constraint; + net_define_callbacks(filename); + xbt_dynar_push(model_list, &surf_network_model); + network_solve = lmm_solve; + + xbt_cfg_setdefault_double(_surf_cfg_set,"network/weight_S", 8775); + + update_model_description(surf_network_model_description, + "SMPI", surf_network_model); +} + /************************************************************************/ /* New model based on optimizations discussed during this thesis */ /************************************************************************/ @@ -556,9 +740,9 @@ void surf_network_model_init_LegrandVelho(const char *filename) xbt_dynar_push(model_list, &surf_network_model); network_solve = lmm_solve; - latency_factor = 10.4; - bandwidth_factor = 0.92; - weight_S_parameter = 8775; + 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); update_model_description(surf_network_model_description, "LV08", surf_network_model); @@ -600,9 +784,9 @@ void surf_network_model_init_Reno(const char *filename) lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi); network_solve = lagrange_solve; - latency_factor = 10.4; - bandwidth_factor = 0.92; - weight_S_parameter = 8775; + 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); update_model_description(surf_network_model_description, "Reno", surf_network_model); @@ -621,9 +805,9 @@ void surf_network_model_init_Reno2(const char *filename) func_reno2_fpi); network_solve = lagrange_solve; - latency_factor = 10.4; - bandwidth_factor = 0.92; - weight_S_parameter = 8775; + 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_parameter", 8775); update_model_description(surf_network_model_description, "Reno2", surf_network_model); @@ -641,10 +825,12 @@ void surf_network_model_init_Vegas(const char *filename) func_vegas_fpi); network_solve = lagrange_solve; - latency_factor = 10.4; - bandwidth_factor = 0.92; - weight_S_parameter = 8775; + 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); update_model_description(surf_network_model_description, "Vegas", surf_network_model); } + +