From: Martin Quinson Date: Thu, 10 Nov 2011 21:38:52 +0000 (+0100) Subject: do not search the cluster backbones again and again, store them in the right location X-Git-Tag: exp_20120216~325^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d3e1bd3437bd7573295b4cf05b79f66851b216b7?hp=d2c7a1ae78246fa7808b1cd2385d27985bbb331f;ds=sidebyside do not search the cluster backbones again and again, store them in the right location On the poor tests I've done, it seems to give a non negligible improvement on the goal example. Maybe 5-10%, but it's hard to say right now. --- diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 35e71ac261..451428390b 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -927,12 +927,7 @@ static void routing_parse_cluster(void) sg_platf_new_link(&link); - surf_parsing_link_up_down_t info = - xbt_new0(s_surf_parsing_link_up_down_t, 1); - info->link_up = - xbt_lib_get_or_null(link_lib, link_backbone, SURF_LINK_LEVEL); - info->link_down = info->link_up; - surf_routing_cluster_add_link(struct_cluster->id, info); + surf_routing_cluster_add_backbone(current_routing, xbt_lib_get_or_null(link_lib, link_backbone, SURF_LINK_LEVEL)); free(link_backbone); } diff --git a/src/surf/surf_routing_cluster.c b/src/surf/surf_routing_cluster.c index 2ea9e5170b..883b88722d 100644 --- a/src/surf/surf_routing_cluster.c +++ b/src/surf/surf_routing_cluster.c @@ -14,6 +14,12 @@ 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 */ @@ -28,8 +34,8 @@ static route_extended_t cluster_get_route(AS_t as, 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,as->name); - if(info) xbt_dynar_push_as(links_list,void*,info->link_up); //link_bb + if ( ((as_cluster_t)as)->backbone ) + xbt_dynar_push_as(links_list,void*, ((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 @@ -48,7 +54,7 @@ static void model_cluster_finalize(AS_t as) { /* Creation routing model functions */ AS_t model_cluster_create(void) { - AS_t result = model_none_create(); + AS_t result = model_none_create_sized(sizeof(s_as_cluster_t)); result->get_route = cluster_get_route; result->finalize = model_cluster_finalize; @@ -61,3 +67,7 @@ void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down 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; +} diff --git a/src/surf/surf_routing_private.h b/src/surf/surf_routing_private.h index e11316ecac..c12b6e3329 100644 --- a/src/surf/surf_routing_private.h +++ b/src/surf/surf_routing_private.h @@ -78,7 +78,9 @@ AS_t model_rulebased_create(void); /* create structures for rulebased routi /* ************** Cluster ROUTING **************** */ 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); /* ************************************************** */ /* ************** Vivaldi ROUTING **************** */