X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/445590fd865f35e74be34955931c97b8956f6d7f..2851c17a93adcd3931c937b698b65f81400c6dc3:/src/surf/surf_routing_cluster.c diff --git a/src/surf/surf_routing_cluster.c b/src/surf/surf_routing_cluster.c index 9031e510c9..37f2e326e7 100644 --- a/src/surf/surf_routing_cluster.c +++ b/src/surf/surf_routing_cluster.c @@ -13,63 +13,65 @@ 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. */ -typedef struct { - s_as_t generic_routing; - void *backbone; -} s_as_cluster_t, *as_cluster_t; - - -static xbt_dict_t cluster_host_link = NULL; - /* Business methods */ static void cluster_get_route_and_latency(AS_t as, - network_element_t src, network_element_t dst, - route_t route, double *lat) { - - surf_parsing_link_up_down_t info; - - info = xbt_dict_get_or_null(cluster_host_link,src->name); - 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) ; + sg_routing_edge_t src, sg_routing_edge_t dst, + sg_platf_route_cbarg_t route, double *lat) { + + s_surf_parsing_link_up_down_t info; + XBT_DEBUG("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]", + src->name,src->id, + dst->name,dst->id); + + if(src->rc_type != SURF_NETWORK_ELEMENT_ROUTER){ // No specific link for router + info = xbt_dynar_get_as(as->link_up_down_list,src->id,s_surf_parsing_link_up_down_t); + if(info.link_up) { // 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->name); - 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); - } + } + + if(dst->rc_type != SURF_NETWORK_ELEMENT_ROUTER){ // No specific link for router + info = xbt_dynar_get_as(as->link_up_down_list,dst->id,s_surf_parsing_link_up_down_t); + if(info.link_down) { // 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); } + +static int cluster_parse_PU(AS_t rc, sg_routing_edge_t elm) { + XBT_DEBUG("Load process unit \"%s\"", elm->name); + xbt_dynar_push_as(rc->index_network_elm,sg_routing_edge_t,elm); + return xbt_dynar_length(rc->index_network_elm)-1; +} + +static int cluster_parse_AS(AS_t rc, sg_routing_edge_t elm) { + XBT_DEBUG("Load Autonomous system \"%s\"", elm->name); + xbt_dynar_push_as(rc->index_network_elm,sg_routing_edge_t,elm); + return xbt_dynar_length(rc->index_network_elm)-1; +} + /* Creation routing model functions */ AS_t model_cluster_create(void) { 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; + result->parse_AS = cluster_parse_AS; + result->parse_PU = cluster_parse_PU; 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_homogeneous(xbt_free); - - xbt_dict_set(cluster_host_link,host_id,info,NULL); -} - -void surf_routing_cluster_add_backbone(AS_t as, void* bb) { - ((as_cluster_t)as)->backbone = bb; -}