X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6760cb07d6b57be16928d95339d71e57c4e24f36..db9bb6fbdfaff4b3e37b928582aa4db0781a6534:/src/surf/network_gtnets.c diff --git a/src/surf/network_gtnets.c b/src/surf/network_gtnets.c index 11e6089998..ea448bd73e 100644 --- a/src/surf/network_gtnets.c +++ b/src/surf/network_gtnets.c @@ -13,7 +13,8 @@ static double time_to_next_flow_completion = -1; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_gtnets, surf, "Logging specific to the SURF network GTNetS module"); -extern routing_t used_routing; +extern routing_global_t global_routing; + double sg_gtnets_jitter=0.0; int sg_gtnets_jitter_seed=10; @@ -21,29 +22,47 @@ static void link_new(char *name, double bw, double lat, xbt_dict_t props) { static int link_count = -1; network_link_GTNETS_t gtnets_link; + network_link_GTNETS_t gtnets_link_friend; + int tmp_idsrc=-1; + int tmp_iddst=-1; + char *name_friend; if (xbt_dict_get_or_null(surf_network_model->resource_set, name)) { return; } - link_count++; +#ifdef HAVE_TRACING + TRACE_surf_link_declaration (name, bw, lat); +#endif - if (gtnets_add_link(link_count, bw, lat)) { - xbt_assert0(0, "Cannot create GTNetS link"); - } + DEBUG1("Scanning link name %s", name); + sscanf(name, "%d_%d", &tmp_idsrc, &tmp_iddst); + DEBUG2("Link name split into %d and %d", tmp_idsrc, tmp_iddst); + + xbt_assert0( (tmp_idsrc!=-1)&&(tmp_idsrc!=-1), "You need to respect fullduplex convention x_y for xml link id."); + + name_friend = (char *)calloc(strlen(name), sizeof(char)); + sprintf(name_friend, "%d_%d", tmp_iddst, tmp_idsrc); - /* KF: Insert entry in the dictionary */ gtnets_link = xbt_new0(s_network_link_GTNETS_t, 1); gtnets_link->generic_resource.name = name; gtnets_link->generic_resource.properties = props; gtnets_link->bw_current = bw; gtnets_link->lat_current = lat; - gtnets_link->id = link_count; -#ifdef HAVE_TRACING - TRACE_surf_link_declaration (name, bw, lat); -#endif + + if((gtnets_link_friend=xbt_dict_get_or_null(surf_network_model->resource_set, name_friend))) { + gtnets_link->id = gtnets_link_friend->id; + } else { + link_count++; + + DEBUG4("Adding new link, linkid %d, name %s, latency %g, bandwidth %g", link_count, name, lat, bw); + if (gtnets_add_link(link_count, bw, lat)) { + xbt_assert0(0, "Cannot create GTNetS link"); + } + gtnets_link->id = link_count; + } xbt_dict_set(surf_network_model->resource_set, name, gtnets_link, - surf_resource_free); + surf_resource_free); } static void route_new(int src_id, int dst_id, xbt_dynar_t links,int nb_link) @@ -112,31 +131,34 @@ static void parse_link_init(void) /* Create the gtnets topology based on routing strategy */ static void create_gtnets_topology() { - xbt_dict_cursor_t cursor = NULL; - char *key, *data; - - xbt_dict_t onelink_routes = used_routing->get_onelink_routes(); - xbt_assert0(onelink_routes, "Error onelink_routes was not initialized"); - - DEBUG0("Starting topology generation"); - - xbt_dict_foreach(onelink_routes, cursor, key, data){ - s_onelink_t link = (s_onelink_t) data; - DEBUG3("Link (#%d), src (#%d), dst (#%d)", ((network_link_GTNETS_t)(link->link_ptr))->id , link->src_id, link->dst_id); - DEBUG0("Calling one link route"); - if(used_routing->is_router(link->src_id)){ - gtnets_add_router(link->src_id); - } - if(used_routing->is_router(link->dst_id)){ - gtnets_add_router(link->dst_id); - } - route_onehop_new(link->src_id, link->dst_id, (network_link_GTNETS_t)(link->link_ptr)); - } - - xbt_dict_free(&route_table); - if (XBT_LOG_ISENABLED(surf_network_gtnets, xbt_log_priority_debug)) { - gtnets_print_topology(); - } +// xbt_dict_cursor_t cursor = NULL; +// char *key, *data; +// xbt_dict_t onelink_routes = global_routing->get_onelink_routes(); +// xbt_assert0(onelink_routes, "Error onelink_routes was not initialized"); +// +// DEBUG0("Starting topology generation"); +// À refaire plus tard. Il faut prendre la liste des hôtes/routeurs (dans routing) +// À partir de cette liste, on les numérote. +// Ensuite, on peut utiliser les id pour refaire les appels GTNets qui suivent. + +// xbt_dict_foreach(onelink_routes, cursor, key, data){ +// s_onelink_t link = (s_onelink_t) data; +// +// DEBUG3("Link (#%d), src (#%s), dst (#%s)", ((network_link_GTNETS_t)(link->link_ptr))->id , link->src, link->dst); +// DEBUG0("Calling one link route"); +// if(global_routing->is_router(link->src)){ +// gtnets_add_router(link->src_id); +// } +// if(global_routing->is_router(link->dst)){ +// gtnets_add_router(link->dst_id); +// } +// route_onehop_new(link->src_id, link->dst_id, (network_link_GTNETS_t)(link->link_ptr)); +// } +// +// xbt_dict_free(&route_table); +// if (XBT_LOG_ISENABLED(surf_network_gtnets, xbt_log_priority_debug)) { +// gtnets_print_topology(); +// } } /* Main XML parsing */ @@ -157,6 +179,9 @@ static int action_unref(surf_action_t action) action->refcount--; if (!action->refcount) { xbt_swag_remove(action, action->state_set); +#ifdef HAVE_TRACING + if (action->category) xbt_free (action->category); +#endif free(action); return 1; } @@ -233,30 +258,35 @@ static void update_actions_state(double now, double delta) xbt_swag_foreach(action, running_actions) { DEBUG2("Action (%p) remains old value: %f", action, action->generic_action.remains); - double remain = gtnets_get_flow_rx(action); + double sent = gtnets_get_flow_rx(action); #ifdef HAVE_TRACING - // tracing resource utilization - int src = TRACE_surf_gtnets_get_src (action); - int dst = TRACE_surf_gtnets_get_dst (action); - if (src != -1 && dst != -1){ - xbt_dynar_t route = used_routing->get_route(src, dst); - network_link_GTNETS_t link; - unsigned int i; - xbt_dynar_foreach(route, i, link) { - - TRACE_surf_link_set_utilization (link->generic_resource.name, - action->generic_action.data, (action->generic_action.remains-remain)/delta, now-delta, delta); - } + double trace_sent = sent; + if (trace_sent == 0){ + //if sent is equals to 0, means that gtnets sent all the bytes + trace_sent = action->generic_action.cost; } + // tracing resource utilization +// COMMENTED BY DAVID +// int src = TRACE_surf_gtnets_get_src (action); +// int dst = TRACE_surf_gtnets_get_dst (action); +// if (src != -1 && dst != -1){ +// xbt_dynar_t route = used_routing->get_route(src, dst); +// network_link_GTNETS_t link; +// unsigned int i; +// xbt_dynar_foreach(route, i, link) { +// TRACE_surf_link_set_utilization (link->generic_resource.name, +// action->generic_action.data, trace_sent/delta, now-delta, delta); +// } +// } #endif - DEBUG1("Remain value returned by GTNetS : %f", remain); + DEBUG1("Sent value returned by GTNetS : %f", sent); //need to trust this remain value - if (remain == 0) { + if (sent == 0) { action->generic_action.remains = 0; } else { - action->generic_action.remains = action->generic_action.cost - remain; + action->generic_action.remains = action->generic_action.cost - sent; } DEBUG2("Action (%p) remains new value: %f", action, action->generic_action.remains); @@ -292,15 +322,19 @@ static void update_resource_state(void *id, /* Max durations are not supported */ static surf_action_t communicate(const char *src_name, const char *dst_name, - int src, int dst, double size, double rate) + double size, double rate) { + int src,dst; + + // Utiliser le dictionnaire définit dans create_gtnets_topology pour initialiser correctement src et dst + src=dst=-1; surf_action_network_GTNETS_t action = NULL; xbt_assert0((src >= 0 && dst >= 0), "Either src or dst have invalid id (id<0)"); DEBUG4("Setting flow src %d \"%s\", dst %d \"%s\"", src, src_name, dst, dst_name); - xbt_dynar_t links = used_routing->get_route(src, dst); + xbt_dynar_t links = global_routing->get_route(src_name, dst_name); route_new(src, dst, links, xbt_dynar_length(links)); action = surf_action_new(sizeof(s_surf_action_network_GTNETS_t), size, surf_network_model, 0); @@ -337,11 +371,6 @@ static int action_is_suspended(surf_action_t action) static void finalize(void) { - xbt_dict_free(&surf_network_model->resource_set); - - surf_model_exit(surf_network_model); - surf_network_model = NULL; - gtnets_finalize(); } @@ -371,13 +400,19 @@ static void surf_network_model_init_internal(void) surf_network_model->extension.network.communicate = communicate; /* Added the initialization for GTNetS interface */ - if (gtnets_initialize()) { + if (gtnets_initialize(sg_tcp_gamma)) { xbt_assert0(0, "Impossible to initialize GTNetS interface"); } routing_model_create(sizeof(network_link_GTNETS_t), NULL); } +#ifdef HAVE_LATENCY_BOUND_TRACKING +static int get_latency_limited(surf_action_t action){ + return 0; +} +#endif + #ifdef HAVE_GTNETS void surf_network_model_init_GTNETS(const char *filename) { @@ -387,6 +422,10 @@ void surf_network_model_init_GTNETS(const char *filename) define_callbacks(filename); xbt_dynar_push(model_list, &surf_network_model); +#ifdef HAVE_LATENCY_BOUND_TRACKING + surf_network_model->get_latency_limited = get_latency_limited; +#endif + if(sg_gtnets_jitter > 0.0){ gtnets_set_jitter(sg_gtnets_jitter); gtnets_set_jitter_seed(sg_gtnets_jitter_seed);