From: navarro Date: Wed, 8 Aug 2012 12:41:22 +0000 (+0200) Subject: Factorize route ASroute bypassRoute and bypassASroute from sg_platf. X-Git-Tag: v3_8~183 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c5b155e2a4b1773e2e294b834cc368d13a866148 Factorize route ASroute bypassRoute and bypassASroute from sg_platf. Replace char* gw_src/dst for edge. --- diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index 3f6189a681..652332fe8b 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -128,35 +128,11 @@ typedef struct s_sg_platf_route_cbarg { int symmetrical; const char *src; const char *dst; + sg_routing_edge_t gw_src; + sg_routing_edge_t gw_dst; xbt_dynar_t link_list; } s_sg_platf_route_cbarg_t; -typedef struct s_sg_platf_ASroute_cbarg *sg_platf_ASroute_cbarg_t; -typedef struct s_sg_platf_ASroute_cbarg { - int symmetrical; - const char *src; - const char *dst; - const char *gw_src; - const char *gw_dst; - xbt_dynar_t link_list; -} s_sg_platf_ASroute_cbarg_t; - -typedef struct s_sg_platf_bypassRoute_cbarg *sg_platf_bypassRoute_cbarg_t; -typedef struct s_sg_platf_bypassRoute_cbarg { - const char *src; - const char *dst; - xbt_dynar_t link_list; -} s_sg_platf_bypassRoute_cbarg_t; - -typedef struct s_sg_platf_bypassASroute_cbarg *sg_platf_bypassASroute_cbarg_t; -typedef struct s_sg_platf_bypassASroute_cbarg { - const char *src; - const char *dst; - const char *gw_src; - const char *gw_dst; - xbt_dynar_t link_list; -} s_sg_platf_bypassASroute_cbarg_t; - typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t; typedef struct s_sg_platf_cluster_cbarg { const char* id; @@ -259,9 +235,9 @@ XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route -XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_ASroute_cbarg_t ASroute); // Add an ASroute -XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_bypassRoute_cbarg_t bypassroute); // Add a bypassRoute -XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_bypassASroute_cbarg_t bypassASroute); // Add an bypassASroute +XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_route_cbarg_t ASroute); // Add an ASroute +XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute +XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_route_cbarg_t bypassASroute); // Add an bypassASroute XBT_PUBLIC(void) sg_platf_new_prop (sg_platf_prop_cbarg_t prop); // Add a prop XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace); @@ -279,10 +255,10 @@ XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process); XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route -XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_ASroute_cbarg_t ASroute); // Initialize ASroute -XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_ASroute_cbarg_t ASroute); // Finalize and add a ASroute +XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute); // Initialize ASroute +XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute); // Finalize and add a ASroute XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list -XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_ASroute_cbarg_t ASroute); // Add a link to link list +XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute); // Add a link to link list #endif /* SG_PLATF_H */ diff --git a/src/include/simgrid/platf_interface.h b/src/include/simgrid/platf_interface.h index cd158ea9b6..c7148a842a 100644 --- a/src/include/simgrid/platf_interface.h +++ b/src/include/simgrid/platf_interface.h @@ -29,9 +29,6 @@ typedef void (*sg_platf_AS_begin_cb_t)(const char*id, int routing); typedef void (*sg_platf_prop_cb_t)(sg_platf_prop_cbarg_t); typedef void (*sg_platf_route_cb_t)(sg_platf_route_cbarg_t); -typedef void (*sg_platf_ASroute_cb_t)(sg_platf_ASroute_cbarg_t); -typedef void (*sg_platf_bypassRoute_cb_t)(sg_platf_bypassRoute_cbarg_t); -typedef void (*sg_platf_bypassASroute_cb_t)(sg_platf_bypassASroute_cbarg_t); typedef void (*sg_platf_trace_cb_t)(sg_platf_trace_cbarg_t); typedef void (*sg_platf_trace_connect_cb_t)(sg_platf_trace_connect_cbarg_t); @@ -56,9 +53,9 @@ void sg_platf_AS_end_add_cb(void_f_void_t fct); void sg_platf_prop_add_cb(sg_platf_prop_cb_t fct); void sg_platf_route_add_cb(sg_platf_route_cb_t); -void sg_platf_ASroute_add_cb(sg_platf_ASroute_cb_t); -void sg_platf_bypassRoute_add_cb(sg_platf_bypassRoute_cb_t); -void sg_platf_bypassASroute_add_cb(sg_platf_bypassASroute_cb_t); +void sg_platf_ASroute_add_cb(sg_platf_route_cb_t); +void sg_platf_bypassRoute_add_cb(sg_platf_route_cb_t); +void sg_platf_bypassASroute_add_cb(sg_platf_route_cb_t); void sg_platf_trace_add_cb(sg_platf_trace_cb_t); void sg_platf_trace_connect_add_cb(sg_platf_trace_connect_cb_t); diff --git a/src/surf/sg_platf.c b/src/surf/sg_platf.c index 190d6ba020..e08135d6e4 100644 --- a/src/surf/sg_platf.c +++ b/src/surf/sg_platf.c @@ -64,9 +64,9 @@ void sg_platf_init(void) { sg_platf_prop_cb_list = xbt_dynar_new(sizeof(sg_platf_prop_cb_t),NULL); sg_platf_route_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL); - sg_platf_ASroute_cb_list = xbt_dynar_new(sizeof(sg_platf_ASroute_cb_t), NULL); - sg_platf_bypassRoute_cb_list = xbt_dynar_new(sizeof(sg_platf_bypassRoute_cb_t), NULL); - sg_platf_bypassASroute_cb_list = xbt_dynar_new(sizeof(sg_platf_bypassASroute_cb_t), NULL); + sg_platf_ASroute_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL); + sg_platf_bypassRoute_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL); + sg_platf_bypassASroute_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL); sg_platf_trace_cb_list = xbt_dynar_new(sizeof(sg_platf_trace_cb_t), NULL); sg_platf_trace_connect_cb_list = xbt_dynar_new(sizeof(sg_platf_trace_connect_cb_t), NULL); @@ -195,22 +195,22 @@ void sg_platf_new_route(sg_platf_route_cbarg_t route) { xbt_dynar_foreach(sg_platf_route_cb_list, iterator, fun) { fun(route); } -}void sg_platf_new_ASroute(sg_platf_ASroute_cbarg_t ASroute) { +}void sg_platf_new_ASroute(sg_platf_route_cbarg_t ASroute) { unsigned int iterator; - sg_platf_ASroute_cb_t fun; + sg_platf_route_cb_t fun; xbt_dynar_foreach(sg_platf_ASroute_cb_list, iterator, fun) { fun(ASroute); } } -void sg_platf_new_bypassRoute(sg_platf_bypassRoute_cbarg_t bypassRoute) { +void sg_platf_new_bypassRoute(sg_platf_route_cbarg_t bypassRoute) { unsigned int iterator; - sg_platf_bypassRoute_cb_t fun; + sg_platf_route_cb_t fun; xbt_dynar_foreach(sg_platf_bypassRoute_cb_list, iterator, fun) { fun(bypassRoute); } -}void sg_platf_new_bypassASroute(sg_platf_bypassASroute_cbarg_t bypassASroute) { +}void sg_platf_new_bypassASroute(sg_platf_route_cbarg_t bypassASroute) { unsigned int iterator; - sg_platf_bypassASroute_cb_t fun; + sg_platf_route_cb_t fun; xbt_dynar_foreach(sg_platf_bypassASroute_cb_list, iterator, fun) { fun(bypassASroute); } @@ -247,14 +247,14 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process){ void sg_platf_route_begin (sg_platf_route_cbarg_t route){ route->link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); } -void sg_platf_ASroute_begin (sg_platf_ASroute_cbarg_t ASroute){ +void sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute){ ASroute->link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); } void sg_platf_route_end (sg_platf_route_cbarg_t route){ sg_platf_new_route(route); } -void sg_platf_ASroute_end (sg_platf_ASroute_cbarg_t ASroute){ +void sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute){ sg_platf_new_ASroute(ASroute); } @@ -262,7 +262,7 @@ void sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route) char *link_name = xbt_strdup(link_id); xbt_dynar_push(route->link_list, &link_name); } -void sg_platf_ASroute_add_link (const char* link_id, sg_platf_ASroute_cbarg_t ASroute){ +void sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute){ char *link_name = xbt_strdup(link_id); xbt_dynar_push(ASroute->link_list, &link_name); } @@ -359,13 +359,13 @@ void sg_platf_mount_add_cb(sg_platf_mount_cb_t fct) { void sg_platf_route_add_cb(sg_platf_route_cb_t fct) { xbt_dynar_push(sg_platf_route_cb_list, &fct); } -void sg_platf_ASroute_add_cb(sg_platf_ASroute_cb_t fct) { +void sg_platf_ASroute_add_cb(sg_platf_route_cb_t fct) { xbt_dynar_push(sg_platf_ASroute_cb_list, &fct); } -void sg_platf_bypassRoute_add_cb(sg_platf_bypassRoute_cb_t fct) { +void sg_platf_bypassRoute_add_cb(sg_platf_route_cb_t fct) { xbt_dynar_push(sg_platf_bypassRoute_cb_list, &fct); } -void sg_platf_bypassASroute_add_cb(sg_platf_bypassASroute_cb_t fct) { +void sg_platf_bypassASroute_add_cb(sg_platf_route_cb_t fct) { xbt_dynar_push(sg_platf_bypassASroute_cb_list, &fct); } void sg_platf_prop_add_cb(sg_platf_prop_cb_t fct) { diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 12e886b15d..327195db20 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -240,22 +240,13 @@ static void parse_E_route(sg_platf_route_cbarg_t route) /** * \brief Store the ASroute by calling the set_ASroute function of the current routing component */ -static void parse_E_ASroute(sg_platf_ASroute_cbarg_t ASroute) +static void parse_E_ASroute(sg_platf_route_cbarg_t ASroute) { route_t e_route = xbt_new0(s_route_t, 1); e_route->link_list = ASroute->link_list; + e_route->src_gateway = ASroute->gw_src; + e_route->dst_gateway = ASroute->gw_dst; - if (!strcmp(current_routing->model_desc->name,"RuleBased")) { - // DIRTY PERL HACK AHEAD: with the rulebased routing, the {src,dst}_gateway fields - // store the provided name instead of the entity directly (model_rulebased_parse_ASroute knows) - // - // This is because the user will provide something like "^AS_(.*)$" instead of the proper name of a given entity - e_route->src_gateway = (sg_routing_edge_t) ASroute->gw_src; - e_route->dst_gateway = (sg_routing_edge_t) ASroute->gw_dst; - } else { - e_route->src_gateway = sg_routing_edge_by_name_or_null(ASroute->gw_src); - e_route->dst_gateway = sg_routing_edge_by_name_or_null(ASroute->gw_dst); - } xbt_assert(current_routing->parse_ASroute, "no defined method \"set_ASroute\" in \"%s\"", current_routing->name); @@ -266,7 +257,7 @@ static void parse_E_ASroute(sg_platf_ASroute_cbarg_t ASroute) /** * \brief Store the bypass route by calling the set_bypassroute function of the current routing component */ -static void parse_E_bypassRoute(sg_platf_bypassRoute_cbarg_t route) +static void parse_E_bypassRoute(sg_platf_route_cbarg_t route) { route_t e_route = xbt_new0(s_route_t, 1); e_route->link_list = route->link_list; @@ -281,12 +272,12 @@ static void parse_E_bypassRoute(sg_platf_bypassRoute_cbarg_t route) /** * \brief Store the bypass route by calling the set_bypassroute function of the current routing component */ -static void parse_E_bypassASroute(sg_platf_bypassASroute_cbarg_t ASroute) +static void parse_E_bypassASroute(sg_platf_route_cbarg_t ASroute) { route_t e_route = xbt_new0(s_route_t, 1); e_route->link_list = ASroute->link_list; - e_route->src_gateway = sg_routing_edge_by_name_or_null(ASroute->gw_src); - e_route->dst_gateway = sg_routing_edge_by_name_or_null(ASroute->gw_dst); + e_route->src_gateway = ASroute->gw_src; + e_route->dst_gateway = ASroute->gw_dst; xbt_assert(current_routing->parse_bypassroute, "Bypassing mechanism not implemented by routing '%s'", current_routing->name); diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index ad0276b143..8693579848 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -23,7 +23,7 @@ int ETag_surfxml_include_state(void); char* surf_parsed_filename = NULL; // to locate parse error messages xbt_dynar_t parsed_link_list = NULL; /* temporary store of current list link of a route */ - +extern AS_t current_routing; /* * Helping functions */ @@ -511,6 +511,8 @@ void ETag_surfxml_route(void){ route.src = A_surfxml_route_src; route.dst = A_surfxml_route_dst; + route.gw_src = NULL; + route.gw_dst = NULL; route.link_list = parsed_link_list; switch (A_surfxml_route_symmetrical) { @@ -528,13 +530,24 @@ void ETag_surfxml_route(void){ } void ETag_surfxml_ASroute(void){ - s_sg_platf_ASroute_cbarg_t ASroute; + s_sg_platf_route_cbarg_t ASroute; memset(&ASroute,0,sizeof(ASroute)); ASroute.src = A_surfxml_ASroute_src; ASroute.dst = A_surfxml_ASroute_dst; - ASroute.gw_src = A_surfxml_ASroute_gw_src; - ASroute.gw_dst = A_surfxml_ASroute_gw_dst; + + if (!strcmp(current_routing->model_desc->name,"RuleBased")) { + // DIRTY PERL HACK AHEAD: with the rulebased routing, the {src,dst}_gateway fields + // store the provided name instead of the entity directly (model_rulebased_parse_ASroute knows) + // + // This is because the user will provide something like "^AS_(.*)$" instead of the proper name of a given entity + ASroute.gw_src = (sg_routing_edge_t) A_surfxml_ASroute_gw_src; + ASroute.gw_dst = (sg_routing_edge_t) A_surfxml_ASroute_gw_dst; + } else { + ASroute.gw_src = sg_routing_edge_by_name_or_null(A_surfxml_ASroute_gw_src); + ASroute.gw_dst = sg_routing_edge_by_name_or_null(A_surfxml_ASroute_gw_dst); + } + ASroute.link_list = parsed_link_list; switch (A_surfxml_ASroute_symmetrical) { @@ -552,26 +565,40 @@ void ETag_surfxml_ASroute(void){ } void ETag_surfxml_bypassRoute(void){ - s_sg_platf_bypassRoute_cbarg_t route; + s_sg_platf_route_cbarg_t route; memset(&route,0,sizeof(route)); route.src = A_surfxml_bypassRoute_src; route.dst = A_surfxml_bypassRoute_dst; + route.gw_src = NULL; + route.gw_dst = NULL; route.link_list = parsed_link_list; + route.symmetrical = FALSE; sg_platf_new_bypassRoute(&route); parsed_link_list = NULL; } void ETag_surfxml_bypassASroute(void){ - s_sg_platf_bypassASroute_cbarg_t ASroute; + s_sg_platf_route_cbarg_t ASroute; memset(&ASroute,0,sizeof(ASroute)); ASroute.src = A_surfxml_bypassASroute_src; ASroute.dst = A_surfxml_bypassASroute_dst; - ASroute.gw_src = A_surfxml_bypassASroute_gw_src; - ASroute.gw_dst = A_surfxml_bypassASroute_gw_dst; ASroute.link_list = parsed_link_list; + ASroute.symmetrical = FALSE; + + if (!strcmp(current_routing->model_desc->name,"RuleBased")) { + // DIRTY PERL HACK AHEAD: with the rulebased routing, the {src,dst}_gateway fields + // store the provided name instead of the entity directly (model_rulebased_parse_ASroute knows) + // + // This is because the user will provide something like "^AS_(.*)$" instead of the proper name of a given entity + ASroute.gw_src = (sg_routing_edge_t) A_surfxml_bypassASroute_gw_src; + ASroute.gw_dst = (sg_routing_edge_t) A_surfxml_bypassASroute_gw_dst; + } else { + ASroute.gw_src = sg_routing_edge_by_name_or_null(A_surfxml_bypassASroute_gw_src); + ASroute.gw_dst = sg_routing_edge_by_name_or_null(A_surfxml_bypassASroute_gw_dst); + } sg_platf_new_bypassASroute(&ASroute); parsed_link_list = NULL;