Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
export to graphviz function in the tracing way, we need node names
authorLucas Schnorr <Lucas.Schnorr@imag.fr>
Mon, 11 Apr 2011 20:41:46 +0000 (22:41 +0200)
committerLucas Schnorr <Lucas.Schnorr@imag.fr>
Mon, 11 Apr 2011 20:41:46 +0000 (22:41 +0200)
include/instr/instr.h
src/instr/instr_interface.c
src/instr/instr_private.h
src/instr/instr_routing.c
tools/graphicator/graphicator.c

index 9551dc7..250d263 100644 (file)
@@ -26,6 +26,7 @@ XBT_PUBLIC(void) TRACE_user_host_variable(double time,
                                           double value, const char *what);
 XBT_PUBLIC(const char *) TRACE_node_name (xbt_node_t node);
 XBT_PUBLIC(xbt_graph_t) TRACE_platform_graph (void);
                                           double value, const char *what);
 XBT_PUBLIC(const char *) TRACE_node_name (xbt_node_t node);
 XBT_PUBLIC(xbt_graph_t) TRACE_platform_graph (void);
+XBT_PUBLIC(void) TRACE_platform_graph_export_graphviz (xbt_graph_t g, const char *filename);
 XBT_PUBLIC(void) TRACE_user_link_variable(double time, const char *resource,
                               const char *variable,
                               double value, const char *what);
 XBT_PUBLIC(void) TRACE_user_link_variable(double time, const char *resource,
                               const char *variable,
                               double value, const char *what);
index 33c122b..f409086 100644 (file)
@@ -160,4 +160,9 @@ xbt_graph_t TRACE_platform_graph (void)
   return instr_routing_platform_graph ();
 }
 
   return instr_routing_platform_graph ();
 }
 
+void TRACE_platform_graph_export_graphviz (xbt_graph_t g, const char *filename)
+{
+  instr_routing_platform_graph_export_graphviz (g, filename);
+}
+
 #endif /* HAVE_TRACING */
 #endif /* HAVE_TRACING */
index 2c6442b..6290b45 100644 (file)
@@ -17,6 +17,7 @@
 #include "msg/msg.h"
 #include "simdag/private.h"
 #include "simix/private.h"
 #include "msg/msg.h"
 #include "simdag/private.h"
 #include "simix/private.h"
+#include "xbt/graph_private.h"
 
 typedef enum {
   TYPE_VARIABLE,
 
 typedef enum {
   TYPE_VARIABLE,
@@ -232,6 +233,7 @@ void instr_new_user_link_variable_type  (const char *new_typename, const char *c
 void instr_new_user_host_variable_type  (const char *new_typename, const char *color);
 int instr_platform_traced (void);
 xbt_graph_t instr_routing_platform_graph (void);
 void instr_new_user_host_variable_type  (const char *new_typename, const char *color);
 int instr_platform_traced (void);
 xbt_graph_t instr_routing_platform_graph (void);
+void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename);
 
 #endif /* HAVE_TRACING */
 
 
 #endif /* HAVE_TRACING */
 
index 9ac2f97..5613849 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");
 
@@ -475,5 +476,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 */
 
index 030f7cd..571f278 100644 (file)
@@ -53,7 +53,7 @@ int main(int argc, char **argv)
   if (graph == NULL){
     XBT_INFO ("%s expects --cfg=tracing:1", argv[0]);
   }else{
   if (graph == NULL){
     XBT_INFO ("%s expects --cfg=tracing:1", argv[0]);
   }else{
-    xbt_graph_export_graphviz(graph, graphvizFile, &TRACE_node_name, NULL);
+    TRACE_platform_graph_export_graphviz (graph, graphvizFile);
     XBT_INFO ("Output is in file %s", graphvizFile);
   }
   MSG_clean();
     XBT_INFO ("Output is in file %s", graphvizFile);
   }
   MSG_clean();