Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't try to change the rate of task once it's done, the new test in
[simgrid.git] / examples / simdag / sd_comm_throttling.c
index 4313e01..8f5f294 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2006-2010, 2012-2014. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -6,7 +6,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include "simdag/simdag.h"
+#include "simgrid/simdag.h"
 #include "xbt/ex.h"
 #include "xbt/log.h"
 
@@ -66,15 +66,22 @@ int main(int argc, char **argv)
     XBT_INFO("Simulation stopped after %.4f seconds", SD_get_clock());
     xbt_dynar_foreach(changed_tasks, ctr, task) {
       XBT_INFO("Task '%s' start time: %f, finish time: %f",
-              SD_task_get_name(task),
-              SD_task_get_start_time(task), 
-              SD_task_get_finish_time(task));
+         SD_task_get_name(task),
+         SD_task_get_start_time(task), 
+         SD_task_get_finish_time(task));
  
     }
     /* let throttle the communication for taskD if its parent is SD_DONE */
-    if (SD_task_get_state(taskC) == SD_DONE)
-      SD_task_set_rate(taskD, 0.5);
+    /* the bandwidth is 1.25e8, the data size is 1e7, and we want to throttle
+     * the bandwidth by a factor 2. the rate is then 1.25e8/(2*1e7)=6.25
+     * Changing the rate is possible before the task execution starts (in SD_RUNNING
+     * state).
+     */
+    if (SD_task_get_state(taskC) == SD_DONE && SD_task_get_state(taskD) < SD_RUNNING)
+      SD_task_set_rate(taskD, 6.25);
+    xbt_dynar_free_container(&changed_tasks);
   }
+  xbt_dynar_free_container(&changed_tasks);
 
   XBT_DEBUG("Destroying tasks...");