Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid into...
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 7 Jul 2016 09:06:00 +0000 (11:06 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 7 Jul 2016 09:06:00 +0000 (11:06 +0200)
examples/simdag/typed_tasks/sd_typed_tasks.tesh
src/simdag/sd_daxloader.cpp
src/simdag/sd_global.cpp
src/simdag/sd_task.cpp
src/simdag/simdag_private.h
teshsuite/simdag/incomplete/incomplete.tesh

index 3246a80..cc9657f 100644 (file)
@@ -3,9 +3,9 @@ p Usage test of simdag's typed tasks
 
 $ $SG_TEST_EXENV ./typed_tasks/sd_typed_tasks ${srcdir:=.}/../platforms/two_clusters.xml
 > [0.000000] [xbt_cfg/INFO] Switching to the L07 model to handle parallel tasks.
-> [2.080600] [sd_typed_tasks_test/INFO] Task 'Seq. comp. 1' start time: 0.000000, finish time: 1.000000
-> [2.080600] [sd_typed_tasks_test/INFO] Task 'Par. Comp. 1' start time: 0.000000, finish time: 0.400000
 > [2.080600] [sd_typed_tasks_test/INFO] Task 'Par. Comp. 3' start time: 0.000000, finish time: 0.400000
+> [2.080600] [sd_typed_tasks_test/INFO] Task 'Par. Comp. 1' start time: 0.000000, finish time: 0.400000
+> [2.080600] [sd_typed_tasks_test/INFO] Task 'Seq. comp. 1' start time: 0.000000, finish time: 1.000000
 > [2.080600] [sd_typed_tasks_test/INFO] Task 'MxN redist' start time: 0.400000, finish time: 0.721600
 > [2.080600] [sd_typed_tasks_test/INFO] Task 'Par. Comp. 2' start time: 0.721600, finish time: 0.921600
 > [2.080600] [sd_typed_tasks_test/INFO] Task 'E2E comm.' start time: 1.000000, finish time: 1.080600
index 77f1532..9d542db 100644 (file)
@@ -340,7 +340,7 @@ void STag_dax__uses(void)
   SD_task_t file = static_cast<SD_task_t>(xbt_dict_get_or_null(files, A_dax__uses_file));
   if (file == nullptr) {
     file = SD_task_create_comm_e2e(A_dax__uses_file, nullptr, size);
-    xbt_dynar_pop(sd_global->initial_task_set,nullptr);
+    sd_global->initial_tasks->erase(file);
     xbt_dict_set(files, A_dax__uses_file, file, nullptr);
   } else {
     if (SD_task_get_amount(file) != size) {
index fa37ca6..d6237ef 100644 (file)
@@ -40,9 +40,9 @@ void SD_init(int *argc, char **argv)
 
   sd_global->task_mallocator=xbt_mallocator_new(65536, SD_task_new_f, SD_task_free_f, SD_task_recycle_f);
 
-  sd_global->initial_task_set = xbt_dynar_new(sizeof(SD_task_t), nullptr);
-  sd_global->executable_task_set = xbt_dynar_new(sizeof(SD_task_t), nullptr);
-  sd_global->completed_task_set = xbt_dynar_new(sizeof(SD_task_t), nullptr);
+  sd_global->initial_tasks = new std::set<SD_task_t>();
+  sd_global->executable_tasks = new std::set<SD_task_t>();
+  sd_global->completed_tasks = new std::set<SD_task_t>();
   sd_global->return_set = xbt_dynar_new(sizeof(SD_task_t), nullptr);
 
   surf_init(argc, argv);
@@ -129,7 +129,9 @@ xbt_dynar_t SD_simulate(double how_long) {
   xbt_dynar_reset(sd_global->return_set);
 
   /* explore the runnable tasks */
-  xbt_dynar_foreach(sd_global->executable_task_set , iter, task) {
+  for (std::set<SD_task_t>::iterator it=sd_global->executable_tasks->begin();
+       it!=sd_global->executable_tasks->end(); ++it){
+    task = *it;
     XBT_VERB("Executing task '%s'", SD_task_get_name(task));
     SD_task_run(task);
     xbt_dynar_push(sd_global->return_set, &task);
@@ -228,13 +230,14 @@ xbt_dynar_t SD_simulate(double how_long) {
     }
   }
 
-  if (!sd_global->watch_point_reached && how_long<0 &&
-      xbt_dynar_is_empty(sd_global->initial_task_set) == 0) {
+  if (!sd_global->watch_point_reached && how_long<0 && !sd_global->initial_tasks->empty()) {
     XBT_WARN("Simulation is finished but %lu tasks are still not done",
-             xbt_dynar_length(sd_global->initial_task_set));
+             sd_global->initial_tasks->size());
     static const char* state_names[] =
       { "SD_NOT_SCHEDULED", "SD_SCHEDULABLE", "SD_SCHEDULED", "SD_RUNNABLE", "SD_RUNNING", "SD_DONE","SD_FAILED" };
-    xbt_dynar_foreach(sd_global->initial_task_set, iter, task){
+    for (std::set<SD_task_t>::iterator it=sd_global->initial_tasks->begin();
+         it!=sd_global->initial_tasks->end(); ++it){
+      task = *it;
       XBT_WARN("%s is in %s state", SD_task_get_name(task), state_names[SD_task_get_state(task)]);
     }
   }
@@ -268,9 +271,9 @@ void SD_exit()
 #endif
 
   xbt_mallocator_free(sd_global->task_mallocator);
-  xbt_dynar_free_container(&(sd_global->initial_task_set));
-  xbt_dynar_free_container(&(sd_global->executable_task_set));
-  xbt_dynar_free_container(&(sd_global->completed_task_set));
+  delete sd_global->initial_tasks;
+  delete sd_global->executable_tasks;
+  delete sd_global->completed_tasks;
   xbt_dynar_free_container(&(sd_global->return_set));
   xbt_free(sd_global);
   sd_global = nullptr;
index d09c692..40c8d70 100644 (file)
@@ -22,7 +22,7 @@ static void __SD_task_dependency_destroy(void *dependency)
 /* Remove all dependencies associated with a task. This function is called when the task is destroyed. */
 static void __SD_task_remove_dependencies(SD_task_t task)
 {
-  /* we must destroy the dependencies carefuly (with SD_dependency_remove) because each one is stored twice */
+  /* we must destroy the dependencies carefully (with SD_dependency_remove) because each one is stored twice */
   SD_dependency_t dependency;
   while (xbt_dynar_is_empty(task->tasks_before) == 0) {
     xbt_dynar_get_cpy(task->tasks_before, 0, &dependency);
@@ -63,7 +63,7 @@ void SD_task_recycle_f(void *t)
   /* Reset the content */
   task->kind = SD_TASK_NOT_TYPED;
   task->state= SD_NOT_SCHEDULED;
-  xbt_dynar_push(sd_global->initial_task_set,&task);
+  sd_global->initial_tasks->insert(task);
 
   task->marked = 0;
 
@@ -319,36 +319,33 @@ e_SD_task_state_t SD_task_get_state(SD_task_t task)
  */
 void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state)
 {
-  int idx;
+  std::set<SD_task_t>::iterator idx;
   switch (new_state) {
   case SD_NOT_SCHEDULED:
   case SD_SCHEDULABLE:
     if (SD_task_get_state(task) == SD_FAILED){
-        xbt_dynar_remove_at(sd_global->completed_task_set,
-            xbt_dynar_search(sd_global->completed_task_set, &task), nullptr);
-        xbt_dynar_push(sd_global->initial_task_set,&task);
+      sd_global->completed_tasks->erase(task);
+      sd_global->initial_tasks->insert(task);
     }
     break;
   case SD_SCHEDULED:
     if (SD_task_get_state(task) == SD_RUNNABLE){
-      xbt_dynar_remove_at(sd_global->executable_task_set,
-          xbt_dynar_search(sd_global->executable_task_set, &task), nullptr);
-      xbt_dynar_push(sd_global->initial_task_set,&task);
+      sd_global->executable_tasks->erase(task);
+      sd_global->initial_tasks->insert(task);
     }
     break;
   case SD_RUNNABLE:
-    idx = xbt_dynar_search_or_negative(sd_global->initial_task_set, &task);
-    if (idx >= 0) {
-      xbt_dynar_remove_at(sd_global->initial_task_set, idx, nullptr);
-      xbt_dynar_push(sd_global->executable_task_set,&task);
+    idx = std::find(sd_global->initial_tasks->begin(), sd_global->initial_tasks->end(), task);
+    if (idx != sd_global->initial_tasks->end()) {
+      sd_global->initial_tasks->erase(idx);
+      sd_global->executable_tasks->insert(*idx);
     }
     break;
   case SD_RUNNING:
-      xbt_dynar_remove_at(sd_global->executable_task_set,
-         xbt_dynar_search(sd_global->executable_task_set, &task), nullptr);
+    sd_global->executable_tasks->erase(task);
     break;
   case SD_DONE:
-    xbt_dynar_push(sd_global->completed_task_set,&task);
+    sd_global->completed_tasks->insert(task);
     task->finish_time = task->surf_action->getFinishTime();
     task->remains = 0;
 #if HAVE_JEDULE
@@ -356,7 +353,7 @@ void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state)
 #endif
     break;
   case SD_FAILED:
-    xbt_dynar_push(sd_global->completed_task_set,&task);
+    sd_global->completed_tasks->insert(task);
     break;
   default:
     xbt_die( "Invalid state");
index 28e8664..d234556 100644 (file)
@@ -6,7 +6,7 @@
 
 #ifndef SIMDAG_PRIVATE_H
 #define SIMDAG_PRIVATE_H
-
+#include <set>
 #include "xbt/dynar.h"
 #include "simgrid/simdag.h"
 #include "surf/surf.h"
@@ -22,9 +22,9 @@ typedef struct SD_global {
 
   bool watch_point_reached;      /* has a task just reached a watch point? */
 
-  xbt_dynar_t initial_task_set;
-  xbt_dynar_t executable_task_set;
-  xbt_dynar_t completed_task_set;
+  std::set<SD_task_t> *initial_tasks;
+  std::set<SD_task_t> *executable_tasks;
+  std::set<SD_task_t> *completed_tasks;
 
   xbt_dynar_t return_set;
 
index 4ecdc50..3f8dddf 100644 (file)
@@ -1,7 +1,7 @@
 $ ${bindir:=.}/incomplete ../../../examples/platforms/two_hosts_platform_shared.xml "--log=root.fmt:[%10.6r]%e%m%n"
 > [  0.000000] Switching to the L07 model to handle parallel tasks.
 > [  8.000100] Simulation is finished but 3 tasks are still not done
-> [  8.000100] Task B is in SD_SCHEDULABLE state
-> [  8.000100] Task C is in SD_NOT_SCHEDULED state
 > [  8.000100] Task D is in SD_SCHEDULED state
+> [  8.000100] Task C is in SD_NOT_SCHEDULED state
+> [  8.000100] Task B is in SD_SCHEDULABLE state
 > [  8.000100] Simulation time: 8.000100