X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dd77d806f578b2bab80b049bd2935ada37adadad..1059053df344f90ee74d4fc9af05efce32022813:/src/surf/surf_routing_cluster.c diff --git a/src/surf/surf_routing_cluster.c b/src/surf/surf_routing_cluster.c index 08416a886a..ccdfea6d51 100644 --- a/src/surf/surf_routing_cluster.c +++ b/src/surf/surf_routing_cluster.c @@ -7,79 +7,38 @@ /* Global vars */ extern routing_global_t global_routing; -extern routing_component_t current_routing; -extern model_type_t current_routing_model; -extern xbt_dynar_t link_list; -extern xbt_dict_t cluster_host_link; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf"); -/* Routing model structure */ +/* This routing is specifically setup to represent clusters, aka homogeneous sets of machines + * Note that a router is created, easing the interconnexion with the rest of the world. + */ 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; -/* Parse routing model functions */ -static route_extended_t cluster_get_route(routing_component_t rc, - const char *src, - const char *dst); +static xbt_dict_t cluster_host_link = NULL; /* Business methods */ -static route_extended_t cluster_get_route(routing_component_t rc, - const char *src, - const char *dst) -{ - xbt_assert(rc && src - && dst, - "Invalid params for \"get_route\" function at AS \"%s\"", - rc->name); - - - xbt_dynar_t links_list = - xbt_dynar_new(global_routing->size_of_link, NULL); - - char *cluster_is_fd = xbt_dict_get_or_null(cluster_host_link,rc->name); - char *link_src,*link_bb,*link_dst,*link_src_up,*link_dst_down; - - if(!cluster_is_fd){ // NOT FULLDUPLEX - link_src = xbt_dict_get_or_null(cluster_host_link,src); - if( !link_src && (global_routing->get_network_element_type(src) != SURF_NETWORK_ELEMENT_ROUTER) ) - xbt_die("No link for '%s' found!",src); - if(link_src) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_src, SURF_LINK_LEVEL)); //link_up - - link_bb = bprintf("%s_backbone",rc->name); - xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_bb, SURF_LINK_LEVEL)); //link_bb - free(link_bb); - - link_dst = xbt_dict_get_or_null(cluster_host_link,dst); - if( !link_dst && (global_routing->get_network_element_type(dst) != SURF_NETWORK_ELEMENT_ROUTER) ) - xbt_die("No link for '%s' found!",dst); - if(link_dst) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_dst, SURF_LINK_LEVEL)); //link_down - } - else // FULLDUPLEX - { - link_src = xbt_dict_get_or_null(cluster_host_link,src); - if( !link_src && (global_routing->get_network_element_type(src) != SURF_NETWORK_ELEMENT_ROUTER) ) - xbt_die("No link for '%s' found!",src); - link_src_up = bprintf("%s_UP",link_src); - if(link_src) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_src_up, SURF_LINK_LEVEL)); //link_up - free(link_src_up); - - link_bb = bprintf("%s_backbone",rc->name); - if(link_bb) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_bb, SURF_LINK_LEVEL)); //link_bb - free(link_bb); - - link_dst = xbt_dict_get_or_null(cluster_host_link,dst); - if(!link_dst && (global_routing->get_network_element_type(dst) != SURF_NETWORK_ELEMENT_ROUTER)) - xbt_die("No link for '%s' found!",dst); - link_dst_down = bprintf("%s_DOWN",link_dst); - if(link_dst) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_dst_down, SURF_LINK_LEVEL)); //link_down - free(link_dst_down); - } +static route_extended_t cluster_get_route(AS_t as, + const char *src, + const char *dst) { + + xbt_dynar_t links_list = xbt_dynar_new(global_routing->size_of_link, NULL); + + 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 + + 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 route_extended_t new_e_route = NULL; new_e_route = xbt_new0(s_route_extended_t, 1); @@ -88,11 +47,28 @@ static route_extended_t cluster_get_route(routing_component_t rc, return new_e_route; } +static void model_cluster_finalize(AS_t as) { + xbt_dict_free(&cluster_host_link); + model_none_finalize(as); +} /* Creation routing model functions */ -void *model_cluster_create(void) +AS_t model_cluster_create(void) { - routing_component_cluster_t new_component = model_rulebased_create(); - new_component->generic_routing.get_route = cluster_get_route; + AS_t result = model_none_create_sized(sizeof(s_as_cluster_t)); + result->get_route = cluster_get_route; + result->get_latency = generic_get_link_latency; + result->finalize = model_cluster_finalize; + + 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(); + + xbt_dict_set(cluster_host_link,host_id,info,xbt_free); +} - return new_component; +void surf_routing_cluster_add_backbone(AS_t as, void* bb) { + ((as_cluster_t)as)->backbone = bb; }