From 8fb370cb7b0fe8f6edcec683a27ffe6e58cb3056 Mon Sep 17 00:00:00 2001 From: navarro Date: Wed, 8 Aug 2012 10:33:54 +0200 Subject: [PATCH 1/1] Remove link_list from surf_routing.c and add it into the structure of *route and *bypassRoute --- include/simgrid/platf.h | 17 +++--------- src/include/simgrid/platf_interface.h | 2 -- src/surf/sg_platf.c | 13 --------- src/surf/surf_routing.c | 40 +++------------------------ src/surf/surfxml_parse.c | 29 +++++++++++++------ 5 files changed, 29 insertions(+), 72 deletions(-) diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index cf291f7dae..99b92f5494 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -52,12 +52,6 @@ typedef enum { SURF_LINK_FATPIPE = 0 } e_surf_link_sharing_policy_t; -typedef enum { - SURF_LINK_DIRECTION_NONE = 2, - SURF_LINK_DIRECTION_UP = 1, - SURF_LINK_DIRECTION_DOWN = 0 -} e_surf_link_ctn_direction_t; - typedef enum { SURF_TRACE_CONNECT_KIND_HOST_AVAIL = 4, SURF_TRACE_CONNECT_KIND_POWER = 3, @@ -129,17 +123,12 @@ typedef struct s_sg_platf_peer_cbarg { tmgr_trace_t state_trace; } s_sg_platf_peer_cbarg_t; -typedef struct s_sg_platf_linkctn_cbarg *sg_platf_linkctn_cbarg_t; -typedef struct s_sg_platf_linkctn_cbarg { - const char *id; - e_surf_link_ctn_direction_t direction; -} s_sg_platf_linkctn_cbarg_t; - typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t; typedef struct s_sg_platf_route_cbarg { int symmetrical; const char *src; const char *dst; + xbt_dynar_t link_list; } s_sg_platf_route_cbarg_t; typedef struct s_sg_platf_ASroute_cbarg *sg_platf_ASroute_cbarg_t; @@ -149,12 +138,14 @@ typedef struct s_sg_platf_ASroute_cbarg { 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; @@ -163,6 +154,7 @@ typedef struct s_sg_platf_bypassASroute_cbarg { 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; @@ -262,7 +254,6 @@ XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router to the currently described AS XBT_PUBLIC(void) sg_platf_new_link (sg_platf_link_cbarg_t link); // Add a link to the currently described AS -XBT_PUBLIC(void) sg_platf_new_linkctn (sg_platf_linkctn_cbarg_t linkctn); // Add a linkctn XBT_PUBLIC(void) sg_platf_new_peer (sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS diff --git a/src/include/simgrid/platf_interface.h b/src/include/simgrid/platf_interface.h index 74a96d4f90..cd158ea9b6 100644 --- a/src/include/simgrid/platf_interface.h +++ b/src/include/simgrid/platf_interface.h @@ -22,7 +22,6 @@ typedef void (*sg_platf_host_cb_t)(sg_platf_host_cbarg_t); typedef void (*sg_platf_host_link_cb_t)(sg_platf_host_link_cbarg_t); typedef void (*sg_platf_router_cb_t)(sg_platf_router_cbarg_t); typedef void (*sg_platf_link_cb_t)(sg_platf_link_cbarg_t); -typedef void (*sg_platf_linkctn_cb_t)(sg_platf_linkctn_cbarg_t); typedef void (*sg_platf_peer_cb_t)(sg_platf_peer_cbarg_t); typedef void (*sg_platf_cluster_cb_t)(sg_platf_cluster_cbarg_t); typedef void (*sg_platf_cabinet_cb_t)(sg_platf_cabinet_cbarg_t); @@ -48,7 +47,6 @@ void sg_platf_host_add_cb(sg_platf_host_cb_t); void sg_platf_host_link_add_cb(sg_platf_host_link_cb_t); void sg_platf_router_add_cb(sg_platf_router_cb_t); void sg_platf_link_add_cb(sg_platf_link_cb_t); -void sg_platf_linkctn_add_cb(sg_platf_linkctn_cb_t fct); void sg_platf_peer_add_cb(sg_platf_peer_cb_t fct); void sg_platf_cluster_add_cb(sg_platf_cluster_cb_t fct); void sg_platf_cabinet_add_cb(sg_platf_cabinet_cb_t fct); diff --git a/src/surf/sg_platf.c b/src/surf/sg_platf.c index 114c427ed6..e9eaa191fb 100644 --- a/src/surf/sg_platf.c +++ b/src/surf/sg_platf.c @@ -15,7 +15,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse); xbt_dynar_t sg_platf_host_cb_list = NULL; // of sg_platf_host_cb_t xbt_dynar_t sg_platf_host_link_cb_list = NULL; // of sg_platf_host_link_cb_t xbt_dynar_t sg_platf_link_cb_list = NULL; // of sg_platf_link_cb_t -xbt_dynar_t sg_platf_linkctn_cb_list = NULL; // of sg_platf_linkctn_cb_t xbt_dynar_t sg_platf_router_cb_list = NULL; // of sg_platf_router_cb_t xbt_dynar_t sg_platf_peer_cb_list = NULL; // of sg_platf_peer_cb_t xbt_dynar_t sg_platf_cluster_cb_list = NULL; // of sg_platf_cluster_cb_t @@ -56,7 +55,6 @@ void sg_platf_init(void) { sg_platf_host_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_link_cb_t), NULL); sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_router_cb_t), NULL); sg_platf_link_cb_list = xbt_dynar_new(sizeof(sg_platf_link_cb_t), NULL); - sg_platf_linkctn_cb_list = xbt_dynar_new(sizeof(sg_platf_linkctn_cb_t), NULL); sg_platf_peer_cb_list = xbt_dynar_new(sizeof(sg_platf_peer_cb_t), NULL); sg_platf_cluster_cb_list = xbt_dynar_new(sizeof(sg_platf_cluster_cb_t), NULL); sg_platf_cabinet_cb_list = xbt_dynar_new(sizeof(sg_platf_cabinet_cb_t), NULL); @@ -86,7 +84,6 @@ void sg_platf_exit(void) { xbt_dynar_free(&sg_platf_host_link_cb_list); xbt_dynar_free(&sg_platf_router_cb_list); xbt_dynar_free(&sg_platf_link_cb_list); - xbt_dynar_free(&sg_platf_linkctn_cb_list); xbt_dynar_free(&sg_platf_postparse_cb_list); xbt_dynar_free(&sg_platf_peer_cb_list); xbt_dynar_free(&sg_platf_cluster_cb_list); @@ -143,13 +140,6 @@ void sg_platf_new_link(sg_platf_link_cbarg_t link){ } } -void sg_platf_new_linkctn(sg_platf_linkctn_cbarg_t linkctn){ - unsigned int iterator; - sg_platf_linkctn_cb_t fun; - xbt_dynar_foreach(sg_platf_linkctn_cb_list, iterator, fun) { - fun(linkctn); - } -} void sg_platf_new_peer(sg_platf_peer_cbarg_t peer){ unsigned int iterator; sg_platf_peer_cb_t fun; @@ -310,9 +300,6 @@ void sg_platf_host_link_add_cb(sg_platf_host_link_cb_t fct) { void sg_platf_link_add_cb(sg_platf_link_cb_t fct) { xbt_dynar_push(sg_platf_link_cb_list, &fct); } -void sg_platf_linkctn_add_cb(sg_platf_linkctn_cb_t fct) { - xbt_dynar_push(sg_platf_linkctn_cb_list, &fct); -} void sg_platf_router_add_cb(sg_platf_router_cb_t fct) { xbt_dynar_push(sg_platf_router_cb_list, &fct); } diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 6abdabb0dd..3992b09897 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -60,7 +60,6 @@ routing_platf_t routing_platf = NULL; AS_t current_routing = NULL; /* global parse functions */ -xbt_dynar_t parsed_link_list = NULL; /* temporary store of current list link of a route */ extern xbt_dynar_t mount_list; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf"); @@ -227,7 +226,7 @@ static void parse_S_router(sg_platf_router_cbarg_t router) static void parse_E_route(sg_platf_route_cbarg_t route) { route_t created_route = xbt_new0(s_route_t, 1); - created_route->link_list = parsed_link_list; + created_route->link_list = route->link_list; xbt_assert(current_routing->parse_route, "no defined method \"set_route\" in \"%s\"", @@ -236,7 +235,6 @@ static void parse_E_route(sg_platf_route_cbarg_t route) current_routing->parse_route(current_routing, route->src, route->dst, created_route); generic_free_route(created_route); - parsed_link_list = NULL; } /** @@ -245,7 +243,7 @@ static void parse_E_route(sg_platf_route_cbarg_t route) static void parse_E_ASroute(sg_platf_ASroute_cbarg_t ASroute) { route_t e_route = xbt_new0(s_route_t, 1); - e_route->link_list = parsed_link_list; + e_route->link_list = ASroute->link_list; if (!strcmp(current_routing->model_desc->name,"RuleBased")) { // DIRTY PERL HACK AHEAD: with the rulebased routing, the {src,dst}_gateway fields @@ -263,7 +261,6 @@ static void parse_E_ASroute(sg_platf_ASroute_cbarg_t ASroute) current_routing->name); current_routing->parse_ASroute(current_routing, ASroute->src, ASroute->dst, e_route); generic_free_route(e_route); - parsed_link_list = NULL; } /** @@ -272,14 +269,13 @@ static void parse_E_ASroute(sg_platf_ASroute_cbarg_t ASroute) static void parse_E_bypassRoute(sg_platf_bypassRoute_cbarg_t route) { route_t e_route = xbt_new0(s_route_t, 1); - e_route->link_list = parsed_link_list; + e_route->link_list = route->link_list; xbt_assert(current_routing->parse_bypassroute, "Bypassing mechanism not implemented by routing '%s'", current_routing->name); current_routing->parse_bypassroute(current_routing, route->src, route->dst, e_route); - parsed_link_list = NULL; } /** @@ -288,39 +284,13 @@ static void parse_E_bypassRoute(sg_platf_bypassRoute_cbarg_t route) static void parse_E_bypassASroute(sg_platf_bypassASroute_cbarg_t ASroute) { route_t e_route = xbt_new0(s_route_t, 1); - e_route->link_list = parsed_link_list; + 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); xbt_assert(current_routing->parse_bypassroute, "Bypassing mechanism not implemented by routing '%s'", current_routing->name); current_routing->parse_bypassroute(current_routing, ASroute->src, ASroute->dst, e_route); - parsed_link_list = NULL; -} - -/** - * \brief Set a new link on the actual list of link for a route or ASroute from XML - */ - -static void routing_parse_link_ctn(sg_platf_linkctn_cbarg_t linkctn) -{ - char *link_id; - switch (linkctn->direction) { - case SURF_LINK_DIRECTION_NONE: - link_id = xbt_strdup(linkctn->id); - break; - case SURF_LINK_DIRECTION_UP: - link_id = bprintf("%s_UP", linkctn->id); - break; - case SURF_LINK_DIRECTION_DOWN: - link_id = bprintf("%s_DOWN", linkctn->id); - break; - } - - if(parsed_link_list == NULL) - parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); - - xbt_dynar_push(parsed_link_list, &link_id); } static void routing_parse_trace(sg_platf_trace_cbarg_t trace) @@ -1195,8 +1165,6 @@ void routing_register_callbacks() sg_platf_peer_add_cb(routing_parse_peer); sg_platf_postparse_add_cb(routing_parse_postparse); - sg_platf_linkctn_add_cb(routing_parse_link_ctn); - /* we care about the ASes while parsing the platf. Incredible, isnt it? */ sg_platf_AS_end_add_cb(routing_AS_end); sg_platf_AS_begin_add_cb(routing_AS_begin); diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 041ed3b614..79b283538a 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -22,6 +22,8 @@ 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 */ + /* * Helping functions */ @@ -437,25 +439,24 @@ void ETag_surfxml_link(void){ } void STag_surfxml_link_ctn(void){ - s_sg_platf_linkctn_cbarg_t linkctn; - memset(&linkctn,0,sizeof(linkctn)); - - linkctn.id = A_surfxml_link_ctn_id; + char *link_id; switch (A_surfxml_link_ctn_direction) { case AU_surfxml_link_ctn_direction: case A_surfxml_link_ctn_direction_NONE: - linkctn.direction = SURF_LINK_DIRECTION_NONE; + link_id = xbt_strdup(A_surfxml_link_ctn_id); break; case A_surfxml_link_ctn_direction_UP: - linkctn.direction = SURF_LINK_DIRECTION_UP; + link_id = bprintf("%s_UP", A_surfxml_link_ctn_id); break; case A_surfxml_link_ctn_direction_DOWN: - linkctn.direction = SURF_LINK_DIRECTION_DOWN; + link_id = bprintf("%s_DOWN", A_surfxml_link_ctn_id); break; } - sg_platf_new_linkctn(&linkctn); + // FIXME we should push the surf link object but it don't + // work because of model rulebased + xbt_dynar_push(parsed_link_list, &link_id); } void ETag_surfxml_backbone(void){ @@ -479,6 +480,7 @@ void STag_surfxml_route(void){ xbt_assert(strlen(A_surfxml_route_src) > 0 || strlen(A_surfxml_route_dst) > 0, "Missing end-points while defining route \"%s\"->\"%s\"", A_surfxml_route_src, A_surfxml_route_dst); + parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); } void STag_surfxml_ASroute(void){ xbt_assert(strlen(A_surfxml_ASroute_src) > 0 || strlen(A_surfxml_ASroute_dst) > 0 @@ -486,11 +488,13 @@ void STag_surfxml_ASroute(void){ "Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)", A_surfxml_ASroute_src, A_surfxml_ASroute_dst, A_surfxml_ASroute_gw_src,A_surfxml_ASroute_gw_dst); + parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); } void STag_surfxml_bypassRoute(void){ xbt_assert(strlen(A_surfxml_bypassRoute_src) > 0 || strlen(A_surfxml_bypassRoute_dst) > 0, "Missing end-points while defining bupass route \"%s\"->\"%s\"", A_surfxml_bypassRoute_src, A_surfxml_bypassRoute_dst); + parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); } void STag_surfxml_bypassASroute(void){ xbt_assert(strlen(A_surfxml_bypassASroute_src) > 0 || strlen(A_surfxml_bypassASroute_dst) > 0 @@ -498,6 +502,7 @@ void STag_surfxml_bypassASroute(void){ "Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)", A_surfxml_bypassASroute_src, A_surfxml_bypassASroute_dst, A_surfxml_bypassASroute_gw_src,A_surfxml_bypassASroute_gw_dst); + parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); } void ETag_surfxml_route(void){ @@ -506,6 +511,7 @@ void ETag_surfxml_route(void){ route.src = A_surfxml_route_src; route.dst = A_surfxml_route_dst; + route.link_list = parsed_link_list; switch (A_surfxml_route_symmetrical) { case AU_surfxml_route_symmetrical: @@ -518,6 +524,7 @@ void ETag_surfxml_route(void){ } sg_platf_new_route(&route); + parsed_link_list = NULL; } void ETag_surfxml_ASroute(void){ @@ -528,6 +535,7 @@ void ETag_surfxml_ASroute(void){ ASroute.dst = A_surfxml_ASroute_dst; ASroute.gw_src = A_surfxml_ASroute_gw_src; ASroute.gw_dst = A_surfxml_ASroute_gw_dst; + ASroute.link_list = parsed_link_list; switch (A_surfxml_ASroute_symmetrical) { case AU_surfxml_ASroute_symmetrical: @@ -540,6 +548,7 @@ void ETag_surfxml_ASroute(void){ } sg_platf_new_ASroute(&ASroute); + parsed_link_list = NULL; } void ETag_surfxml_bypassRoute(void){ @@ -548,8 +557,10 @@ void ETag_surfxml_bypassRoute(void){ route.src = A_surfxml_bypassRoute_src; route.dst = A_surfxml_bypassRoute_dst; + route.link_list = parsed_link_list; sg_platf_new_bypassRoute(&route); + parsed_link_list = NULL; } void ETag_surfxml_bypassASroute(void){ @@ -560,8 +571,10 @@ void ETag_surfxml_bypassASroute(void){ 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; sg_platf_new_bypassASroute(&ASroute); + parsed_link_list = NULL; } void ETag_surfxml_trace(void){ -- 2.20.1