Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix an issue that occurs when SD_simulate is called with a positive
authorsuter <frederic.suter@cc.in2p3.fr>
Fri, 12 Oct 2012 22:57:03 +0000 (00:57 +0200)
committersuter <frederic.suter@cc.in2p3.fr>
Fri, 12 Oct 2012 22:57:21 +0000 (00:57 +0200)
value (simulate for X seconds). The simulation does not always stop
after the expected duration.
Cause: The "less than" test is sometimes tricky with doubles.
Fix: Replace by "difference smaller than 0.00001 (the maxmin precision).

+ indent
+ one more verbose message

src/simdag/sd_global.c

index 1ca32d0..2294740 100644 (file)
@@ -229,13 +229,14 @@ xbt_swag_t SD_simulate_swag(double how_long) {
   unsigned int iter, depcnt;
   static int first_time = 1;
 
-   if (first_time) {
-     XBT_VERB("Starting simulation...");
+  if (first_time) {
+    XBT_VERB("Starting simulation...");
 
-     surf_presolve();            /* Takes traces into account */
-     first_time = 0;
-   }
+    surf_presolve();            /* Takes traces into account */
+    first_time = 0;
+  }
 
+  XBT_VERB("Run simulation for %f seconds", how_long);
   sd_global->watch_point_reached = 0;
 
   xbt_swag_reset(sd_global->return_set);
@@ -250,7 +251,7 @@ xbt_swag_t SD_simulate_swag(double how_long) {
   /* main loop */
   elapsed_time = 0.0;
   while (elapsed_time >= 0.0 &&
-         (how_long < 0.0 || total_time < how_long) &&
+         (how_long < 0.0 || 0.00001 < (how_long -total_time)) &&
          !sd_global->watch_point_reached) {
     surf_model_t model = NULL;
     /* dumb variables */