Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simdata cleanup from smx_action_t. Now all SIMIX's data structures [Cristian]
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 13 Jul 2009 18:03:42 +0000 (18:03 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 13 Jul 2009 18:03:42 +0000 (18:03 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6492 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/gras/Virtu/sg_process.c
src/include/simix/datatypes.h
src/include/simix/simix.h
src/msg/global.c
src/msg/mailbox.h
src/simix/private.h
src/simix/smx_action.c
src/simix/smx_process.c
src/smpi/smpi_global.c

index 975c627..c001c00 100644 (file)
@@ -237,7 +237,6 @@ void gras_function_register(const char *name, xbt_main_func_t code)
 
 void gras_main()
 {
-  smx_cond_t cond = NULL;
   smx_action_t action;
   xbt_fifo_t actions_done = xbt_fifo_new();
   xbt_fifo_t actions_failed = xbt_fifo_new();
@@ -249,19 +248,15 @@ void gras_main()
 
   while (SIMIX_solve(actions_done, actions_failed) != -1.0) {
     while ((action = xbt_fifo_pop(actions_failed))) {
-      DEBUG1("** %s failed **", action->name);
-      while ((cond = xbt_fifo_pop(action->cond_list))) {
-        SIMIX_cond_broadcast(cond);
-      }
+      DEBUG1("** %s failed **", SIMIX_action_get_name(action));
+      SIMIX_action_signal_all (action);
       /* action finished, destroy it */
       //        SIMIX_action_destroy(action);
     }
 
     while ((action = xbt_fifo_pop(actions_done))) {
-      DEBUG1("** %s done **", action->name);
-      while ((cond = xbt_fifo_pop(action->cond_list))) {
-        SIMIX_cond_broadcast(cond);
-      }
+      DEBUG1("** %s done **", SIMIX_action_get_name(action));
+      SIMIX_action_signal_all (action);
       /* action finished, destroy it */
       //SIMIX_action_destroy(action);
     }
index f1eb193..28e1be2 100644 (file)
@@ -39,18 +39,6 @@ SG_BEGIN_DECL()
 
 
 /********************************** Action *************************************/
-     typedef struct s_smx_simdata_action *smx_simdata_action_t;
-/** @brief Action datatype 
-    @ingroup m_datatypes_management_details */
-     typedef struct s_smx_action {
-       char *name;              /**< @brief action name if any */
-       smx_simdata_action_t simdata;
-                                /**< @brief simulator data */
-       xbt_fifo_t cond_list;    /*< conditional variables that must be signaled when the action finish. */
-       void *data;              /**< @brief user data */
-       int refcount;            /**< @brief reference counter */
-     } s_smx_action_t;
-
      typedef struct s_smx_action *smx_action_t;
 
 
index a9c0780..5226cee 100644 (file)
@@ -175,7 +175,10 @@ XBT_PUBLIC(smx_action_t) SIMIX_action_parallel_execute(char *name,
                                                        double amount,
                                                        double rate);
 
-     void SIMIX_display_process_status(void);
+XBT_PUBLIC(char *) SIMIX_action_get_name(smx_action_t action);
+XBT_PUBLIC(void) SIMIX_action_signal_all(smx_action_t action);
+
+void SIMIX_display_process_status(void);
 
 
 SG_END_DECL()
index d5de0ca..431996b 100644 (file)
@@ -146,7 +146,6 @@ int MSG_get_channel_number(void)
  */
 MSG_error_t MSG_main(void)
 {
-  smx_cond_t cond = NULL;
   smx_action_t smx_action;
   xbt_fifo_t actions_done = xbt_fifo_new();
   xbt_fifo_t actions_failed = xbt_fifo_new();
@@ -162,20 +161,13 @@ MSG_error_t MSG_main(void)
   while (SIMIX_solve(actions_done, actions_failed) != -1.0) {
 
     while ((smx_action = xbt_fifo_pop(actions_failed))) {
-
-
-      DEBUG1("** %s failed **", smx_action->name);
-      while ((cond = xbt_fifo_pop(smx_action->cond_list))) {
-        SIMIX_cond_broadcast(cond);
-      }
+      DEBUG1("** %s failed **", SIMIX_action_get_name(smx_action));
+      SIMIX_action_signal_all(smx_action);
     }
 
     while ((smx_action = xbt_fifo_pop(actions_done))) {
-
-      DEBUG1("** %s done **", smx_action->name);
-      while ((cond = xbt_fifo_pop(smx_action->cond_list))) {
-        SIMIX_cond_broadcast(cond);
-      }
+      DEBUG1("** %s done **", SIMIX_action_get_name(smx_action));
+      SIMIX_action_signal_all(smx_action);      
     }
   }
   xbt_fifo_free(actions_failed);
index e7c00fd..c742cc2 100644 (file)
@@ -2,9 +2,10 @@
 #define SMX_MAILBOX_H
 
 #include "xbt/fifo.h"
-#include "simix/private.h"
+#include "simix/simix.h"
 #include "msg/datatypes.h"
 
+
 SG_BEGIN_DECL()
 #define MAX_ALIAS_NAME ((size_t)260)
 /*
index bcf61c9..bb65a42 100644 (file)
@@ -108,14 +108,16 @@ typedef struct s_smx_cond {
 
 /********************************* Action **************************************/
 
-typedef struct s_smx_simdata_action {
+/** @brief Action datatype 
+    @ingroup m_datatypes_management_details */
+typedef struct s_smx_action {
+  char *name;              /**< @brief action name if any */
+  xbt_fifo_t cond_list;    /*< conditional variables that must be signaled when the action finish. */
+  void *data;              /**< @brief user data */
+  int refcount;            /**< @brief reference counter */
   surf_action_t surf_action;    /* SURF modeling of computation  */
-
   smx_host_t source;
-
-} s_smx_simdata_action_t;
-
-
+} s_smx_action_t;
 
 /******************************* Other **********************************/
 
index b5a4cd2..39e981c 100644 (file)
@@ -29,7 +29,6 @@ smx_action_t SIMIX_action_communicate(smx_host_t sender,
                                       double size, double rate)
 {
   smx_action_t act;
-  smx_simdata_action_t simdata;
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
@@ -45,19 +44,17 @@ smx_action_t SIMIX_action_communicate(smx_host_t sender,
 
   /* alloc structures */
   act = xbt_new0(s_smx_action_t, 1);
-  act->simdata = xbt_new0(s_smx_simdata_action_t, 1);
-  simdata = act->simdata;
   act->cond_list = xbt_fifo_new();
 
   /* initialize them */
   act->name = xbt_strdup(name);
-  simdata->source = sender;
+  act->source = sender;
 
 
-  simdata->surf_action =
+  act->surf_action =
     surf_workstation_model->extension.workstation.
     communicate(sender->host, receiver->host, size, rate);
-  surf_workstation_model->action_data_set(simdata->surf_action, act);
+  surf_workstation_model->action_data_set(act->surf_action, act);
 
   DEBUG1("Create communicate action %p", act);
   return act;
@@ -75,7 +72,6 @@ smx_action_t SIMIX_action_execute(smx_host_t host, const char *name,
                                   double amount)
 {
   smx_action_t act;
-  smx_simdata_action_t simdata;
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
@@ -86,20 +82,18 @@ smx_action_t SIMIX_action_execute(smx_host_t host, const char *name,
 
   /* alloc structures */
   act = xbt_new0(s_smx_action_t, 1);
-  act->simdata = xbt_new0(s_smx_simdata_action_t, 1);
-  simdata = act->simdata;
   act->cond_list = xbt_fifo_new();
 
   /* initialize them */
-  simdata->source = host;
+  act->source = host;
   act->name = xbt_strdup(name);
 
   /* set communication */
-  simdata->surf_action =
+  act->surf_action =
     surf_workstation_model->extension.workstation.execute(host->host,
                                                           amount);
 
-  surf_workstation_model->action_data_set(simdata->surf_action, act);
+  surf_workstation_model->action_data_set(act->surf_action, act);
 
   DEBUG1("Create execute action %p", act);
   return act;
@@ -115,7 +109,6 @@ smx_action_t SIMIX_action_execute(smx_host_t host, const char *name,
 smx_action_t SIMIX_action_sleep(smx_host_t host, double duration)
 {
   char name[] = "sleep";
-  smx_simdata_action_t simdata;
   smx_action_t act;
 
   /* check if the host is active */
@@ -127,19 +120,17 @@ smx_action_t SIMIX_action_sleep(smx_host_t host, double duration)
 
   /* alloc structures */
   act = xbt_new0(s_smx_action_t, 1);
-  act->simdata = xbt_new0(s_smx_simdata_action_t, 1);
-  simdata = act->simdata;
   act->cond_list = xbt_fifo_new();
 
   /* initialize them */
-  simdata->source = host;
+  act->source = host;
   act->name = xbt_strdup(name);
 
-  simdata->surf_action =
+  act->surf_action =
     surf_workstation_model->extension.workstation.sleep(host->host,
                                                         duration);
 
-  surf_workstation_model->action_data_set(simdata->surf_action, act);
+  surf_workstation_model->action_data_set(act->surf_action, act);
 
   DEBUG1("Create sleep action %p", act);
   return act;
@@ -156,8 +147,8 @@ void SIMIX_action_cancel(smx_action_t action)
   xbt_assert0((action != NULL), "Invalid parameter");
 
   DEBUG1("Cancel action %p", action);
-  if (action->simdata->surf_action) {
-    surf_workstation_model->action_cancel(action->simdata->surf_action);
+  if (action->surf_action) {
+    surf_workstation_model->action_cancel(action->surf_action);
   }
   return;
 }
@@ -171,10 +162,9 @@ void SIMIX_action_cancel(smx_action_t action)
  */
 void SIMIX_action_set_priority(smx_action_t action, double priority)
 {
-  xbt_assert0((action != NULL)
-              && (action->simdata != NULL), "Invalid parameter");
+  xbt_assert0((action != NULL), "Invalid parameter");
 
-  surf_workstation_model->set_priority(action->simdata->surf_action,
+  surf_workstation_model->set_priority(action->surf_action,
                                        priority);
   return;
 }
@@ -204,11 +194,9 @@ int SIMIX_action_destroy(smx_action_t action)
 
   xbt_fifo_free(action->cond_list);
 
-  if (action->simdata->surf_action)
-    action->simdata->surf_action->model_type->action_unref(action->
-                                                          simdata->surf_action);
+  if (action->surf_action)
+    action->surf_action->model_type->action_unref(action->surf_action);
 
-  xbt_free(action->simdata);
   xbt_free(action);
   return 1;
 }
@@ -270,8 +258,7 @@ void SIMIX_register_action_to_condition(smx_action_t action, smx_cond_t cond)
  *     \param action SIMIX action
  *     \param cond SIMIX cond
  */
-void SIMIX_unregister_action_to_condition(smx_action_t action,
-                                          smx_cond_t cond)
+void SIMIX_unregister_action_to_condition(smx_action_t action, smx_cond_t cond)
 {
   xbt_assert0((action != NULL) && (cond != NULL), "Invalid parameters");
 
@@ -292,7 +279,7 @@ void SIMIX_unregister_action_to_condition(smx_action_t action,
 double SIMIX_action_get_remains(smx_action_t action)
 {
   xbt_assert0((action != NULL), "Invalid parameter");
-  return action->simdata->surf_action->remains;
+  return action->surf_action->remains;
 }
 
 smx_action_t SIMIX_action_parallel_execute(char *name, int host_nb,
@@ -302,14 +289,11 @@ smx_action_t SIMIX_action_parallel_execute(char *name, int host_nb,
                                            double amount, double rate)
 {
   void **workstation_list = NULL;
-  smx_simdata_action_t simdata;
   smx_action_t act;
   int i;
 
   /* alloc structures */
   act = xbt_new0(s_smx_action_t, 1);
-  act->simdata = xbt_new0(s_smx_simdata_action_t, 1);
-  simdata = act->simdata;
   act->cond_list = xbt_fifo_new();
 
   /* initialize them */
@@ -321,7 +305,7 @@ smx_action_t SIMIX_action_parallel_execute(char *name, int host_nb,
   for (i = 0; i < host_nb; i++)
     workstation_list[i] = host_list[i]->host;
 
-  simdata->surf_action =
+  act->surf_action =
     surf_workstation_model->extension.
     workstation.execute_parallel_task(host_nb, workstation_list,
                                       computation_amount,
@@ -335,9 +319,8 @@ smx_action_t SIMIX_action_parallel_execute(char *name, int host_nb,
 e_surf_action_state_t SIMIX_action_get_state(smx_action_t action)
 {
   xbt_assert0((action != NULL), "Invalid parameter");
-  return surf_workstation_model->action_state_get(action->simdata->
+  return surf_workstation_model->action_state_get(action->
                                                   surf_action);
-
 }
 
 void __SIMIX_cond_display_actions(smx_cond_t cond)
@@ -359,3 +342,19 @@ void __SIMIX_action_display_conditions(smx_action_t action)
   xbt_fifo_foreach(action->cond_list, item, cond, smx_cond_t)
     DEBUG1("\t %p", cond);
 }
+
+char * SIMIX_action_get_name(smx_action_t action)
+{
+  xbt_assert0((action != NULL), "Invalid parameter");
+  return action->name;
+}
+
+void SIMIX_action_signal_all(smx_action_t action)
+{
+  smx_cond_t cond;
+
+  while((cond = xbt_fifo_pop(action->cond_list)))
+    SIMIX_cond_broadcast(cond);
+
+  return;
+}
\ No newline at end of file
index d7a9f44..cd0487e 100644 (file)
@@ -307,7 +307,7 @@ void SIMIX_process_suspend(smx_process_t process)
       process->suspended = 1;
       c = process->cond;
       xbt_fifo_foreach(c->actions, i, act, smx_action_t) {
-      surf_workstation_model->suspend(act->surf_action);
+        surf_workstation_model->suspend(act->surf_action);
       }
     } else {
       process->suspended = 1;
@@ -321,7 +321,7 @@ void SIMIX_process_suspend(smx_process_t process)
 
     cond = SIMIX_cond_init();
     dummy = SIMIX_action_execute(SIMIX_process_get_host(process), name, 0);
-    surf_workstation_model->suspend(dummy->simdata->surf_action);
+    surf_workstation_model->suspend(dummy->surf_action);
     SIMIX_register_action_to_condition(dummy, cond);
     __SIMIX_cond_wait(cond);
     SIMIX_unregister_action_to_condition(dummy, cond);
@@ -358,7 +358,7 @@ void SIMIX_process_resume(smx_process_t process)
     process->suspended = 0;
     c = process->cond;
     xbt_fifo_foreach(c->actions, i, act, smx_action_t) {
-      surf_workstation_model->resume(act->simdata->surf_action);
+      surf_workstation_model->resume(act->surf_action);
     }
     SIMIX_cond_signal(c);
     return;
index 62f7e7d..c8550fe 100644 (file)
@@ -291,7 +291,6 @@ static void smpi_cfg_cb_host_speed(const char *name, int pos)
 
 int smpi_run_simulation(int *argc, char **argv)
 {
-  smx_cond_t cond = NULL;
   smx_action_t action = NULL;
 
   xbt_fifo_t actions_failed = xbt_fifo_new();
@@ -329,16 +328,12 @@ int smpi_run_simulation(int *argc, char **argv)
 
   while (SIMIX_solve(actions_done, actions_failed) != -1.0) {
     while ((action = xbt_fifo_pop(actions_failed))) {
-      DEBUG1("** %s failed **", action->name);
-      while ((cond = xbt_fifo_pop(action->cond_list))) {
-        SIMIX_cond_broadcast(cond);
-      }
+      DEBUG1("** %s failed **", SIMIX_action_get_name(action));
+      SIMIX_action_signal_all(action);
     }
     while ((action = xbt_fifo_pop(actions_done))) {
-      DEBUG1("** %s done **", action->name);
-      while ((cond = xbt_fifo_pop(action->cond_list))) {
-        SIMIX_cond_broadcast(cond);
-      }
+      DEBUG1("** %s done **", SIMIX_action_get_name(action));
+      SIMIX_action_signal_all(action);
     }
   }