From: navarro Date: Mon, 19 Mar 2012 10:22:44 +0000 (+0100) Subject: Remove dict cluster_host_link specific to cluster model. X-Git-Tag: v3_7~304 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/084e8bbede5c1c275292a037a5b2fbfcb8c7d381?hp=a067481f5e9782cf82ebc6c1487d58083ec2fbd5 Remove dict cluster_host_link specific to cluster model. --- diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index dafbfc4c47..a55186ef7c 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -152,6 +152,7 @@ typedef struct s_as { struct s_as *routing_father; xbt_dict_t routing_sons; network_element_t net_elem; + xbt_dynar_t link_up_down_list; void (*get_route_and_latency) (AS_t as, network_element_t src, network_element_t dst, route_t into, double *latency); diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index e93f8fad0f..8efa22a766 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -832,10 +832,12 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) xbt_dict_set(patterns, "suffix", xbt_strdup(cluster->suffix), NULL); } - XBT_DEBUG("", cluster->id); sg_platf_new_AS_begin(cluster->id, "Cluster"); + current_routing->link_up_down_list + = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL); + //Make all hosts radical_elements = xbt_str_split(cluster->radical, ","); xbt_dynar_foreach(radical_elements, iter, groups) { @@ -901,23 +903,22 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) link.policy = cluster->sharing_policy; sg_platf_new_link(&link); - surf_parsing_link_up_down_t info = - xbt_new0(s_surf_parsing_link_up_down_t, 1); + s_surf_parsing_link_up_down_t info; + if (link.policy == SURF_LINK_FULLDUPLEX) { char *tmp_link = bprintf("%s_UP", link_id); - info->link_up = + info.link_up = xbt_lib_get_or_null(link_lib, tmp_link, SURF_LINK_LEVEL); free(tmp_link); tmp_link = bprintf("%s_DOWN", link_id); - info->link_down = + info.link_down = xbt_lib_get_or_null(link_lib, tmp_link, SURF_LINK_LEVEL); free(tmp_link); } else { - info->link_up = xbt_lib_get_or_null(link_lib, link_id, SURF_LINK_LEVEL); - info->link_down = info->link_up; + info.link_up = xbt_lib_get_or_null(link_lib, link_id, SURF_LINK_LEVEL); + info.link_down = info.link_up; } - surf_routing_cluster_add_link(host_id, info); - + xbt_dynar_push(current_routing->link_up_down_list,&info); xbt_free(link_id); xbt_free(host_id); } diff --git a/src/surf/surf_routing_cluster.c b/src/surf/surf_routing_cluster.c index 9031e510c9..a34dc31c33 100644 --- a/src/surf/surf_routing_cluster.c +++ b/src/surf/surf_routing_cluster.c @@ -18,21 +18,23 @@ typedef struct { 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); + 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 ) { @@ -41,35 +43,43 @@ static void cluster_get_route_and_latency(AS_t as, *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); + xbt_dynar_free(&(as->link_up_down_list)); model_none_finalize(as); } + +static int cluster_parse_PU(AS_t rc, network_element_t elm) { + xbt_dynar_push(rc->index_network_elm, (void *)elm); + return xbt_dynar_length(rc->index_network_elm)-1; +} + +static int cluster_parse_AS(AS_t rc, network_element_t elm) { + xbt_dynar_push(rc->index_network_elm, (void *)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; } diff --git a/src/surf/surf_routing_private.h b/src/surf/surf_routing_private.h index 9b356ddefd..7a1e3dc5b9 100644 --- a/src/surf/surf_routing_private.h +++ b/src/surf/surf_routing_private.h @@ -75,7 +75,6 @@ AS_t model_rulebased_create(void); /* create structures for rulebased routi AS_t model_cluster_create(void); /* create structures for cluster routing model */ /* Pass info from the cluster parser to the cluster routing */ -void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down_t info); void surf_routing_cluster_add_backbone(AS_t as, void* bb); /* ************************************************** */