Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
new tracing option, use only onelink routes to trace platform
[simgrid.git] / src / instr / instr_routing.c
index 9ac2f97..a0a7cc3 100644 (file)
@@ -9,6 +9,7 @@
 #ifdef HAVE_TRACING
 #include "surf/surf_private.h"
 #include "surf/network_private.h"
 #ifdef HAVE_TRACING
 #include "surf/surf_private.h"
 #include "surf/network_private.h"
+#include "xbt/graph.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_routing, instr, "Tracing platform hierarchy");
 
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_routing, instr, "Tracing platform hierarchy");
 
@@ -109,6 +110,9 @@ static void recursiveGraphExtraction (routing_component_t rc, container_t contai
           strcmp (child1_name, child2_name) != 0){
 
         xbt_dynar_t route = global_routing->get_route (child1_name, child2_name);
           strcmp (child1_name, child2_name) != 0){
 
         xbt_dynar_t route = global_routing->get_route (child1_name, child2_name);
+        if (TRACE_onelink_only()){
+          if (xbt_dynar_length (route) > 1) continue;
+        }
         unsigned int cpt;
         void *link;
         container_t previous = child1;
         unsigned int cpt;
         void *link;
         container_t previous = child1;
@@ -431,6 +435,9 @@ static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xb
           strcmp (child1_name, child2_name) != 0){
 
         xbt_dynar_t route = global_routing->get_route (child1_name, child2_name);
           strcmp (child1_name, child2_name) != 0){
 
         xbt_dynar_t route = global_routing->get_route (child1_name, child2_name);
+        if (TRACE_onelink_only()){
+          if (xbt_dynar_length (route) > 1) continue;
+        }
         unsigned int cpt;
         void *link;
         xbt_node_t current, previous = new_xbt_graph_node(graph, child1_name, nodes);
         unsigned int cpt;
         void *link;
         xbt_node_t current, previous = new_xbt_graph_node(graph, child1_name, nodes);
@@ -475,5 +482,42 @@ xbt_graph_t instr_routing_platform_graph (void)
   return ret;
 }
 
   return ret;
 }
 
+void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename)
+{
+  unsigned int cursor = 0;
+  xbt_node_t node = NULL;
+  xbt_edge_t edge = NULL;
+  FILE *file = NULL;
+
+  file = fopen(filename, "w");
+  xbt_assert(file, "Failed to open %s \n", filename);
+
+  if (g->directed)
+    fprintf(file, "digraph test {\n");
+  else
+    fprintf(file, "graph test {\n");
+
+  fprintf(file, "  graph [overlap=scale]\n");
+
+  fprintf(file, "  node [shape=box, style=filled]\n");
+  fprintf(file,
+          "  node [width=.3, height=.3, style=filled, color=skyblue]\n\n");
+
+  xbt_dynar_foreach(g->nodes, cursor, node) {
+    fprintf(file, "  \"%s\";\n", TRACE_node_name(node));
+  }
+  xbt_dynar_foreach(g->edges, cursor, edge) {
+    const char *src_s = TRACE_node_name (edge->src);
+    const char *dst_s = TRACE_node_name (edge->dst);
+    if (g->directed)
+      fprintf(file, "  \"%s\" -> \"%s\";\n", src_s, dst_s);
+    else
+      fprintf(file, "  \"%s\" -- \"%s\";\n", src_s, dst_s);
+  }
+  fprintf(file, "}\n");
+  fclose(file);
+
+}
+
 #endif /* HAVE_TRACING */
 
 #endif /* HAVE_TRACING */