Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge with master and fix conflicts
[simgrid.git] / src / simdag / sd_daxloader.c
index c44a719..29803e9 100644 (file)
@@ -8,6 +8,7 @@
 #include "simdag/simdag.h"
 #include "xbt/misc.h"
 #include "xbt/log.h"
+#include <libgen.h>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_daxparse, sd, "Parsing DAX files");
 
@@ -22,7 +23,7 @@ bool parents_are_marked(SD_task_t task);
 static void dax_parse_error(char *msg)
 {
   fprintf(stderr, "Parse error on line %d: %s\n", dax_lineno, msg);
-  abort();
+  xbt_abort();
 }
 
 static double dax_parse_double(const char *string)
@@ -36,17 +37,6 @@ static double dax_parse_double(const char *string)
   return value;
 }
 
-static int dax_parse_int(const char *string)
-{
-  int ret = 0;
-  int value;
-
-  ret = sscanf(string, "%d", &value);
-  if (ret != 1)
-    dax_parse_error(bprintf("%s is not an integer", string));
-  return value;
-}
-
 /* Ensure that transfer tasks have unique names even though a file is used
  * several times */
 
@@ -253,16 +243,6 @@ static xbt_dict_t files;
 static SD_task_t current_job;
 static SD_task_t root_task, end_task;
 
-static void dump_res()
-{
-  unsigned int cursor;
-  SD_task_t task;
-  xbt_dynar_foreach(result, cursor, task) {
-    XBT_INFO("Task %u", cursor);
-    SD_task_dump(task);
-  }
-}
-
 static void dax_task_free(void *task)
 {
   SD_task_t t = task;
@@ -324,7 +304,7 @@ xbt_dynar_t SD_daxload(const char *filename)
           const char *category = depafter->src->category;
           if (category){
             TRACE_category (category);
-            TRACE_sd_set_task_category (newfile, category);
+            TRACE_sd_set_task_category(newfile, category);
           }
         }
 #endif
@@ -340,7 +320,7 @@ xbt_dynar_t SD_daxload(const char *filename)
           const char *category = depbefore->src->category;
           if (category){
             TRACE_category (category);
-            TRACE_sd_set_task_category (newfile, category);
+            TRACE_sd_set_task_category(newfile, category);
           }
         }
 #endif
@@ -362,7 +342,7 @@ xbt_dynar_t SD_daxload(const char *filename)
             const char *category = depbefore->src->category;
             if (category){
               TRACE_category (category);
-              TRACE_sd_set_task_category (newfile, category);
+              TRACE_sd_set_task_category(newfile, category);
             }
           }
 #endif
@@ -384,8 +364,16 @@ xbt_dynar_t SD_daxload(const char *filename)
     }
   }
 
-  acyclic_graph_detail(result);
-  return result;
+  if (!acyclic_graph_detail(result)){
+    XBT_ERROR("The DAX described in %s is not a DAG. It contains a cycle.",
+              basename((char*)filename));
+    xbt_dynar_foreach(result, cpt, file)
+      SD_task_destroy(file);
+     xbt_dynar_free_container(&result);
+    return NULL;
+  } else {
+    return result;
+  }
 }
 
 void STag_dax__adag(void)