X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6760cb07d6b57be16928d95339d71e57c4e24f36..a1fa4f192a490a340c59ed77ab7c3c2ed1c76bd1:/src/surf/network.c diff --git a/src/surf/network.c b/src/surf/network.c index de86cc00a6..80a48680d8 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -22,6 +22,70 @@ double sg_weight_S_parameter = 0.0;/* default value; can be set by model or from double sg_tcp_gamma = 0.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, double bw_initial, tmgr_trace_t bw_trace, @@ -381,14 +445,17 @@ static void net_update_resource_state(void *id, 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); /* 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: @@ -397,8 +464,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; @@ -414,17 +479,23 @@ static surf_action_t net_communicate(const char *src_name, const char *dst_name, 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) */ @@ -516,6 +587,39 @@ 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 = (char*)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); @@ -554,6 +658,8 @@ static void surf_network_model_init_internal(void) 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(); @@ -565,6 +671,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 */ /************************************************************************/ @@ -670,3 +800,5 @@ void surf_network_model_init_Vegas(const char *filename) update_model_description(surf_network_model_description, "Vegas", surf_network_model); } + +