Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Oops this variable is twice declared.
[simgrid.git] / src / simdag / sd_dotloader.c
index 31b9e8b946329588348c3ff5ddb2a1da1aa32c1b..1974cb86e06c77d15bb9c86b0bafdbbdfb6878bd 100644 (file)
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_dotparse, sd, "Parsing DOT files");
 
 #undef CLEANUP
-#include <cgraph.h>
+
+#ifdef HAVE_CGRAPH_H
+       #include <graphviz/cgraph.h>
+#elif HAVE_AGRAPH_H
+       #include <graphviz/agraph.h>
+#endif
 
 void dot_add_task(Agnode_t * dag_node);
 void dot_add_input_dependencies(SD_task_t current_job, Agedge_t * edge);
@@ -67,6 +72,16 @@ static void dot_task_free(void *task)
   SD_task_destroy(t);
 }
 
+static void TRACE_sd_dotloader (SD_task_t task, const char *category)
+{
+  if (category){
+    if (strlen (category) != 0){
+      TRACE_category (category);
+      TRACE_sd_set_task_category (task, category);
+    }
+  }
+}
+
 /** @brief loads a DOT file describing a DAG
  * 
  * See http://www.graphviz.org/doc/info/lang.html
@@ -104,8 +119,13 @@ xbt_dynar_t SD_dotload_FILE(FILE * in_file)
 
   Agnode_t *dag_node = NULL;
   for (dag_node = agfstnode(dag_dot); dag_node;
+       #ifdef HAVE_CGRAPH_H
        dag_node = agnxtnode(dag_dot, dag_node)) {
-    dot_add_task(dag_node);
+    #elif HAVE_AGRAPH_H
+          dag_node = agnxtnode(dag_node)) {
+       #endif
+
+  dot_add_task(dag_node);
   }
   agclose(dag_dot);
   xbt_dict_free(&jobs);
@@ -181,20 +201,33 @@ void dot_add_task(Agnode_t * dag_node)
   if (current_job == NULL) {
     current_job =
         SD_task_create_comp_seq(name, (void *) performer, runtime);
+#ifdef HAVE_TRACING
+   TRACE_sd_dotloader (current_job, agget (dag_node, (char*)"category"));
+#endif
     xbt_dict_set(jobs, name, current_job, NULL);
     xbt_dynar_push(result, &current_job);
   }
   Agedge_t *e;
   int count = 0;
-  for (e = agfstin(dag_dot, dag_node); e; e = agnxtin(dag_dot, e)) {
-    dot_add_input_dependencies(current_job, e);
-    count++;
+
+  #ifdef HAVE_CGRAPH_H
+         for (e = agfstin(dag_dot, dag_node); e; e = agnxtin(dag_dot, e)) {
+  #elif HAVE_AGRAPH_H
+         for (e = agfstin(dag_node); e; e = agnxtin(e)) {
+  #endif
+  dot_add_input_dependencies(current_job, e);
+  count++;
   }
   if (count == 0 && current_job != root_task) {
     SD_task_dependency_add(NULL, NULL, root_task, current_job);
   }
   count = 0;
-  for (e = agfstout(dag_dot, dag_node); e; e = agnxtout(dag_dot, e)) {
+  #ifdef HAVE_CGRAPH_H
+         for (e = agfstout(dag_dot, dag_node); e; e = agnxtout(dag_dot, e)) {
+  #elif HAVE_AGRAPH_H
+         for (e = agfstout(dag_node); e; e = agnxtout(e)) {
+  #endif
+
     dot_add_output_dependencies(current_job, e);
     count++;
   }
@@ -221,6 +254,9 @@ void dot_add_input_dependencies(SD_task_t current_job, Agedge_t * edge)
     file = xbt_dict_get_or_null(files, name);
     if (file == NULL) {
       file = SD_task_create_comm_e2e(name, NULL, size);
+#ifdef HAVE_TRACING
+      TRACE_sd_dotloader (file, agget (edge, (char*)"category"));
+#endif
       xbt_dict_set(files, name, file, &dot_task_free);
     } else {
       if (SD_task_get_amount(file) != size) {
@@ -256,6 +292,9 @@ void dot_add_output_dependencies(SD_task_t current_job, Agedge_t * edge)
     file = xbt_dict_get_or_null(files, name);
     if (file == NULL) {
       file = SD_task_create_comm_e2e(name, NULL, size);
+#ifdef HAVE_TRACING
+      TRACE_sd_dotloader (file, agget (edge, (char*)"category"));
+#endif
       xbt_dict_set(files, name, file, &dot_task_free);
     } else {
       if (SD_task_get_amount(file) != size) {