X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b15387511bf0c053e55724f67b63e1c1dad99465..9d765a692e8aae0c06d16ce6d7db2acdd0b3b63d:/src/surf/surf_routing_cluster.c diff --git a/src/surf/surf_routing_cluster.c b/src/surf/surf_routing_cluster.c index a0a92d83bd..840015941c 100644 --- a/src/surf/surf_routing_cluster.c +++ b/src/surf/surf_routing_cluster.c @@ -6,7 +6,6 @@ #include "surf_routing_private.h" /* Global vars */ -extern routing_global_t global_routing; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf"); @@ -14,51 +13,63 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf" * Note that a router is created, easing the interconnexion with the rest of the world. */ -static xbt_dict_t cluster_host_link = NULL; /* for tag cluster */ - typedef struct { - s_routing_component_t generic_routing; - xbt_dict_t dict_processing_units; - xbt_dict_t dict_autonomous_systems; -} s_routing_component_cluster_t, *routing_component_cluster_t; + s_as_t generic_routing; + void *backbone; +} s_as_cluster_t, *as_cluster_t; -/* Business methods */ -static route_extended_t cluster_get_route(routing_component_t rc, - const char *src, - const char *dst) { - xbt_dynar_t links_list = xbt_dynar_new(global_routing->size_of_link, NULL); +static xbt_dict_t cluster_host_link = NULL; + +/* Business methods */ +static void cluster_get_route_and_latency(AS_t as, + const char *src, const char *dst, + route_t route, double *lat) { surf_parsing_link_up_down_t info; info = xbt_dict_get_or_null(cluster_host_link,src); - if(info) xbt_dynar_push_as(links_list,void*,info->link_up); //link_up - - info = xbt_dict_get_or_null(cluster_host_link,rc->name); - if(info) xbt_dynar_push_as(links_list,void*,info->link_up); //link_bb + if(info) { // link up + xbt_dynar_push_as(route->link_list,void*,info->link_up); + if (lat) + *lat += surf_network_model->extension.network.get_link_latency(info->link_up); + } + + if ( ((as_cluster_t)as)->backbone ) { + xbt_dynar_push_as(route->link_list,void*, ((as_cluster_t)as)->backbone) ; + if (lat) + *lat += surf_network_model->extension.network.get_link_latency(((as_cluster_t)as)->backbone); + } info = xbt_dict_get_or_null(cluster_host_link,dst); - if(info) xbt_dynar_push_as(links_list,void*,info->link_down); //link_down - - route_extended_t new_e_route = NULL; - new_e_route = xbt_new0(s_route_extended_t, 1); - new_e_route->generic_route.link_list = links_list; - - return new_e_route; + if(info) { // link down + xbt_dynar_push_as(route->link_list,void*,info->link_down); + if (lat) + *lat += surf_network_model->extension.network.get_link_latency(info->link_down); + } } +static void model_cluster_finalize(AS_t as) { + xbt_dict_free(&cluster_host_link); + model_none_finalize(as); +} /* Creation routing model functions */ -routing_component_t model_cluster_create(void) +AS_t model_cluster_create(void) { - routing_component_t new_component = model_rulebased_create(); - new_component->get_route = cluster_get_route; + AS_t result = model_none_create_sized(sizeof(s_as_cluster_t)); + result->get_route_and_latency = cluster_get_route_and_latency; + result->finalize = model_cluster_finalize; - return (routing_component_t) new_component; + return (AS_t) result; } void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down_t info) { if(!cluster_host_link) - cluster_host_link = xbt_dict_new(); + cluster_host_link = xbt_dict_new_homogeneous(xbt_free); + + xbt_dict_set(cluster_host_link,host_id,info,NULL); +} - xbt_dict_set(cluster_host_link,host_id,info,xbt_free); +void surf_routing_cluster_add_backbone(AS_t as, void* bb) { + ((as_cluster_t)as)->backbone = bb; }