Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove a crude hack where first call to surf_solve() finalize the initialization...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 15 May 2008 14:24:16 +0000 (14:24 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 15 May 2008 14:24:16 +0000 (14:24 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5429 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/gras/Virtu/sg_process.c
src/gras_config.h.in
src/include/simix/simix.h
src/include/surf/surf.h
src/msg/global.c
src/simdag/sd_global.c
src/simix/smx_global.c
src/smpi/smpi_global.c
src/surf/surf.c

index b37d2ba..392d11e 100644 (file)
@@ -217,6 +217,7 @@ void gras_main() {
   /* Clean IO before the run */
   fflush(stdout);
   fflush(stderr);
+  SIMIX_init();
 
   while (SIMIX_solve(actions_done, actions_failed) != -1.0) {
     while ( (action = xbt_fifo_pop(actions_failed)) ) {
index 32c5e80..dd0c895 100644 (file)
@@ -1,5 +1,8 @@
 /* src/gras_config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* Arguments passed to the configure script */
+#undef AC_CONFIGURE_ARGS
+
 /* Path to the addr2line tool */
 #undef ADDR2LINE
 
index a3d6ec0..3bc9eb9 100644 (file)
@@ -29,6 +29,7 @@ XBT_PUBLIC(xbt_main_func_t) SIMIX_get_registered_function(const char *name);
 XBT_PUBLIC(void) SIMIX_launch_application(const char *file);
 
 XBT_PUBLIC(double) SIMIX_get_clock(void);
+XBT_PUBLIC(void) SIMIX_init(void);
 XBT_PUBLIC(double) SIMIX_solve(xbt_fifo_t actions_done, xbt_fifo_t actions_failed);
 
 /* Timer functions */
index 8b83c0a..16dd164 100644 (file)
@@ -537,6 +537,13 @@ XBT_PUBLIC_DATA(xbt_dynar_t)  model_list;
  */
 XBT_PUBLIC(void) surf_init(int *argc, char **argv);    /* initialize common structures */
 
+/** \brief Finish simulation initialization
+ *  \ingroup SURF_simulation
+ *
+ *  This function must be called before the first call to surf_solve()
+ */
+XBT_PUBLIC(void) surf_presolve(void);
+
 /** \brief Performs a part of the simulation
  *  \ingroup SURF_simulation
  *  \return the elapsed time, or -1.0 if no event could be executed
index 42dba8b..1b5325f 100644 (file)
@@ -168,6 +168,7 @@ MSG_error_t MSG_main(void)
   /* Clean IO before the run */
   fflush(stdout);
   fflush(stderr);
+  SIMIX_init();
 
   //surf_solve(); /* Takes traces into account. Returns 0.0 */
   /* xbt_fifo_size(msg_global->process_to_run) */
index ce76515..c849609 100644 (file)
@@ -419,7 +419,7 @@ SD_task_t* SD_simulate(double how_long)
   changed_tasks[0] = NULL;
 
   if (first_time) {
-    surf_solve(); /* Takes traces into account. Returns 0.0 */
+    surf_presolve(); /* Takes traces into account */
     first_time = 0;
   }
 
index 5742d2b..c797d56 100644 (file)
@@ -313,6 +313,15 @@ double SIMIX_get_clock(void)
   return surf_get_clock();
 }
 
+/**
+ *     \brief Finish the simulation initialization 
+ * 
+ *      Must be called before the first call to SIMIX_solve()
+ */
+void SIMIX_init(void) {
+    surf_presolve();
+}
+
 /**
  *     \brief Does a turn of the simulation
  *
@@ -328,16 +337,12 @@ double SIMIX_solve(xbt_fifo_t actions_done, xbt_fifo_t actions_failed)
   unsigned int iter;
   double elapsed_time = 0.0;
   static int state_modifications = 1;
-  static int first = 1;
 
   xbt_context_empty_trash();
   if (xbt_swag_size(simix_global->process_to_run) && (elapsed_time > 0)) {
     DEBUG0("**************************************************");
   }
-  if (first) {
-    surf_solve();              /* Takes traces into account. Returns 0.0 */
-    first = 0;
-  }
   while ((process = xbt_swag_extract(simix_global->process_to_run))) {
     DEBUG2("Scheduling %s on %s",
           process->name, process->simdata->smx_host->name);
index 822f0ca..1221b7c 100644 (file)
@@ -301,6 +301,7 @@ int smpi_run_simulation(int *argc, char **argv)
        /* Clean IO before the run */
        fflush(stdout);
        fflush(stderr);
+        SIMIX_init();
 
        while (SIMIX_solve(actions_done, actions_failed) != -1.0) {
                while ((action = xbt_fifo_pop(actions_failed))) {
index 166c134..ac8040c 100644 (file)
@@ -454,20 +454,14 @@ void surf_exit(void)
   xbt_exit();
 }
 
-double surf_solve(void)
-{
-  static int first_run = 1;
-
-  double min = -1.0;
+void surf_presolve(void) {
   double next_event_date = -1.0;
-  double model_next_action_end = -1.0;
+  tmgr_trace_event_t event = NULL;
   double value = -1.0;
   surf_model_object_t model_obj = NULL;
   surf_model_t model = NULL;
-  tmgr_trace_event_t event = NULL;
   unsigned int iter;
-
-  if (first_run) {
+   
     DEBUG0
        ("First Run! Let's \"purge\" events and put models in the right state");
     while ((next_event_date = tmgr_history_next_date(history)) != -1.0) {
@@ -484,9 +478,18 @@ double surf_solve(void)
     xbt_dynar_foreach(model_list, iter, model) {
       model->common_private->update_actions_state(NOW, 0.0);
     }
-    first_run = 0;
-    return 0.0;
-  }
+}
+
+double surf_solve(void)
+{
+  double min = -1.0;
+  double next_event_date = -1.0;
+  double model_next_action_end = -1.0;
+  double value = -1.0;
+  surf_model_object_t model_obj = NULL;
+  surf_model_t model = NULL;
+  tmgr_trace_event_t event = NULL;
+  unsigned int iter;
 
   min = -1.0;