Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Export topology in a much more efficient way.
authorJonathan Rouzaud-Cornabas <jonathan.rouzaud-cornabas@ens-lyon.fr>
Thu, 31 Jan 2013 08:56:07 +0000 (09:56 +0100)
committerJonathan Rouzaud-Cornabas <jonathan.rouzaud-cornabas@ens-lyon.fr>
Thu, 31 Jan 2013 08:56:07 +0000 (09:56 +0100)
src/surf/instr_routing.c
src/surf/surf_private.h
src/surf/surf_routing_cluster.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_none.c
src/surf/surf_routing_private.h
src/surf/surf_routing_rulebased.c
src/surf/surf_routing_vivaldi.c

index c5fc212..285a03b 100644 (file)
@@ -160,60 +160,24 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t
     }
   }
 
-  //let's get routes
-  xbt_dict_cursor_t cursor1 = NULL, cursor2 = NULL;
-  container_t child1, child2;
-  const char *child1_name, *child2_name;
-  xbt_dict_foreach(container->children, cursor1, child1_name, child1) {
-    //if child1 is not a link, a smpi node, a msg process, a msg vm or a msg task
-    if (child1->kind == INSTR_LINK || child1->kind == INSTR_SMPI || child1->kind == INSTR_MSG_PROCESS || child1->kind == INSTR_MSG_VM || child1->kind == INSTR_MSG_TASK) continue;
-
-    xbt_dict_foreach(container->children, cursor2, child2_name, child2) {
-      //if child2 is not a link, a smpi node, a msg process, a msg vm or a msg task
-      if (child2->kind == INSTR_LINK || child2->kind == INSTR_SMPI || child2->kind == INSTR_MSG_PROCESS || child2->kind == INSTR_MSG_VM || child2->kind == INSTR_MSG_TASK) continue;
-
-      //if child1 is not child2
-      if (strcmp (child1_name, child2_name) == 0) continue;
-
-      //get the route
-      sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
-      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);
-
-      //user might want to extract a graph using routes with only one link
-      //see --cfg=tracing/onelink_only:1 or --help-tracing for details
-      if (TRACE_onelink_only() && xbt_dynar_length (route->link_list) > 1){
-        generic_free_route(route);
-        continue;
-      }
+  {
+       xbt_graph_t graph = xbt_graph_new_graph (0, NULL);
+    xbt_dict_t nodes = xbt_dict_new_homogeneous(NULL);
+    xbt_dict_t edges = xbt_dict_new_homogeneous(NULL);
+    xbt_edge_t edge = NULL;
 
-      //traverse the route connecting the containers
-      unsigned int cpt;
-      void *link;
-      container_t current, previous;
-      if (route->gw_src){
-        previous = PJ_container_get(route->gw_src->name);
-      }else{
-        previous = child1;
-      }
+    xbt_dict_cursor_t cursor = NULL;
+    char *edge_name;
 
-      xbt_dynar_foreach (route->link_list, cpt, link) {
-        //FIXME (TODO): Should have a cleaner way to get the link name
-        char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
-        current = PJ_container_get(link_name);
-        linkContainers(previous, current, filter);
-        previous = current;
-      }
-      if (route->gw_dst){
-        current = PJ_container_get(route->gw_dst->name);
-      }else{
-        current = child2;
-      }
-      linkContainers(previous, current, filter);
-      generic_free_route(route);
+    rc->get_graph(graph,nodes,edges,rc);
+    xbt_dict_foreach(edges,cursor,edge_name,edge) {
+        linkContainers(PJ_container_get(edge->src->data), PJ_container_get(edge->dst->data), filter);
     }
+    xbt_dict_free (&nodes);
+    xbt_dict_free (&edges);
+    xbt_graph_free_graph(graph,xbt_free, xbt_free, NULL);
   }
+
 }
 
 /*
@@ -498,41 +462,6 @@ int instr_platform_traced ()
 #define GRAPHICATOR_SUPPORT_FUNCTIONS
 
 
-static xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes)
-{
-  xbt_node_t ret = xbt_dict_get_or_null (nodes, name);
-  if (ret) return ret;
-
-  ret = xbt_graph_new_node (graph, xbt_strdup(name));
-  xbt_dict_set (nodes, name, ret, NULL);
-  return ret;
-}
-
-static xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges)
-{
-  xbt_edge_t ret;
-
-  const char *sn = instr_node_name (s);
-  const char *dn = instr_node_name (d);
-  int len = strlen(sn)+strlen(dn)+1;
-  char *name = (char*)xbt_malloc(len * sizeof(char));
-
-
-  snprintf (name, len, "%s%s", sn, dn);
-  ret = xbt_dict_get_or_null (edges, name);
-  if (ret == NULL){
-    snprintf (name, len, "%s%s", dn, sn);
-    ret = xbt_dict_get_or_null (edges, name);
-  }
-
-  if (ret == NULL){
-    ret = xbt_graph_new_edge(graph, s, d, NULL);
-    xbt_dict_set (edges, name, ret, NULL);
-  }
-  free (name);
-  return ret;
-}
-
 static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges,
     AS_t rc, container_t container)
 {
@@ -547,58 +476,7 @@ static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xb
     }
   }
 
-  //let's get routes
-  xbt_dict_cursor_t cursor1 = NULL, cursor2 = NULL;
-  container_t child1, child2;
-  const char *child1_name, *child2_name;
-  xbt_dict_foreach(container->children, cursor1, child1_name, child1) {
-    //if child1 is not a link, a smpi node, a msg process, a msg vm or a msg task
-    if (child1->kind == INSTR_LINK || child1->kind == INSTR_SMPI || child1->kind == INSTR_MSG_PROCESS || child1->kind == INSTR_MSG_VM || child1->kind == INSTR_MSG_TASK) continue;
-
-    xbt_dict_foreach(container->children, cursor2, child2_name, child2) {
-      //if child2 is not a link, a smpi node, a msg process or a msg task
-      if (child2->kind == INSTR_LINK || child2->kind == INSTR_SMPI || child2->kind == INSTR_MSG_PROCESS || child2->kind == INSTR_MSG_VM || child2->kind == INSTR_MSG_TASK) continue;
-
-      //if child1 is not child2
-      if (strcmp (child1_name, child2_name) == 0) continue;
-
-      //get the route
-      sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
-      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);
-
-      //user might want to extract a graph using routes with only one link
-      //see --cfg=tracing/onelink_only:1 or --help-tracing for details
-      if (TRACE_onelink_only() && xbt_dynar_length (route->link_list) > 1) continue;
-
-      //traverse the route connecting the containers
-      unsigned int cpt;
-      void *link;
-      xbt_node_t current, previous;
-      if (route->gw_src){
-        previous = new_xbt_graph_node(graph, route->gw_src->name, nodes);
-      }else{
-        previous = new_xbt_graph_node(graph, child1_name, nodes);
-      }
-
-      xbt_dynar_foreach (route->link_list, cpt, link) {
-        char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
-        current = new_xbt_graph_node(graph, link_name, nodes);
-        new_xbt_graph_edge (graph, previous, current, edges);
-        //previous -> current
-        previous = current;
-      }
-      if (route->gw_dst){
-        current = new_xbt_graph_node(graph, route->gw_dst->name, nodes);
-      }else{
-        current = new_xbt_graph_node(graph, child2_name, nodes);
-      }
-      new_xbt_graph_edge (graph, previous, current, edges);
-      generic_free_route(route);
-    }
-  }
-
+  rc->get_graph(graph,nodes,edges,rc);
 }
 
 xbt_graph_t instr_routing_platform_graph (void)
index 4732aa3..c01d50b 100644 (file)
@@ -153,6 +153,7 @@ typedef struct s_as {
   void (*get_route_and_latency) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, sg_platf_route_cbarg_t into, double *latency);
 
   xbt_dynar_t(*get_onelink_routes) (AS_t as);
+  void (*get_graph) (xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, AS_t rc);
   sg_platf_route_cbarg_t(*get_bypass_route) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat);
   void (*finalize) (AS_t as);
 
@@ -192,6 +193,7 @@ XBT_PUBLIC(void) generic_free_route(sg_platf_route_cbarg_t route); // FIXME rena
 XBT_PUBLIC(void) routing_get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst,
                               xbt_dynar_t * route, double *latency);
 
+XBT_PUBLIC(void) generic_get_graph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, AS_t rc);
 /**
  * Resource protected methods
  */
index 37f2e32..d30c073 100644 (file)
@@ -4,6 +4,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 #include "surf_routing_private.h"
+#include "xbt/graph.h"
 
 /* Global vars */
 
@@ -15,40 +16,130 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf"
 
 /* Business methods */
 static void cluster_get_route_and_latency(AS_t as,
-    sg_routing_edge_t src, sg_routing_edge_t dst,
-    sg_platf_route_cbarg_t route, double *lat) {
+                                          sg_routing_edge_t src,
+                                          sg_routing_edge_t dst,
+                                          sg_platf_route_cbarg_t route,
+                                          double *lat)
+{
 
-      s_surf_parsing_link_up_down_t info;
-    XBT_DEBUG("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]",
-        src->name,src->id,
-        dst->name,dst->id);
-
-    if(src->rc_type != SURF_NETWORK_ELEMENT_ROUTER){ // No specific link for router
-        info = xbt_dynar_get_as(as->link_up_down_list,src->id,s_surf_parsing_link_up_down_t);
-        if(info.link_up) { // link up
-          xbt_dynar_push_as(route->link_list,void*,info.link_up);
-        if (lat)
-          *lat += surf_network_model->extension.network.get_link_latency(info.link_up);
-        }
+  s_surf_parsing_link_up_down_t info;
+  XBT_DEBUG("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]",
+            src->name, src->id, dst->name, dst->id);
+
+  if (src->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {    // No specific link for router
+    info =
+        xbt_dynar_get_as(as->link_up_down_list, src->id,
+                         s_surf_parsing_link_up_down_t);
+    if (info.link_up) {         // link up
+      xbt_dynar_push_as(route->link_list, void *, info.link_up);
+      if (lat)
+        *lat +=
+            surf_network_model->extension.network.get_link_latency(info.
+                                                                   link_up);
     }
+  }
+
+  if (((as_cluster_t) as)->backbone) {
+    xbt_dynar_push_as(route->link_list, void *, ((as_cluster_t) as)->backbone);
+    if (lat)
+      *lat +=
+          surf_network_model->extension.network.
+          get_link_latency(((as_cluster_t) as)->backbone);
+  }
 
-    if ( ((as_cluster_t)as)->backbone ) {
-      xbt_dynar_push_as(route->link_list,void*, ((as_cluster_t)as)->backbone) ;
+  if (dst->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {    // No specific link for router
+    info =
+        xbt_dynar_get_as(as->link_up_down_list, dst->id,
+                         s_surf_parsing_link_up_down_t);
+    if (info.link_down) {       // link down
+      xbt_dynar_push_as(route->link_list, void *, info.link_down);
       if (lat)
-        *lat += surf_network_model->extension.network.get_link_latency(((as_cluster_t)as)->backbone);
+        *lat +=
+            surf_network_model->extension.network.get_link_latency(info.
+                                                                   link_down);
     }
+  }
+}
+
+static void cluster_get_graph(xbt_graph_t graph, xbt_dict_t nodes,
+                              xbt_dict_t edges, AS_t rc)
+{
+  int isrc = 0, idst;
+  int table_size = xbt_dynar_length(rc->index_network_elm);
+
+  sg_routing_edge_t src, dst;
+  xbt_node_t current, previous, revCurrent, revPrevious;
+
+  for (isrc = 0; isrc < table_size; isrc++) {
+    src = xbt_dynar_get_as(rc->index_network_elm, isrc, sg_routing_edge_t);
+
+    previous = new_xbt_graph_node(graph, src->name, nodes);
+    revPrevious = new_xbt_graph_node(graph, src->name, nodes);
+
+    for (idst = isrc + 1; idst < table_size; idst++) {
+      dst = xbt_dynar_get_as(rc->index_network_elm, idst, sg_routing_edge_t);
 
-    if(dst->rc_type != SURF_NETWORK_ELEMENT_ROUTER){ // No specific link for router
-        info = xbt_dynar_get_as(as->link_up_down_list,dst->id,s_surf_parsing_link_up_down_t);
-        if(info.link_down) { // link down
-          xbt_dynar_push_as(route->link_list,void*,info.link_down);
-        if (lat)
-          *lat += surf_network_model->extension.network.get_link_latency(info.link_down);
+      sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
+      route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+      rc->get_route_and_latency(rc, src, dst, route, NULL);
+
+      s_surf_parsing_link_up_down_t info;
+
+      if (src->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {        // No specific link for router
+        info =
+            xbt_dynar_get_as(rc->link_up_down_list, src->id,
+                             s_surf_parsing_link_up_down_t);
+
+        if (info.link_up) {     // link up
+          char *link_name = ((surf_resource_t) info.link_up)->name;
+          current = new_xbt_graph_node(graph, link_name, nodes);
+          new_xbt_graph_edge(graph, previous, current, edges);
+          previous = current;
+        } else if (info.link_down) {    // link down
+          char *link_name = ((surf_resource_t) info.link_down)->name;
+          revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+          new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+          revPrevious = revCurrent;
+        }
+      }
+
+      if (((as_cluster_t) rc)->backbone) {
+        char *link_name =
+            ((surf_resource_t) ((as_cluster_t) rc)->backbone)->name;
+
+        current = new_xbt_graph_node(graph, link_name, nodes);
+        new_xbt_graph_edge(graph, previous, current, edges);
+        previous = current;
+
+        revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+        new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+        revPrevious = revCurrent;
+      }
+
+      if (dst->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {        // No specific link for router
+        info =
+            xbt_dynar_get_as(rc->link_up_down_list, dst->id,
+                             s_surf_parsing_link_up_down_t);
+
+        if (info.link_up) {     // link up
+          char *link_name = ((surf_resource_t) info.link_up)->name;
+          current = new_xbt_graph_node(graph, link_name, nodes);
+          new_xbt_graph_edge(graph, previous, current, edges);
+          previous = current;
+        } else if (info.link_down) {    // link down
+          char *link_name = ((surf_resource_t) info.link_down)->name;
+          revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+          new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+          revPrevious = revCurrent;
         }
+      }
+
     }
+  }
 }
 
-static void model_cluster_finalize(AS_t as) {
+static void model_cluster_finalize(AS_t as)
+{
   model_none_finalize(as);
 }
 
@@ -70,6 +161,7 @@ AS_t model_cluster_create(void)
   AS_t result = model_none_create_sized(sizeof(s_as_cluster_t));
   result->get_route_and_latency = cluster_get_route_and_latency;
   result->finalize = model_cluster_finalize;
+  result->get_graph = cluster_get_graph;
   result->parse_AS = cluster_parse_AS;
   result->parse_PU = cluster_parse_PU;
 
index 7d7eac4..4b0d4c9 100644 (file)
@@ -156,8 +156,7 @@ static void add_loopback_dijkstra(as_dijkstra_t as) {
     if (!found) {
       sg_platf_route_cbarg_t e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
       e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
-      xbt_dynar_push(e_route->link_list,
-          &routing_platf->loopback);
+      xbt_dynar_push(e_route->link_list, &routing_platf->loopback);
       xbt_graph_new_edge(as->route_graph, node, node, e_route);
     }
   }
@@ -420,6 +419,7 @@ AS_t model_dijkstra_both_create(int cached)
   new_component->generic_routing.get_route_and_latency = dijkstra_get_route_and_latency;
   new_component->generic_routing.get_onelink_routes =
       dijkstra_get_onelink_routes;
+  new_component->generic_routing.get_graph = generic_get_graph;
   new_component->generic_routing.finalize = dijkstra_finalize;
   new_component->cached = cached;
 
index 5bce7d4..0f08c52 100644 (file)
@@ -146,6 +146,7 @@ AS_t model_floyd_create(void)
   new_component->generic_routing.get_route_and_latency = floyd_get_route_and_latency;
   new_component->generic_routing.get_onelink_routes =
       floyd_get_onelink_routes;
+  new_component->generic_routing.get_graph = generic_get_graph;
   new_component->generic_routing.finalize = floyd_finalize;
   return (AS_t)new_component;
 }
index 71cdfc6..0fb3422 100644 (file)
@@ -115,6 +115,8 @@ AS_t model_full_create(void)
   new_component->generic_routing.parse_ASroute = model_full_set_route;
   new_component->generic_routing.get_route_and_latency =
       full_get_route_and_latency;
+  new_component->generic_routing.get_graph = generic_get_graph;
+
   new_component->generic_routing.get_onelink_routes = full_get_onelink_routes;
   new_component->generic_routing.finalize = full_finalize;
 
index 177c092..e6192c6 100644 (file)
@@ -9,6 +9,7 @@
 #include "surf_routing_private.h"
 #include "surf/surf_routing.h"
 #include "surf/surfxml_parse_values.h"
+#include "xbt/graph.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing");
 
@@ -91,11 +92,109 @@ xbt_dynar_t generic_get_onelink_routes(AS_t rc) { // FIXME: kill that stub
   return NULL;
 }
 
-sg_platf_route_cbarg_t generic_get_bypassroute(AS_t rc, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat)
+static const char *instr_node_name(xbt_node_t node)
+{
+  void *data = xbt_graph_node_get_data(node);
+  char *str = (char *) data;
+  return str;
+}
+
+xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name,
+                              xbt_dict_t nodes)
+{
+  xbt_node_t ret = xbt_dict_get_or_null(nodes, name);
+  if (ret)
+    return ret;
+
+  ret = xbt_graph_new_node(graph, xbt_strdup(name));
+  xbt_dict_set(nodes, name, ret, NULL);
+  return ret;
+}
+
+xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d,
+                              xbt_dict_t edges)
+{
+  xbt_edge_t ret;
+
+  const char *sn = instr_node_name(s);
+  const char *dn = instr_node_name(d);
+  int len = strlen(sn) + strlen(dn) + 1;
+  char *name = (char *) xbt_malloc(len * sizeof(char));
+
+
+  snprintf(name, len, "%s%s", sn, dn);
+  ret = xbt_dict_get_or_null(edges, name);
+  if (ret == NULL) {
+    snprintf(name, len, "%s%s", dn, sn);
+    ret = xbt_dict_get_or_null(edges, name);
+  }
+
+  if (ret == NULL) {
+    ret = xbt_graph_new_edge(graph, s, d, NULL);
+    xbt_dict_set(edges, name, ret, NULL);
+  }
+  free(name);
+  return ret;
+}
+
+void generic_get_graph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges,
+                       AS_t rc)
+{
+  int src, dst;
+  int table_size = xbt_dynar_length(rc->index_network_elm);
+
+  sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
+  route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+
+  for (src = 0; src < table_size; src++) {
+    sg_routing_edge_t my_src =
+        xbt_dynar_get_as(rc->index_network_elm, src, sg_routing_edge_t);
+    for (dst = 0; dst < table_size; dst++) {
+      if (src == dst)
+        continue;
+      sg_routing_edge_t my_dst =
+          xbt_dynar_get_as(rc->index_network_elm, dst, sg_routing_edge_t);
+
+      rc->get_route_and_latency(rc, my_src, my_dst, route, NULL);
+
+      if (route) {
+        unsigned int cpt;
+        void *link;
+
+        xbt_node_t current, previous;
+
+        if (route->gw_src) {
+          previous = new_xbt_graph_node(graph, route->gw_src->name, nodes);
+        } else {
+          previous = new_xbt_graph_node(graph, my_src->name, nodes);
+        }
+
+        xbt_dynar_foreach(route->link_list, cpt, link) {
+          char *link_name = ((surf_resource_t) link)->name;
+          current = new_xbt_graph_node(graph, link_name, nodes);
+          new_xbt_graph_edge(graph, previous, current, edges);
+          previous = current;
+        }
+
+        if (route->gw_dst) {
+          current = new_xbt_graph_node(graph, route->gw_dst->name, nodes);
+        } else {
+          current = new_xbt_graph_node(graph, my_dst->name, nodes);
+        }
+        new_xbt_graph_edge(graph, previous, current, edges);
+
+      }
+    }
+  }
+}
+
+sg_platf_route_cbarg_t generic_get_bypassroute(AS_t rc, sg_routing_edge_t src,
+                                               sg_routing_edge_t dst,
+                                               double *lat)
 {
   // If never set a bypass route return NULL without any further computations
-  XBT_DEBUG("generic_get_bypassroute from %s to %s",src->name,dst->name);
-  if(no_bypassroute_declared)
+  XBT_DEBUG("generic_get_bypassroute from %s to %s", src->name, dst->name);
+  if (no_bypassroute_declared)
     return NULL;
 
   sg_platf_route_cbarg_t e_route_bypass = NULL;
index 1f403c8..46d667b 100644 (file)
@@ -18,6 +18,11 @@ static void none_get_route_and_latency(AS_t rc, sg_routing_edge_t src, sg_routin
   *lat = 0.0;
 }
 
+static void none_get_graph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, AS_t rc)
+{
+       XBT_INFO("No routing no graph");
+}
+
 static sg_platf_route_cbarg_t none_get_bypass_route(AS_t rc,
     sg_routing_edge_t src,
     sg_routing_edge_t dst, double *lat) {
@@ -53,6 +58,7 @@ AS_t model_none_create_sized(size_t childsize) {
   new_component->get_onelink_routes = none_get_onelink_routes;
   new_component->get_bypass_route = none_get_bypass_route;
   new_component->finalize = model_none_finalize;
+  new_component->get_graph = none_get_graph;
   new_component->routing_sons = xbt_dict_new_homogeneous(NULL);
   new_component->index_network_elm = xbt_dynar_new(sizeof(char*),NULL);
 
index cdc5fb4..ac4cbe3 100644 (file)
@@ -57,7 +57,6 @@ generic_processing_units_exist(AS_t rc, char *element);
 void generic_src_dst_check(AS_t rc, sg_routing_edge_t src,
     sg_routing_edge_t dst);
 
-
 /* ************************************************************************** */
 /* *************************** FLOYD ROUTING ******************************** */
 AS_t model_floyd_create(void);  /* create structures for floyd routing model */
@@ -98,6 +97,10 @@ AS_t model_full_create(void);   /* create structures for full routing model */
 void model_full_end(AS_t as);       /* finalize the creation of full routing model */
 void model_full_set_route(  /* Set the route and ASroute between src and dst */
     AS_t rc, sg_platf_route_cbarg_t route);
+/* ************************************************************************** */
+/* ************************* GRAPH EXPORTING FUNCTIONS ********************** */
+xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes);
+xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges);
 
 
 #endif                          /* _SURF_SURF_ROUTING_PRIVATE_H */
index 53d87be..2c69fc9 100644 (file)
@@ -64,14 +64,14 @@ static void rule_route_extended_free(void *e)
 static int model_rulebased_parse_PU(AS_t rc, sg_routing_edge_t elm)
 {
   AS_rulebased_t routing = (AS_rulebased_t) rc;
-  xbt_dynar_push(routing->generic_routing.index_network_elm,(void *)elm);
+  xbt_dynar_push(routing->generic_routing.index_network_elm,&elm);
   return -1;
 }
 
 static int model_rulebased_parse_AS(AS_t rc, sg_routing_edge_t elm)
 {
   AS_rulebased_t routing = (AS_rulebased_t) rc;
-  xbt_dynar_push(routing->generic_routing.index_network_elm,(void *)elm);
+  xbt_dynar_push(routing->generic_routing.index_network_elm,&elm);
   return -1;
 }
 
@@ -394,6 +394,7 @@ AS_t model_rulebased_create(void) {
   new_component->generic_routing.get_onelink_routes = rulebased_get_onelink_routes;
   new_component->generic_routing.get_route_and_latency = rulebased_get_route_and_latency;
   new_component->generic_routing.get_bypass_route = rulebased_get_bypass_route;
+  new_component->generic_routing.get_graph = generic_get_graph;
   new_component->generic_routing.finalize = rulebased_finalize;
   /* initialization of internal structures */
   new_component->list_route = xbt_dynar_new(sizeof(rule_route_t), &rule_route_free);
index 2079a80..ed8a80c 100644 (file)
@@ -105,5 +105,6 @@ AS_t model_vivaldi_create(void)
   AS_t new_component = model_rulebased_create();
   new_component->get_route_and_latency = vivaldi_get_route_and_latency;
   new_component->parse_PU = vivaldi_parse_PU;
+  new_component->get_graph = generic_get_graph;
   return new_component;
 }