From 220a2e5a4021f10d1a6a4d92ae478b2d1edb0973 Mon Sep 17 00:00:00 2001 From: navarrop Date: Fri, 5 Nov 2010 15:09:12 +0000 Subject: [PATCH] By default setting route symetrical to YES Implement a function to compare if two routes are different. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8500 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/cunit_unit.c | 2 +- src/surf/simgrid.dtd | 4 +- src/surf/simgrid_dtd.c | 6 +-- src/surf/surf_routing.c | 48 ++++++++++++++++--- .../three_hosts_non_symmetric_route.xml | 11 +---- .../two_hosts_one_link_fullduplex.xml | 4 +- 6 files changed, 52 insertions(+), 23 deletions(-) diff --git a/src/cunit_unit.c b/src/cunit_unit.c index d333278d4e..dc5aa8cb3b 100644 --- a/src/cunit_unit.c +++ b/src/cunit_unit.c @@ -8,7 +8,7 @@ /* GENERATED FILE, DO NOT EDIT */ /*******************************/ -#line 835 "xbt/cunit.c" +#line 826 "xbt/cunit.c" XBT_TEST_UNIT("expect", test_expected_failure, "expected failures") diff --git a/src/surf/simgrid.dtd b/src/surf/simgrid.dtd index 1dc2cfae94..5b6e5db2aa 100644 --- a/src/surf/simgrid.dtd +++ b/src/surf/simgrid.dtd @@ -62,14 +62,14 @@ - + - + diff --git a/src/surf/simgrid_dtd.c b/src/surf/simgrid_dtd.c index 5db2d8045a..24d2cfc8de 100644 --- a/src/surf/simgrid_dtd.c +++ b/src/surf/simgrid_dtd.c @@ -2816,7 +2816,7 @@ int surf_parse__flex_debug = 0; #define YY_RESTORE_YY_MORE_OFFSET char *surf_parse_text; /* Validating XML processor for src/surf/simgrid.dtd. - * Generated 2010/11/03 10:00:12. + * Generated 2010/11/04 11:16:46. * * This program was generated with the FleXML XML processor generator. * FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved. @@ -4957,7 +4957,7 @@ YY_RULE_SETUP { AX_surfxml_route_src = 0; AX_surfxml_route_dst = 0; - AX_surfxml_route_symetrical = A_surfxml_route_symetrical_NO; + AX_surfxml_route_symetrical = A_surfxml_route_symetrical_YES; ENTER(AL_surfxml_route); pushbuffer(0); } YY_BREAK @@ -5067,7 +5067,7 @@ YY_RULE_SETUP AX_surfxml_ASroute_dst = 0; AX_surfxml_ASroute_gw_src = 0; AX_surfxml_ASroute_gw_dst = 0; - AX_surfxml_ASroute_symetrical = A_surfxml_ASroute_symetrical_NO; + AX_surfxml_ASroute_symetrical = A_surfxml_ASroute_symetrical_YES; ENTER(AL_surfxml_ASroute); pushbuffer(0); } YY_BREAK diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 4a8c74274c..51eeb16d1d 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -114,6 +114,7 @@ static void generic_set_ASroute(routing_component_t rc, const char *src, static void generic_set_bypassroute(routing_component_t rc, const char *src, const char *dst, route_extended_t e_route); +int compare_routes(route_t route1, route_t route2); /* ************************************************************************** */ /* *************** GENERIC BUSINESS METHODS (declarations) ****************** */ @@ -2505,9 +2506,13 @@ static void generic_set_route(routing_component_t rc, const char *src, xbt_assert2(xbt_dynar_length(route->link_list) > 0, "Invalid count of links, must be greater than zero (%s,%s)", src, dst); - xbt_assert2(!xbt_dict_get_or_null(_parse_routes, route_name), - "The route between \"%s\" and \"%s\" already exist", src, - dst); + + if( compare_routes(route,xbt_dict_get_or_null(_parse_routes, route_name)) ) + xbt_die(bprintf("The route between \"%s\" and \"%s\" already exist", src,dst)); + +// xbt_assert2(!xbt_dict_get_or_null(_parse_routes, route_name), +// "The route between \"%s\" and \"%s\" already exist", src, +// dst); xbt_dict_set(_parse_routes, route_name, route, NULL); xbt_free(route_name); @@ -2524,6 +2529,8 @@ static void generic_set_route(routing_component_t rc, const char *src, xbt_dynar_push_as(route_sym->link_list ,char *, link_name); } DEBUG2("Load Route from \"%s\" to \"%s\"", dst, src); + if( compare_routes(route_sym,xbt_dict_get_or_null(_parse_routes, bprintf("%d#%d",*dst_id, *src_id))) ) + xbt_die(bprintf("The route between \"%s\" and \"%s\" already exist", dst,src)); xbt_dict_set(_parse_routes, bprintf("%d#%d",*dst_id, *src_id), route_sym, NULL); } } @@ -2552,9 +2559,10 @@ static void generic_set_ASroute(routing_component_t rc, const char *src, xbt_assert2(xbt_dynar_length(e_route->generic_route.link_list) > 0, "Invalid count of links, must be greater than zero (%s,%s)", src, dst); - xbt_assert4(!xbt_dict_get_or_null(_parse_routes, route_name), - "The route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist", - src, e_route->src_gateway, dst, e_route->dst_gateway); + + if( compare_routes((route_t) &(e_route->generic_route),xbt_dict_get_or_null(_parse_routes, route_name)) ) + xbt_die(bprintf("The route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist", + src, e_route->src_gateway, dst, e_route->dst_gateway)); xbt_dict_set(_parse_routes, route_name, e_route, NULL); xbt_free(route_name); @@ -2576,6 +2584,11 @@ static void generic_set_ASroute(routing_component_t rc, const char *src, route_sym->dst_gateway = xbt_new0( char,strlen(e_route->src_gateway) ); route_sym->dst_gateway = bprintf("%s",e_route->src_gateway); DEBUG4("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",dst, route_sym->src_gateway,src,route_sym->dst_gateway); + + if( compare_routes((route_t) &(route_sym->generic_route),xbt_dict_get_or_null(_parse_routes,bprintf("%d#%d", *dst_id, *src_id))) ) + xbt_die(bprintf("The route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist", + dst, route_sym->src_gateway, src, route_sym->dst_gateway)); + xbt_dict_set(_parse_routes, bprintf("%d#%d", *dst_id, *src_id), route_sym, NULL); } } @@ -3281,3 +3294,26 @@ void routing_store_route(void) { parse_E_route_store_route(); } + +/* + * Compare two routes to know if the second route is in the table. + * route1 : route to store + * route2 : old route in the table + */ +int compare_routes(route_t route1, route_t route2) +{ + if(!route2) return 0; + if(xbt_dynar_length(route1->link_list) == xbt_dynar_length(route2->link_list)) + { + int i; + int nb_links = xbt_dynar_length(route1->link_list); + for(i=0 ; ilink_list, i, char *); + char *link_name2 = xbt_dynar_get_as(route2->link_list, i, char *); + if(strcmp(link_name1,link_name2)) return 1; + } + return 0; + } + return 1; +} diff --git a/teshsuite/simdag/platforms/three_hosts_non_symmetric_route.xml b/teshsuite/simdag/platforms/three_hosts_non_symmetric_route.xml index fb58ad0512..10811000a3 100644 --- a/teshsuite/simdag/platforms/three_hosts_non_symmetric_route.xml +++ b/teshsuite/simdag/platforms/three_hosts_non_symmetric_route.xml @@ -10,10 +10,10 @@ - + - + @@ -22,15 +22,8 @@ - - - - - - - diff --git a/teshsuite/simdag/platforms/two_hosts_one_link_fullduplex.xml b/teshsuite/simdag/platforms/two_hosts_one_link_fullduplex.xml index 24cffdba3c..08904b4851 100644 --- a/teshsuite/simdag/platforms/two_hosts_one_link_fullduplex.xml +++ b/teshsuite/simdag/platforms/two_hosts_one_link_fullduplex.xml @@ -8,11 +8,11 @@ - + - + -- 2.20.1