From 792ee50ee3c72fbd12a6693dda4b5792844b50ab Mon Sep 17 00:00:00 2001 From: velho Date: Tue, 6 Oct 2009 12:45:11 +0000 Subject: [PATCH 1/1] Commit stollen from Arnaud personal git repository. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6712 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/surf/surf_private.h | 1 + src/surf/surf_routing.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 61e28b3989..54156f3126 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -85,6 +85,7 @@ struct s_routing { xbt_dynar_t (*get_route)(int src, int dst); void (*finalize)(void); int host_count; + int router_count; }; XBT_PUBLIC(void) routing_model_create(size_t size_of_link,void *loopback); diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 7f042e7601..00356453a3 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -64,6 +64,9 @@ typedef struct { } s_routing_full_t,*routing_full_t; #define ROUTE_FULL(i,j) ((routing_full_t)used_routing)->routing_table[(i)+(j)*(used_routing)->host_count] +#define HOST2ROUTER(id) ((id)+(2<<29)) +#define ROUTER2HOST(id) ((id)-(2>>20)) +#define ROUTER(id) ((id)>=(2<<29)) /* * Parsing @@ -74,6 +77,15 @@ static void routing_full_parse_Shost(void) { *val = used_routing->host_count++; xbt_dict_set(used_routing->host_id,A_surfxml_host_id,val,xbt_free); } + +static void routing_full_parse_Srouter(void) { + int *val = xbt_malloc(sizeof(int)); + DEBUG3("Seen router %s (%d -> #%d)",A_surfxml_router_id,used_routing->router_count, + HOST2ROUTER(used_routing->router_count)); + *val = HOST2ROUTER(used_routing->router_count++); + xbt_dict_set(used_routing->host_id,A_surfxml_router_id,val,xbt_free); +} + static int src_id = -1; static int dst_id = -1; static void routing_full_parse_Sroute_set_endpoints(void) @@ -251,6 +263,12 @@ static void routing_full_parse_end(void) { dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 16); xbt_dynar_free(&keys); + if(ROUTER(src_id) || ROUTER(dst_id)) { + DEBUG2("There is route with a router here: (%d ,%d)",src_id,dst_id); + /* Check there is only one link in the route and store the information */ + continue; + } + DEBUG4("Handle %d %d (from %d hosts): %ld links", src_id,dst_id,routing->generic_routing.host_count,xbt_dynar_length(links)); xbt_dynar_foreach(links, cpt, link_name) { @@ -311,6 +329,7 @@ static void routing_model_full_create(size_t size_of_link,void *loopback) { /* Setup the parsing callbacks we need */ routing->generic_routing.host_id = xbt_dict_new(); surfxml_add_callback(STag_surfxml_host_cb_list, &routing_full_parse_Shost); + surfxml_add_callback(STag_surfxml_router_cb_list, &routing_full_parse_Srouter); surfxml_add_callback(ETag_surfxml_platform_cb_list, &routing_full_parse_end); surfxml_add_callback(STag_surfxml_route_cb_list, &routing_full_parse_Sroute_set_endpoints); -- 2.20.1