Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
bugfixes to make the dax loader and typed task scheduler work
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 7 Oct 2009 10:06:13 +0000 (10:06 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 7 Oct 2009 10:06:13 +0000 (10:06 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6735 48e7efb5-ca39-0410-a469-dd3cf9ba447f

ChangeLog
examples/simdag/dax/dax_test.c
include/simdag/simdag.h
src/simdag/sd_daxloader.c
src/simdag/sd_task.c

index 448d0c7..a532634 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -73,7 +73,9 @@ SimGrid (3.3.4) unstable; urgency=low
     SD_task_get_parents(task) and SD_task_get_children(task)
  * Add getters on amount of workstations and list:
     SD_task_get_workstation_count(t) and SD_task_get_workstation_list(t)
+ * Add getter on task kind: SD_task_get_kind(task)
  * Update the start_time and finish_time of tasks on completion/failure
+ * Bugfix: Remove task from state swags when destroyed
 
    
  Bug fixes:
index 9a97ff9..05c9b58 100644 (file)
@@ -9,6 +9,7 @@
 #include <stdio.h>
 #include "simdag/simdag.h"
 #include "xbt/log.h"
+#include "xbt/ex.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(test,
                              "Logging specific to this SimDag example");
@@ -36,6 +37,7 @@ int main(int argc, char **argv) {
   dax=SD_daxload(argv[2]);
 
   /* Display all the tasks */
+  INFO0("------------------- Display all tasks of the loaded DAG ---------------------------");
   xbt_dynar_foreach(dax,cursor,task) {
     SD_task_dump(task);
   }
@@ -48,6 +50,38 @@ int main(int argc, char **argv) {
   fprintf(out,"}\n");
   fclose(out);
 
+  /* Schedule them all on the first workstation */
+  INFO0("------------------- Schedule tasks ---------------------------");
+  const SD_workstation_t *ws_list =  SD_workstation_get_list();
+  xbt_dynar_foreach(dax,cursor,task) {
+    if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ)
+      SD_task_schedulel(task,1,ws_list[0]);
+  }
+
+  INFO0("------------------- Run the schedule ---------------------------");
+  SD_simulate(-1);
+  INFO0("------------------- Produce the trace file---------------------------");
+  xbt_dynar_foreach(dax,cursor,task) {
+    int kind = SD_task_get_kind(task);
+    SD_workstation_t *wsl = SD_task_get_workstation_list(task);
+    switch (kind) {
+    case SD_TASK_COMP_SEQ:
+      INFO4("[%f] %s compute %f # %s",SD_task_get_start_time(task),
+          SD_workstation_get_name(wsl[0]),SD_task_get_amount(task),
+          SD_task_get_name(task));
+      break;
+    case SD_TASK_COMM_E2E:
+      INFO5("[%f] %s send %s %f # %s",SD_task_get_start_time(task),
+          SD_workstation_get_name(wsl[0]),SD_workstation_get_name(wsl[1]),
+          SD_task_get_amount(task), SD_task_get_name(task));
+      INFO5("[%f] %s recv %s %f # %s",SD_task_get_start_time(task),
+          SD_workstation_get_name(wsl[1]),SD_workstation_get_name(wsl[0]),
+          SD_task_get_amount(task), SD_task_get_name(task));
+      break;
+    default:
+      xbt_die(bprintf("Task %s is of unknown kind %d",SD_task_get_name(task),SD_task_get_kind(task)));
+    }
+  }
   /* exit */
   SD_exit();
   return 1;
index 9d98ad9..2b5e2dd 100644 (file)
@@ -124,6 +124,7 @@ XBT_PUBLIC(double) SD_task_get_execution_time(SD_task_t task,
                                               *computation_amount, const double
                                               *communication_amount,
                                               double rate);
+XBT_PUBLIC(int) SD_task_get_kind(SD_task_t task);
 XBT_PUBLIC(void) SD_task_schedule(SD_task_t task, int workstation_nb,
                                   const SD_workstation_t * workstation_list,
                                   const double *computation_amount,
index 5deef85..312839d 100644 (file)
@@ -69,9 +69,9 @@ 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);
@@ -130,9 +130,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);
 
 }
index 7c5bc15..64870f9 100644 (file)
@@ -271,14 +271,29 @@ double SD_task_get_remaining_amount(SD_task_t task)
     return task->remains;
 }
 
+int SD_task_get_kind(SD_task_t task) {
+  return task->kind;
+}
+
 /** @brief Displays debugging informations about a task */
 void SD_task_dump(SD_task_t task)
 {
   unsigned int counter;
   SD_dependency_t dependency;
+  char *statename;
 
   INFO1("Displaying task %s",SD_task_get_name(task));
-  INFO1("  - amount: %.0f",SD_task_get_amount(task));
+  statename=bprintf("%s %s %s %s %s %s %s",
+      (task->state&SD_NOT_SCHEDULED?"not scheduled":""),
+      (task->state&SD_SCHEDULED?"scheduled":""),
+      (task->state&SD_READY?"ready":"not ready"),
+      (task->state&SD_IN_FIFO?"in fifo":""),
+      (task->state&SD_RUNNING?"running":""),
+      (task->state&SD_DONE?"done":""),
+      (task->state&SD_FAILED?"failed":""));
+  INFO1("  - state: %s",statename);
+  free(statename);
+
   if (task->kind!=0) {
     switch(task->kind){
     case SD_TASK_COMM_E2E:
@@ -291,6 +306,7 @@ void SD_task_dump(SD_task_t task)
       INFO1("  - (unknown kind %d)",task->kind);
     }
   }
+  INFO1("  - amount: %.0f",SD_task_get_amount(task));
   if (xbt_dynar_length(task->tasks_before)) {
     INFO0("  - pre-dependencies:");
     xbt_dynar_foreach(task->tasks_before,counter,dependency) {
@@ -308,7 +324,7 @@ void SD_task_dump(SD_task_t task)
 void SD_task_dotty(SD_task_t task,void* out) {
   unsigned int counter;
   SD_dependency_t dependency;
-  fprintf(out, "  T%d [label=\"%.10s\"",(unsigned int)task,task->name);
+  fprintf(out, "  T%d [label=\"%.20s\"",(unsigned int)task,task->name);
   switch(task->kind){
     case SD_TASK_COMM_E2E:
       fprintf(out,", shape=box");
@@ -1133,10 +1149,10 @@ void SD_task_destroy(SD_task_t task)
   DEBUG1("Destroying task %s...", SD_task_get_name(task));
 
   __SD_task_remove_dependencies(task);
-
   /* if the task was scheduled or ready we have to free the scheduling parameters */
   if (__SD_task_is_scheduled_or_ready(task))
     __SD_task_destroy_scheduling_data(task);
+  xbt_swag_remove(task,task->state_set);
 
   if (task->name != NULL)
     xbt_free(task->name);
@@ -1176,8 +1192,8 @@ static inline SD_task_t SD_task_create_sized(const char*name,void*data,double am
  * specified at creation is sent from hosts[0] to hosts[1].
  */
 SD_task_t SD_task_create_comm_e2e(const char*name, void *data, double amount) {
-  SD_task_t res = SD_task_create_sized(name,data,0,2);
-  res->communication_amount[1] = amount;
+  SD_task_t res = SD_task_create_sized(name,data,amount,2);
+  res->communication_amount[2] = amount;
   res->kind=SD_TASK_COMM_E2E;
   return res;
 }
@@ -1192,7 +1208,7 @@ SD_task_t SD_task_create_comm_e2e(const char*name, void *data, double amount) {
  * specified at creation to be run on hosts[0].
  */
 SD_task_t SD_task_create_comp_seq(const char*name, void *data, double amount) {
-  SD_task_t res = SD_task_create_sized(name,data,0,1);
+  SD_task_t res = SD_task_create_sized(name,data,amount,1);
   res->computation_amount[0]=amount;
   res->kind=SD_TASK_COMP_SEQ;
   return res;
@@ -1232,27 +1248,47 @@ void SD_task_schedulev(SD_task_t task, int count, const SD_workstation_t*list) {
     xbt_die(bprintf("Kind of task %s not supported by SD_task_schedulev()",
           SD_task_get_name(task)));
   }
+  if (task->kind == SD_TASK_COMM_E2E) {
+    VERB4("Schedule comm task %s between %s -> %s. It costs %.f bytes",
+        SD_task_get_name(task),
+        SD_workstation_get_name(task->workstation_list[0]),SD_workstation_get_name(task->workstation_list[1]),
+        task->communication_amount[2]);
+
+  }
   /* Iterate over all childs and parent being COMM_E2E to say where I am located (and start them if ready) */
   if (task->kind == SD_TASK_COMP_SEQ) {
+    VERB3("Schedule computation task %s on %s. It costs %.f flops",
+        SD_task_get_name(task),SD_workstation_get_name(task->workstation_list[0]),
+        task->computation_amount[0]);
     SD_dependency_t dep;
     unsigned int cpt;
     xbt_dynar_foreach(task->tasks_before,cpt,dep) {
       SD_task_t before = dep->src;
       if (before->kind == SD_TASK_COMM_E2E) {
         before->workstation_list[1] = task->workstation_list[0];
-        if (before->workstation_list[0])
+        if (before->workstation_list[0] && __SD_task_is_not_scheduled(before)) {
           SD_task_do_schedule(before);
+          VERB4("Auto-Schedule comm task %s between %s -> %s. It costs %.f bytes",
+              SD_task_get_name(before),
+              SD_workstation_get_name(before->workstation_list[0]),SD_workstation_get_name(before->workstation_list[1]),
+              before->communication_amount[2]);
+        }
       }
     }
     xbt_dynar_foreach(task->tasks_after,cpt,dep) {
       SD_task_t after = dep->dst;
       if (after->kind == SD_TASK_COMM_E2E) {
         after->workstation_list[0] = task->workstation_list[0];
-        if (after->workstation_list[1])
+        if (after->workstation_list[1] && __SD_task_is_not_scheduled(after)) {
           SD_task_do_schedule(after);
+          VERB4("Auto-Schedule comm task %s between %s -> %s. It costs %.f bytes",
+              SD_task_get_name(after),
+              SD_workstation_get_name(after->workstation_list[0]),SD_workstation_get_name(after->workstation_list[1]),
+              after->communication_amount[2]);
+
+        }
       }
     }
-
   }
 }
 /** @brief autoschedule a task on a list of workstations