From aea5cd54d7bc57803095a419ce5e9f1765634921 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 8 Apr 2012 15:43:28 -1000 Subject: [PATCH] [route parsing] kill global_routing->size_of_link - Actually, all links we use are pointers to structure (how surprising). This strange thing survived until now because the constant model declared to have a size of links being the size of a double. But actually, since there is no link in constant routing, we could use 0 as size of links in that case. - Also introduce a sg_routing_link_t that is simply an alias to void* for now. It is intended to represent what is stored into link_lib at the surf level (that is the core-most link concept) --- include/simgrid/platf.h | 3 +++ src/instr/instr_routing.c | 4 ++-- src/surf/network.c | 5 ++--- src/surf/network_constant.c | 2 +- src/surf/surf_private.h | 3 +-- src/surf/surf_routing.c | 7 +++---- src/surf/surf_routing_dijkstra.c | 4 ++-- src/surf/surf_routing_floyd.c | 11 +++++------ src/surf/surf_routing_full.c | 6 +++--- src/surf/surf_routing_generic.c | 4 ++-- src/surf/surf_routing_rulebased.c | 2 +- src/surf/workstation_ptask_L07.c | 3 +-- 12 files changed, 26 insertions(+), 28 deletions(-) diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index a08e6a67da..383226abc0 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -11,6 +11,9 @@ #include +typedef void *sg_routing_link_t; /* The actual type is model-dependent so use void* instead*/ + + typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */ XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new(const char *filename); XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id, diff --git a/src/instr/instr_routing.c b/src/instr/instr_routing.c index 7f582cbae5..c00078e2ab 100644 --- a/src/instr/instr_routing.c +++ b/src/instr/instr_routing.c @@ -145,7 +145,7 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t //get the route route_t route = xbt_new0(s_route_t,1); - route->link_list = xbt_dynar_new(global_routing->size_of_link,NULL); + route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); rc->get_route_and_latency(rc, child1->net_elm, child2->net_elm, route, NULL); @@ -472,7 +472,7 @@ static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xb //get the route route_t route = xbt_new0(s_route_t,1); - route->link_list = xbt_dynar_new(global_routing->size_of_link,NULL); + route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); rc->get_route_and_latency(rc, child1->net_elm, child2->net_elm, route, NULL); diff --git a/src/surf/network.c b/src/surf/network.c index c9e0a70ffb..ed12bf74a5 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -765,7 +765,7 @@ static surf_action_t net_communicate(network_element_t src, xbt_dynar_t back_route = NULL; int constraints_per_variable = 0; - xbt_dynar_t route = xbt_dynar_new(global_routing->size_of_link, NULL); + xbt_dynar_t route = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); XBT_IN("(%s,%s,%g,%g)", src->name, dst->name, size, rate); @@ -1091,8 +1091,7 @@ static void surf_network_model_init_internal(void) if (!network_maxmin_system) network_maxmin_system = lmm_system_new(net_selective_update); - routing_model_create(sizeof(link_CM02_t), - net_create_resource("__loopback__", + routing_model_create(net_create_resource("__loopback__", 498000000, NULL, 0.000015, NULL, SURF_RESOURCE_ON, NULL, SURF_LINK_FATPIPE, NULL)); diff --git a/src/surf/network_constant.c b/src/surf/network_constant.c index 3279f4d97c..f47e92f3bc 100644 --- a/src/surf/network_constant.c +++ b/src/surf/network_constant.c @@ -234,5 +234,5 @@ void surf_network_model_init_Constant() netcste_define_callbacks(); xbt_dynar_push(model_list, &surf_network_model); - routing_model_create(sizeof(double), NULL); + routing_model_create(NULL); } diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 8f147725ef..7f4c81a1b8 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -178,12 +178,11 @@ typedef struct s_as { struct s_routing_global { AS_t root; void *loopback; - size_t size_of_link; xbt_dynar_t last_route; xbt_dynar_t(*get_onelink_routes) (void); }; -XBT_PUBLIC(void) routing_model_create(size_t size_of_link, void *loopback); +XBT_PUBLIC(void) routing_model_create(void *loopback); XBT_PUBLIC(void) routing_exit(void); XBT_PUBLIC(void) storage_register_callbacks(void); XBT_PUBLIC(void) routing_register_callbacks(void); diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 3a4fdac894..7839ddfb3f 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -611,7 +611,7 @@ static void _get_route_and_latency(network_element_t src, network_element_t dst, /* Not in the same AS, no bypass. We'll have to find our path between the ASes recursively*/ - route.link_list = xbt_dynar_new(global_routing->size_of_link, NULL); + route.link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); // Find the net_card corresponding to father network_element_t src_father_net_elm = src_father->net_elem; network_element_t dst_father_net_elm = dst_father->net_elem; @@ -714,15 +714,14 @@ e_surf_network_element_type_t routing_get_network_element_type(const char *name) * * Make a global routing structure and set all the parsing functions. */ -void routing_model_create(size_t size_of_links, void *loopback) +void routing_model_create( void *loopback) { /* config the uniq global routing */ global_routing = xbt_new0(s_routing_global_t, 1); global_routing->root = NULL; global_routing->get_onelink_routes = get_onelink_routes; global_routing->loopback = loopback; - global_routing->size_of_link = size_of_links; - global_routing->last_route = xbt_dynar_new(global_routing->size_of_link,NULL); + global_routing->last_route = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); /* no current routing at moment */ current_routing = NULL; } diff --git a/src/surf/surf_routing_dijkstra.c b/src/surf/surf_routing_dijkstra.c index 2736aa9f32..bcc8a22bbc 100644 --- a/src/surf/surf_routing_dijkstra.c +++ b/src/surf/surf_routing_dijkstra.c @@ -157,7 +157,7 @@ static void add_loopback_dijkstra(as_dijkstra_t as) { if (!found) { route_t e_route = xbt_new0(s_route_t, 1); - e_route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL); + e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); xbt_dynar_push(e_route->link_list, &global_routing->loopback); xbt_graph_new_edge(as->route_graph, node, node, e_route); @@ -172,7 +172,7 @@ static xbt_dynar_t dijkstra_get_onelink_routes(AS_t as) { xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free); route_t route = xbt_new0(s_route_t,1); - route->link_list = xbt_dynar_new(global_routing->size_of_link,NULL); + route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); int src,dst; network_element_t src_elm, dst_elm; diff --git a/src/surf/surf_routing_floyd.c b/src/surf/surf_routing_floyd.c index 0e770ca26b..6ee25f3c12 100644 --- a/src/surf/surf_routing_floyd.c +++ b/src/surf/surf_routing_floyd.c @@ -33,7 +33,7 @@ static xbt_dynar_t floyd_get_onelink_routes(AS_t asg) { xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free); route_t route = xbt_new0(s_route_t, 1); - route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL); + route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); int src,dst; network_element_t src_elm, dst_elm; @@ -112,7 +112,7 @@ static void floyd_get_route_and_latency(AS_t asg, network_element_t src, network if (asg->hierarchy == SURF_ROUTING_RECURSIVE && !first && strcmp(gw_dst->name, prev_gw_src->name)) { xbt_dynar_t e_route_as_to_as; - e_route_as_to_as = xbt_dynar_new(global_routing->size_of_link, NULL); + e_route_as_to_as = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); routing_get_route_and_latency(gw_dst, prev_gw_src,&e_route_as_to_as,NULL); links = e_route_as_to_as; int pos = 0; @@ -214,8 +214,7 @@ void model_floyd_end(AS_t current_routing) e_route = xbt_new0(s_route_t, 1); e_route->src_gateway = NULL; e_route->dst_gateway = NULL; - e_route->link_list = - xbt_dynar_new(global_routing->size_of_link, NULL); + e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); xbt_dynar_push(e_route->link_list, &global_routing->loopback); TO_FLOYD_LINK(i, i) = e_route; TO_FLOYD_PRED(i, i) = i; @@ -300,7 +299,7 @@ void model_floyd_parse_route(AS_t rc, const char *src, char * link_name; unsigned int cpt; - xbt_dynar_t link_route_to_test = xbt_dynar_new(global_routing->size_of_link, NULL); + xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); xbt_dynar_foreach(route->link_list,cpt,link_name) { void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL); @@ -335,7 +334,7 @@ void model_floyd_parse_route(AS_t rc, const char *src, route->src_gateway->name, src, route->dst_gateway->name); char * link_name; unsigned int i; - xbt_dynar_t link_route_to_test = xbt_dynar_new(global_routing->size_of_link, NULL); + xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); for(i=xbt_dynar_length(route->link_list) ;i>0 ;i--) { link_name = xbt_dynar_get_as(route->link_list,i-1,void *); diff --git a/src/surf/surf_routing_full.c b/src/surf/surf_routing_full.c index 431c3d3047..40c1c97eb3 100644 --- a/src/surf/surf_routing_full.c +++ b/src/surf/surf_routing_full.c @@ -143,7 +143,7 @@ void model_full_end(AS_t current_routing) e_route = xbt_new0(s_route_t, 1); e_route->src_gateway = NULL; e_route->dst_gateway = NULL; - e_route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL); + e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); xbt_dynar_push(e_route->link_list, &global_routing->loopback); TO_ROUTE_FULL(i, i) = e_route; } @@ -185,7 +185,7 @@ void model_full_set_route(AS_t rc, const char *src, char *link_name; unsigned int i; xbt_dynar_t link_route_to_test = - xbt_dynar_new(global_routing->size_of_link, NULL); + xbt_dynar_new(sizeof(sg_routing_link_t), NULL); xbt_dynar_foreach(route->link_list, i, link_name) { void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL); xbt_assert(link, "Link : '%s' doesn't exists.", link_name); @@ -258,7 +258,7 @@ void model_full_set_route(AS_t rc, const char *src, char *link_name; unsigned int i; xbt_dynar_t link_route_to_test = - xbt_dynar_new(global_routing->size_of_link, NULL); + xbt_dynar_new(sizeof(sg_routing_link_t), NULL); for (i = xbt_dynar_length(route->link_list); i > 0; i--) { link_name = xbt_dynar_get_as(route->link_list, i - 1, void *); void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL); diff --git a/src/surf/surf_routing_generic.c b/src/surf/surf_routing_generic.c index e4e5e0bd2c..143f981451 100644 --- a/src/surf/surf_routing_generic.c +++ b/src/surf/surf_routing_generic.c @@ -214,7 +214,7 @@ route_t generic_get_bypassroute(AS_t rc, network_element_t src, network_element_ new_e_route->src_gateway = e_route_bypass->src_gateway; new_e_route->dst_gateway = e_route_bypass->dst_gateway; new_e_route->link_list = - xbt_dynar_new(global_routing->size_of_link, NULL); + xbt_dynar_new(sizeof(sg_routing_link_t), NULL); xbt_dynar_foreach(e_route_bypass->link_list, cpt, link) { xbt_dynar_push(new_e_route->link_list, &link); if (lat) @@ -237,7 +237,7 @@ generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy, unsigned int cpt; result = xbt_new0(s_route_t, 1); - result->link_list = xbt_dynar_new(global_routing->size_of_link, NULL); + result->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); xbt_assert(hierarchy == SURF_ROUTING_BASE || hierarchy == SURF_ROUTING_RECURSIVE, diff --git a/src/surf/surf_routing_rulebased.c b/src/surf/surf_routing_rulebased.c index 2b2ab9ae0f..11c7258afc 100644 --- a/src/surf/surf_routing_rulebased.c +++ b/src/surf/surf_routing_rulebased.c @@ -233,7 +233,7 @@ static xbt_dynar_t rulebased_get_onelink_routes(AS_t rc) network_element_t host = NULL; xbt_lib_foreach(as_router_lib, cursor, k1, host){ route_t route = xbt_new0(s_route_t,1); - route->link_list = xbt_dynar_new(global_routing->size_of_link,NULL); + route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); rulebased_get_route_and_latency (rc, router, host, route,NULL); int number_of_links = xbt_dynar_length(route->link_list); diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index d0a27e30e5..51c7757581 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -900,8 +900,7 @@ static void ptask_model_init_internal(void) if (!ptask_maxmin_system) ptask_maxmin_system = lmm_system_new(1); - routing_model_create(sizeof(link_L07_t), - ptask_link_create_resource("__loopback__", + routing_model_create(ptask_link_create_resource("__loopback__", 498000000, NULL, 0.000015, NULL, SURF_RESOURCE_ON, NULL, -- 2.20.1