Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[route parsing] kill global_routing->size_of_link
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 9 Apr 2012 01:43:28 +0000 (15:43 -1000)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 9 Apr 2012 01:47:22 +0000 (15:47 -1000)
- 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)

12 files changed:
include/simgrid/platf.h
src/instr/instr_routing.c
src/surf/network.c
src/surf/network_constant.c
src/surf/surf_private.h
src/surf/surf_routing.c
src/surf/surf_routing_dijkstra.c
src/surf/surf_routing_floyd.c
src/surf/surf_routing_full.c
src/surf/surf_routing_generic.c
src/surf/surf_routing_rulebased.c
src/surf/workstation_ptask_L07.c

index a08e6a6..383226a 100644 (file)
@@ -11,6 +11,9 @@
 
 #include <xbt.h>
 
+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,
index 7f582cb..c00078e 100644 (file)
@@ -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);
 
index c9e0a70..ed12bf7 100644 (file)
@@ -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));
index 3279f4d..f47e92f 100644 (file)
@@ -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);
 }
index 8f14772..7f4c81a 100644 (file)
@@ -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);
index 3a4fdac..7839ddf 100644 (file)
@@ -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;
 }
index 2736aa9..bcc8a22 100644 (file)
@@ -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;
index 0e770ca..6ee25f3 100644 (file)
@@ -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 *);
index 431c3d3..40c1c97 100644 (file)
@@ -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);
index e4e5e0b..143f981 100644 (file)
@@ -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,
index 2b2ab9a..11c7258 100644 (file)
@@ -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);
index d0a27e3..51c7757 100644 (file)
@@ -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,