From: suter Date: Fri, 12 Oct 2012 22:57:03 +0000 (+0200) Subject: fix an issue that occurs when SD_simulate is called with a positive X-Git-Tag: v3_8~68 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/97fbb37cce6bc8da3b1f72909bacb5e896a8ae3c fix an issue that occurs when SD_simulate is called with a positive 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 --- diff --git a/src/simdag/sd_global.c b/src/simdag/sd_global.c index 1ca32d068f..2294740e6c 100644 --- a/src/simdag/sd_global.c +++ b/src/simdag/sd_global.c @@ -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 */