X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9888b5b5c4a3d51bbed3fc6862c8fb2843c2241b..5e2dd3ecf166c2d82974beb220aeb8dd4200f105:/src/surf/network.c diff --git a/src/surf/network.c b/src/surf/network.c index e867afd923..88232f08be 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. */ @@ -21,6 +20,71 @@ double sg_bandwidth_factor = 1.0; /* default value; can be set by model or from 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, @@ -102,6 +166,21 @@ static void net_parse_link_init(void) } +static void net_create_resource(char *name, + double bw_initial, + tmgr_trace_t bw_trace, + double lat_initial, + tmgr_trace_t lat_trace, + e_surf_resource_state_t + state_initial, + tmgr_trace_t state_trace, + e_surf_link_sharing_policy_t policy, + xbt_dict_t properties) +{ + net_link_new(name, bw_initial, bw_trace, + lat_initial, lat_trace, state_initial, state_trace, + policy, xbt_dict_new()); +} static void net_add_traces(void) { xbt_dict_cursor_t cursor = NULL; @@ -184,17 +263,20 @@ 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; + surf_network_model->action_state_set(action, SURF_ACTION_FAILED); } -static void net_action_recycle(surf_action_t action) +void net_action_recycle(surf_action_t action) { return; } -static double net_action_get_remains(surf_action_t action) +int net_get_link_latency(surf_action_t action) +{ + return action->latency_limited; +} + +double net_action_get_remains(surf_action_t action) { return action->remains; } @@ -214,6 +296,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; @@ -237,20 +324,17 @@ static void net_update_actions_state(double now, double delta) */ xbt_swag_foreach_safe(action, next_action, running_actions) { - #ifdef HAVE_TRACING - TRACE_surf_update_action_state (action, action->generic_action.data, - lmm_variable_getvalue(action->variable), "BandwidthUsed", now-delta, delta); - - 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_update_action_state_net_resource (link->lmm_resource.generic_resource.name, - action->generic_action.data, lmm_variable_getvalue(action->variable), now-delta, delta); - } +// COMMENTED BY DAVID +// 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) { @@ -264,6 +348,15 @@ static void net_update_actions_state(double now, double delta) lmm_update_variable_weight(network_maxmin_system, action->variable, action->weight); } +#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 double_update(&(action->generic_action.remains), lmm_variable_getvalue(action->variable) * deltap); if (action->generic_action.max_duration != NO_MAX_DURATION) @@ -340,11 +433,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); @@ -382,17 +482,31 @@ 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 route = used_routing->get_route(src, dst); // COMMENTED BY DAVID + xbt_dynar_t route = global_routing->get_route(src_name, dst_name); + xbt_dynar_t back_route = NULL; + int constraints_per_variable = 0; + + if( sg_network_fullduplex == 1){ + //back_route = used_routing->get_route(dst, src); // COMMENTED BY DAVID + back_route = global_routing->get_route(src_name, dst_name); + } + /* 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: @@ -401,8 +515,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; @@ -412,34 +524,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 + 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 *= sg_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) @@ -463,7 +586,14 @@ 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 */ @@ -481,11 +611,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); @@ -515,7 +640,7 @@ static int net_action_is_suspended(surf_action_t action) return ((surf_action_network_CM02_t) action)->suspended; } -static void net_action_set_max_duration(surf_action_t action, double duration) +void net_action_set_max_duration(surf_action_t action, double duration) { action->max_duration = duration; } @@ -525,7 +650,10 @@ static void net_finalize(void) surf_model_exit(surf_network_model); surf_network_model = NULL; - used_routing->finalize(); + //used_routing->finalize(); // COMMENTED BY DAVID + + global_routing->finalize(); + lmm_system_free(network_maxmin_system); network_maxmin_system = NULL; } @@ -539,6 +667,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; @@ -556,8 +685,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.add_traces = net_add_traces; + surf_network_model->extension.network.create_resource = net_create_resource; if (!network_maxmin_system) network_maxmin_system = lmm_system_new(); @@ -569,6 +699,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 */ /************************************************************************/ @@ -674,3 +828,5 @@ void surf_network_model_init_Vegas(const char *filename) update_model_description(surf_network_model_description, "Vegas", surf_network_model); } + +