Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Regenerate all flexml parsers with 1.9.6-4
[simgrid.git] / src / simdag / sd_daxloader.cpp
index c1b80d2..6cee84c 100644 (file)
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_daxparse, sd, "Parsing DAX files");
 
 extern "C" {
-       #undef CLEANUP
-       #include "dax_dtd.h"
-       #include "dax_dtd.c"
+  #undef CLEANUP
+  #include "dax_dtd.h"
+  #define register /* g++ don't like register, so don't say it */
+  #include "dax_dtd.c"
+  #undef register
 }
 
 bool children_are_marked(SD_task_t task);
 bool parents_are_marked(SD_task_t task);
 
 /* Parsing helpers */
-static void dax_parse_error(char *msg)
-{
-  fprintf(stderr, "Parse error on line %d: %s\n", dax_lineno, msg);
-  xbt_abort();
-}
 
 static double dax_parse_double(const char *string)
 {
@@ -34,13 +31,11 @@ static double dax_parse_double(const char *string)
   double value;
 
   ret = sscanf(string, "%lg", &value);
-  if (ret != 1)
-    dax_parse_error(bprintf("%s is not a double", string));
+  xbt_assert (ret == 1, "Parse error on line %d: %s is not a double", dax_lineno, string);
   return value;
 }
 
-/* Ensure that transfer tasks have unique names even though a file is used
- * several times */
+/* Ensure that transfer tasks have unique names even though a file is used several times */
 
 void uniq_transfer_task_name(SD_task_t task)
 {
@@ -54,9 +49,7 @@ void uniq_transfer_task_name(SD_task_t task)
   xbt_dynar_get_cpy(children, 0, &child);
   xbt_dynar_get_cpy(parents, 0, &parent);
 
-  new_name = bprintf("%s_%s_%s",
-                     SD_task_get_name(parent),
-                     SD_task_get_name(task), SD_task_get_name(child));
+  new_name = bprintf("%s_%s_%s", SD_task_get_name(parent), SD_task_get_name(task), SD_task_get_name(child));
 
   SD_task_set_name(task, new_name);
 
@@ -252,8 +245,7 @@ static void dax_task_free(void *task)
 
 /** @brief loads a DAX file describing a DAG
  * 
- * See https://confluence.pegasus.isi.edu/display/pegasus/WorkflowGenerator
- * for more details.
+ * See https://confluence.pegasus.isi.edu/display/pegasus/WorkflowGenerator for more details.
  */
 xbt_dynar_t SD_daxload(const char *filename)
 {
@@ -271,7 +263,7 @@ xbt_dynar_t SD_daxload(const char *filename)
   jobs = xbt_dict_new_homogeneous(NULL);
   root_task = SD_task_create_comp_seq("root", NULL, 0);
   /* by design the root task is always SCHEDULABLE */
-  __SD_task_set_state(root_task, SD_SCHEDULABLE);
+  SD_task_set_state(root_task, SD_SCHEDULABLE);
 
   xbt_dynar_push(result, &root_task);
   end_task = SD_task_create_comp_seq("end", NULL, 0);
@@ -299,13 +291,6 @@ xbt_dynar_t SD_daxload(const char *filename)
         newfile = SD_task_create_comm_e2e(file->name, NULL, file->amount);
         SD_task_dependency_add(NULL, NULL, root_task, newfile);
         SD_task_dependency_add(NULL, NULL, newfile, depafter->dst);
-        if (depafter->src){
-          const char *category = depafter->src->category;
-          if (category){
-            TRACE_category (category);
-            TRACE_sd_set_task_category(newfile, category);
-          }
-        }
         xbt_dynar_push(result, &newfile);
       }
     } else if (xbt_dynar_is_empty(file->tasks_after)) {
@@ -313,13 +298,6 @@ xbt_dynar_t SD_daxload(const char *filename)
         newfile = SD_task_create_comm_e2e(file->name, NULL, file->amount);
         SD_task_dependency_add(NULL, NULL, depbefore->src, newfile);
         SD_task_dependency_add(NULL, NULL, newfile, end_task);
-        if (depbefore->src){
-          const char *category = depbefore->src->category;
-          if (category){
-            TRACE_category (category);
-            TRACE_sd_set_task_category(newfile, category);
-          }
-        }
         xbt_dynar_push(result, &newfile);
       }
     } else {
@@ -327,19 +305,12 @@ xbt_dynar_t SD_daxload(const char *filename)
         xbt_dynar_foreach(file->tasks_after, cpt2, depafter) {
           if (depbefore->src == depafter->dst) {
             XBT_WARN
-                ("File %s is produced and consumed by task %s. This loop dependency will prevent the execution of the task.",
-                 file->name, depbefore->src->name);
+                ("File %s is produced and consumed by task %s."
+                 "This loop dependency will prevent the execution of the task.", file->name, depbefore->src->name);
           }
           newfile = SD_task_create_comm_e2e(file->name, NULL, file->amount);
           SD_task_dependency_add(NULL, NULL, depbefore->src, newfile);
           SD_task_dependency_add(NULL, NULL, newfile, depafter->dst);
-          if (depbefore->src){
-            const char *category = depbefore->src->category;
-            if (category){
-              TRACE_category (category);
-              TRACE_sd_set_task_category(newfile, category);
-            }
-          }
           xbt_dynar_push(result, &newfile);
         }
       }
@@ -369,11 +340,10 @@ xbt_dynar_t SD_daxload(const char *filename)
   }
 
   if (!acyclic_graph_detail(result)){
-    XBT_ERROR("The DAX described in %s is not a DAG. It contains a cycle.", 
-             xbt_basename(filename));
+    XBT_ERROR("The DAX described in %s is not a DAG. It contains a cycle.", xbt_basename(filename));
     xbt_dynar_foreach(result, cpt, file)
       SD_task_destroy(file);
-     xbt_dynar_free_container(&result);
+    xbt_dynar_free_container(&result);
     return NULL;
   } else {
     return result;
@@ -385,9 +355,7 @@ void STag_dax__adag(void)
   XBT_ATTRIB_UNUSED double version;
   version = dax_parse_double(A_dax__adag_version);
 
-  xbt_assert(version == 2.1,
-              "Expected version 2.1 in <adag> tag, got %f. Fix the parser or your file",
-              version);
+  xbt_assert(version == 2.1, "Expected version 2.1 in <adag> tag, got %f. Fix the parser or your file", version);
 }
 
 void STag_dax__job(void)
@@ -397,11 +365,6 @@ void STag_dax__job(void)
   runtime *= 4200000000.;       /* Assume that timings were done on a 4.2GFlops machine. I mean, why not? */
 //  XBT_INFO("See <job id=%s runtime=%s %.0f>",A_dax__job_id,A_dax__job_runtime,runtime);
   current_job = SD_task_create_comp_seq(name, NULL, runtime);
-  char *category = A_dax__job_name;
-  if (category){
-    TRACE_category (category);
-    TRACE_sd_set_task_category(current_job, category);
-  }
   xbt_dict_set(jobs, A_dax__job_id, current_job, NULL);
   free(name);
   xbt_dynar_push(result, &current_job);
@@ -417,11 +380,11 @@ void STag_dax__uses(void)
   file = (SD_task_t)xbt_dict_get_or_null(files, A_dax__uses_file);
   if (file == NULL) {
     file = SD_task_create_comm_e2e(A_dax__uses_file, NULL, size);
+    xbt_dynar_pop(sd_global->initial_task_set,NULL);
     xbt_dict_set(files, A_dax__uses_file, file, NULL);
   } else {
     if (SD_task_get_amount(file) != size) {
-      XBT_WARN("Ignoring file %s size redefinition from %.0f to %.0f",
-            A_dax__uses_file, SD_task_get_amount(file), size);
+      XBT_WARN("Ignore file %s size redefinition from %.0f to %.0f", A_dax__uses_file, SD_task_get_amount(file), size);
     }
   }
   if (is_input) {
@@ -438,10 +401,8 @@ static SD_task_t current_child;
 void STag_dax__child(void)
 {
   current_child = (SD_task_t)xbt_dict_get_or_null(jobs, A_dax__child_ref);
-  if (current_child == NULL)
-    dax_parse_error(bprintf
-                    ("Asked to add dependencies to the non-existent %s task",
-                     A_dax__child_ref));
+  xbt_assert(current_child != NULL,"Parse error on line %d: Asked to add dependencies to the non-existent %s task",
+             dax_lineno, A_dax__child_ref);
 }
 
 void ETag_dax__child(void)
@@ -452,14 +413,10 @@ void ETag_dax__child(void)
 void STag_dax__parent(void)
 {
   SD_task_t parent = (SD_task_t)xbt_dict_get_or_null(jobs, A_dax__parent_ref);
-  if (parent == NULL)
-    dax_parse_error(bprintf
-                    ("Asked to add a dependency from %s to %s, but %s does not exist",
-                     current_child->name, A_dax__parent_ref,
-                     A_dax__parent_ref));
+  xbt_assert(parent != NULL, "Parse error on line %d: Asked to add a dependency from %s to %s, but %s does not exist",
+             dax_lineno, current_child->name, A_dax__parent_ref, A_dax__parent_ref);
   SD_task_dependency_add(NULL, NULL, parent, current_child);
-  XBT_DEBUG("Control-flow dependency from %s to %s", current_child->name,
-         parent->name);
+  XBT_DEBUG("Control-flow dependency from %s to %s", current_child->name, parent->name);
 }
 
 void ETag_dax__adag(void)