Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
prevent tasks to share resources when they don't have to.
authorFrederic Suter <suter@youpi.(none)>
Tue, 28 Feb 2012 15:43:55 +0000 (16:43 +0100)
committerFrederic Suter <suter@youpi.(none)>
Tue, 28 Feb 2012 15:43:55 +0000 (16:43 +0100)
allow users to create a dependency from a task in a SD_RUNNING state
revalidate the tesh file for the minmin_test example

examples/simdag/scheduling/minmin_test.c
examples/simdag/scheduling/test_minmin.tesh
src/simdag/sd_task.c

index 3a0788d..d0f137d 100644 (file)
@@ -20,6 +20,7 @@ typedef struct _WorkstationAttribute *WorkstationAttribute;
 struct _WorkstationAttribute {
   /* Earliest time at wich a workstation is ready to execute a task */
   double available_at;
+  SD_task_t last_scheduled_task;
 };
 
 static void SD_workstation_allocate_attribute(SD_workstation_t workstation)
@@ -51,6 +52,19 @@ static void SD_workstation_set_available_at(SD_workstation_t workstation,
   SD_workstation_set_data(workstation, attr);
 }
 
+static SD_task_t SD_workstation_get_last_scheduled_task( SD_workstation_t workstation){
+       WorkstationAttribute attr =
+                       (WorkstationAttribute) SD_workstation_get_data(workstation);
+       return attr->last_scheduled_task;
+}
+
+static void SD_workstation_set_last_scheduled_task(SD_workstation_t workstation,
+               SD_task_t task){
+       WorkstationAttribute attr =
+                       (WorkstationAttribute) SD_workstation_get_data(workstation);
+       attr->last_scheduled_task=task;
+       SD_workstation_set_data(workstation, attr);
+}
 
 static xbt_dynar_t get_ready_tasks(xbt_dynar_t dax)
 {
@@ -235,7 +249,7 @@ int main(int argc, char **argv)
 {
   unsigned int cursor;
   double finish_time, min_finish_time = -1.0;
-  SD_task_t task, selected_task = NULL;
+  SD_task_t task, selected_task = NULL, last_scheduled_task;
   xbt_dynar_t ready_tasks;
   SD_workstation_t workstation, selected_workstation = NULL;
   int total_nworkstations = 0;
@@ -318,6 +332,31 @@ int main(int argc, char **argv)
           SD_workstation_get_name(selected_workstation));
 
     SD_task_schedulel(selected_task, 1, selected_workstation);
+
+    /*
+     * SimDag allows tasks to be executed concurrently when they can by default.
+     * Yet schedulers take decisions assuming that tasks wait for resource
+     * availability to start.
+     * The solution (well crude hack is to keep track of the last task scheduled
+     * on a workstation and add a special type of dependency if needed to
+     * force the sequential execution meant by the scheduler.
+     * If the last scheduled task is already done, has failed or is a 
+     * predecessor of the current task, no need for a new dependency
+    */
+
+    last_scheduled_task = 
+      SD_workstation_get_last_scheduled_task(selected_workstation);
+    if (last_scheduled_task && 
+       (SD_task_get_state(last_scheduled_task) != SD_DONE) &&
+       (SD_task_get_state(last_scheduled_task) != SD_FAILED) &&
+       !SD_task_dependency_exists(
+          SD_workstation_get_last_scheduled_task(selected_workstation),
+          selected_task))
+      SD_task_dependency_add("resource", NULL,
+                            last_scheduled_task, selected_task);
+    
+    SD_workstation_set_last_scheduled_task(selected_workstation, selected_task);
+    
     SD_workstation_set_available_at(selected_workstation, min_finish_time);
 
     xbt_dynar_free_container(&ready_tasks);
index 74a1b71..9a992d1 100644 (file)
@@ -9,27 +9,27 @@ $ $SG_TEST_EXENV ${bindir:=.}/minmin_test --log=sd_daxparse.thresh:critical ${sr
 > [0.000120] [test/INFO] Schedule ID00003@mProjectPP on Host 30
 > [0.000327] [test/INFO] Schedule ID00004@mProjectPP on Host 27
 > [0.000434] [test/INFO] Schedule ID00001@mProjectPP on Host 32
-> [29.085091] [test/INFO] Schedule ID00010@mDiffFit on Host 27
-> [29.085194] [test/INFO] Schedule ID00008@mDiffFit on Host 26
-> [29.989619] [test/INFO] Schedule ID00013@mDiffFit on Host 30
-> [32.637908] [test/INFO] Schedule ID00009@mDiffFit on Host 27
-> [32.638011] [test/INFO] Schedule ID00011@mDiffFit on Host 26
-> [32.638027] [test/INFO] Schedule ID00005@mDiffFit on Host 32
-> [32.638244] [test/INFO] Schedule ID00006@mDiffFit on Host 31
-> [32.638351] [test/INFO] Schedule ID00012@mDiffFit on Host 28
-> [32.638663] [test/INFO] Schedule ID00007@mDiffFit on Host 27
-> [64.163256] [test/INFO] Schedule ID00014@mConcatFit on Host 27
-> [64.953548] [test/INFO] Schedule ID00015@mBgModel on Host 27
-> [66.495779] [test/INFO] Schedule ID00016@mBackground on Host 27
-> [66.495794] [test/INFO] Schedule ID00017@mBackground on Host 26
-> [66.495901] [test/INFO] Schedule ID00020@mBackground on Host 30
-> [66.496001] [test/INFO] Schedule ID00018@mBackground on Host 27
-> [66.496016] [test/INFO] Schedule ID00019@mBackground on Host 32
-> [92.289758] [test/INFO] Schedule ID00021@mImgTbl on Host 27
-> [93.882917] [test/INFO] Schedule ID00022@mAdd on Host 27
-> [97.173604] [test/INFO] Schedule ID00023@mShrink on Host 27
-> [101.458976] [test/INFO] Schedule ID00024@mJPEG on Host 27
-> [101.951429] [test/INFO] Schedule end on Host 27
-> [101.951856] [test/INFO] Simulation Time: 101.951856
-> [101.951856] [test/INFO] ------------------- Produce the trace file---------------------------
-> [101.951856] [test/INFO] Producing the trace of the run into ./Montage_25.jed
+> [14.576439] [test/INFO] Schedule ID00010@mDiffFit on Host 26
+> [17.049690] [test/INFO] Schedule ID00008@mDiffFit on Host 27
+> [29.541537] [test/INFO] Schedule ID00013@mDiffFit on Host 26
+> [32.637908] [test/INFO] Schedule ID00009@mDiffFit on Host 30
+> [32.638114] [test/INFO] Schedule ID00011@mDiffFit on Host 27
+> [32.638217] [test/INFO] Schedule ID00005@mDiffFit on Host 26
+> [32.638233] [test/INFO] Schedule ID00006@mDiffFit on Host 32
+> [32.638445] [test/INFO] Schedule ID00012@mDiffFit on Host 31
+> [32.638548] [test/INFO] Schedule ID00007@mDiffFit on Host 28
+> [60.428541] [test/INFO] Schedule ID00014@mConcatFit on Host 27
+> [61.220372] [test/INFO] Schedule ID00015@mBgModel on Host 27
+> [62.762602] [test/INFO] Schedule ID00016@mBackground on Host 27
+> [62.762618] [test/INFO] Schedule ID00017@mBackground on Host 26
+> [62.762724] [test/INFO] Schedule ID00020@mBackground on Host 30
+> [62.762824] [test/INFO] Schedule ID00018@mBackground on Host 27
+> [62.762840] [test/INFO] Schedule ID00019@mBackground on Host 32
+> [88.556582] [test/INFO] Schedule ID00021@mImgTbl on Host 27
+> [90.149741] [test/INFO] Schedule ID00022@mAdd on Host 27
+> [93.440428] [test/INFO] Schedule ID00023@mShrink on Host 27
+> [97.725800] [test/INFO] Schedule ID00024@mJPEG on Host 27
+> [98.218253] [test/INFO] Schedule end on Host 27
+> [98.218679] [test/INFO] Simulation Time: 98.218679
+> [98.218679] [test/INFO] ------------------- Produce the trace file---------------------------
+> [98.218679] [test/INFO] Producing the trace of the run into ./Montage_25.jed
index 038d46e..9465be4 100644 (file)
@@ -447,9 +447,10 @@ void SD_task_dependency_add(const char *name, void *data, SD_task_t src,
            SD_task_get_name(src));
 
   if (!__SD_task_is_not_scheduled(src) && !__SD_task_is_schedulable(src)
-      && !__SD_task_is_scheduled_or_runnable(src))
+      && !__SD_task_is_scheduled_or_runnable(src) && !__SD_task_is_running(src))
     THROWF(arg_error, 0,
-           "Task '%s' must be SD_NOT_SCHEDULED, SD_SCHEDULABLE, SD_SCHEDULED or SD_RUNNABLE",
+           "Task '%s' must be SD_NOT_SCHEDULED, SD_SCHEDULABLE, SD_SCHEDULED or SD_RUNNABLE"
+          " or SD_RUNNING",
            SD_task_get_name(src));
 
   if (!__SD_task_is_not_scheduled(dst) && !__SD_task_is_schedulable(dst)
@@ -500,7 +501,7 @@ void SD_task_dependency_add(const char *name, void *data, SD_task_t src,
 }
 
 /**
- * \brief Indacates whether there is a dependency between two tasks.
+ * \brief Indicates whether there is a dependency between two tasks.
  *
  * \param src a task
  * \param dst a task depending on \a src