X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/bd2cf2d478d8e130e47a9b2943af0269b8da910a..3432ea9894c66b049be0b2ad1465d3677e739e19:/src/surf/network.c diff --git a/src/surf/network.c b/src/surf/network.c index e42e22a7f7..d62882504b 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team. +/* Copyright (c) 2004-2011. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -9,6 +9,9 @@ #include "xbt/str.h" #include "surf/surfxml_parse_values.h" +#include "surf/surf_resource.h" +#include "surf/surf_resource_lmm.h" + XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf, "Logging specific to the SURF network module"); @@ -196,22 +199,42 @@ static void net_parse_link_init(sg_platf_link_cbarg_t link) { XBT_DEBUG("link_CM02"); - if(link->V_policy_initial_link == SURF_LINK_FULLDUPLEX) - { - net_create_resource(bprintf("%s_UP",link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, link->properties); - net_create_resource(bprintf("%s_DOWN",link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, NULL); // FIXME: We need to deep copy the properties or we won't be able to free it - } - else - { - net_create_resource(xbt_strdup(link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, link->properties); + if (link->policy == SURF_LINK_FULLDUPLEX) { + char *link_id; + link_id = bprintf("%s_UP", link->id); + net_create_resource(link_id, + link->bandwidth, + link->bandwidth_trace, + link->latency, + link->latency_trace, + link->state, + link->state_trace, + link->policy, + link->properties); + xbt_free(link_id); + link_id = bprintf("%s_DOWN", link->id); + net_create_resource(link_id, + link->bandwidth, + link->bandwidth_trace, + link->latency, + link->latency_trace, + 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 */ + xbt_free(link_id); + } else { + net_create_resource(link->id, + link->bandwidth, + link->bandwidth_trace, + link->latency, + link->latency_trace, + link->state, + link->state_trace, + link->policy, + link->properties); } - } static void net_add_traces(void) @@ -295,8 +318,7 @@ static int net_action_unref(surf_action_t action) #ifdef HAVE_TRACING xbt_free(((surf_action_network_CM02_t) action)->src_name); xbt_free(((surf_action_network_CM02_t) action)->dst_name); - if (action->category) - xbt_free(action->category); + xbt_free(action->category); #endif surf_action_free(&action); return 1; @@ -391,8 +413,7 @@ static void net_update_actions_state(double now, double delta) } #ifdef HAVE_TRACING if (TRACE_is_enabled()) { - xbt_dynar_t route = global_routing->get_route(action->src_name, - action->dst_name); + xbt_dynar_t route = routing_get_route(action->src_name, action->dst_name); link_CM02_t link; unsigned int i; xbt_dynar_foreach(route, i, link) { @@ -564,11 +585,11 @@ static surf_action_t net_communicate(const char *src_name, xbt_dynar_t back_route = NULL; int constraints_per_variable = 0; xbt_dynar_t route; - // I will need this route for some time so require for no cleanup - global_routing->get_route_latency(src_name, dst_name, &route, &latency, 0); + // I need to have the forward and backward routes at the same time, so I don't ask the routing to cleanup the route right away for me + routing_get_route_and_latency(src_name, dst_name, &route, &latency, 0); if (sg_network_fullduplex == 1) { - back_route = global_routing->get_route(dst_name, src_name); + back_route = routing_get_route(dst_name, src_name); } /* LARGE PLATFORMS HACK: @@ -606,21 +627,21 @@ static surf_action_t net_communicate(const char *src_name, (link->lmm_resource.power.peak * link->lmm_resource.power.scale); if (bandwidth_bound < 0.0) bandwidth_bound = - (*bandwidth_factor_callback) (size) * + bandwidth_factor_callback(size) * (link->lmm_resource.power.peak * link->lmm_resource.power.scale); else bandwidth_bound = min(bandwidth_bound, - (*bandwidth_factor_callback) (size) * + 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_callback) (size); + action->latency *= latency_factor_callback(size); action->rate = - (*bandwidth_constraint_callback) (action->rate, bandwidth_bound, + bandwidth_constraint_callback(action->rate, bandwidth_bound, size); if(xbt_dynar_length(route) > 0) { @@ -701,7 +722,7 @@ static surf_action_t net_communicate(const char *src_name, static xbt_dynar_t net_get_route(const char *src, const char *dst) { - return global_routing->get_route(src, dst); + return routing_get_route(src, dst); } static double net_get_link_bandwidth(const void *link) @@ -763,8 +784,6 @@ static void net_finalize(void) surf_model_exit(surf_network_model); surf_network_model = NULL; - global_routing->finalize(); - lmm_system_free(network_maxmin_system); network_maxmin_system = NULL; } @@ -813,11 +832,11 @@ static void surf_network_model_init_internal(void) network_maxmin_system = lmm_system_new(); routing_model_create(sizeof(link_CM02_t), - net_create_resource(xbt_strdup("__loopback__"), - 498000000, NULL, 0.000015, NULL, - SURF_RESOURCE_ON, NULL, - SURF_LINK_FATPIPE, NULL), - net_get_link_latency); + net_create_resource("__loopback__", + 498000000, NULL, + 0.000015, NULL, + SURF_RESOURCE_ON, NULL, + SURF_LINK_FATPIPE, NULL)); } @@ -841,8 +860,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); - update_model_description(surf_network_model_description, - "SMPI", surf_network_model); } /************************************************************************/ @@ -863,8 +880,6 @@ void surf_network_model_init_LegrandVelho(void) 0.92); xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775); - update_model_description(surf_network_model_description, - "LV08_fullupdate", surf_network_model); } /***************************************************************************/ @@ -887,9 +902,6 @@ void surf_network_model_init_CM02(void) net_define_callbacks(); xbt_dynar_push(model_list, &surf_network_model); network_solve = lmm_solve; - - update_model_description(surf_network_model_description, - "CM02", surf_network_model); } void surf_network_model_init_Reno(void) @@ -908,9 +920,6 @@ void surf_network_model_init_Reno(void) 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); } @@ -931,9 +940,6 @@ void surf_network_model_init_Reno2(void) 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); } void surf_network_model_init_Vegas(void) @@ -952,7 +958,4 @@ void surf_network_model_init_Vegas(void) 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); }