Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a warning if the DAX file contains loop dependencies in the data flow
[simgrid.git] / src / simdag / sd_daxloader.c
index 5deef85..6a523ea 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (c) 2009 Da SimGrid Team.  All rights reserved.                */
+/* Copyright (c) 2009, 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -60,6 +61,11 @@ static void dax_task_free(void*task){
   SD_task_destroy(t);
 }
 
+/** @brief loads a DAX file describing a DAG
+ * 
+ * See https://confluence.pegasus.isi.edu/display/pegasus/WorkflowGenerator
+ * for more details.
+ */
 xbt_dynar_t SD_daxload(const char*filename) {
   FILE* in_file = fopen(filename,"r");
   xbt_assert1(in_file, "Unable to open \"%s\"\n", filename);
@@ -69,16 +75,16 @@ xbt_dynar_t SD_daxload(const char*filename) {
 
   result = xbt_dynar_new(sizeof(SD_task_t),dax_task_free);
   files=xbt_dict_new();
-  root_task = SD_task_create("root",NULL,0);
+  root_task = SD_task_create_comp_seq("root",NULL,0);
   xbt_dynar_push(result,&root_task);
-  end_task = SD_task_create("end",NULL,0);
+  end_task = SD_task_create_comp_seq("end",NULL,0);
 
   xbt_assert2(!dax_lex(),"Parse error in %s: %s",filename,dax__parse_err_msg());
   dax__delete_buffer(input_buffer);
   fclose(in_file);
 
   /* And now, post-process the files.
-   * We want a file task per pair of computation tasks exchanging the file. Dupplicate on need
+   * We want a file task per pair of computation tasks exchanging the file. Duplicate on need
    * Files not produced in the system are said to be produced by root task (top of DAG).
    * Files not consumed in the system are said to be consumed by end task (bottom of DAG).
    */
@@ -105,6 +111,10 @@ xbt_dynar_t SD_daxload(const char*filename) {
     } else {
       xbt_dynar_foreach(file->tasks_before,cpt1,depbefore) {
         xbt_dynar_foreach(file->tasks_after,cpt2,depafter) {
+          if (depbefore->src == depafter->dst) {
+            WARN2("File %s is produced and consumed by task %s. This loop dependency will prevent the execution of the task.",
+                file->name,depbefore->src->name);
+          }
           SD_task_t 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);
@@ -130,9 +140,11 @@ void STag_dax__adag(void) {
 }
 void STag_dax__job(void) {
   double runtime = dax_parse_double(A_dax__job_runtime);
+  char *name=bprintf("%s@%s",A_dax__job_id,A_dax__job_name);
   runtime*=4200000000.; /* Assume that timings were done on a 4.2GFlops machine. I mean, why not? */
 //  INFO3("See <job id=%s runtime=%s %.0f>",A_dax__job_id,A_dax__job_runtime,runtime);
-  current_job = SD_task_create_comp_seq(A_dax__job_id,NULL,runtime);
+  current_job = SD_task_create_comp_seq(name,NULL,runtime);
+  free(name);
   xbt_dynar_push(result,&current_job);
 
 }