Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify msg_host_t by inlining the simdata field
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 27 Apr 2012 20:35:49 +0000 (22:35 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 27 Apr 2012 20:35:49 +0000 (22:35 +0200)
include/msg/datatypes.h
src/msg/msg_gos.c
src/msg/msg_host.c
src/msg/msg_mailbox.c
src/msg/msg_private.h
src/msg/msg_process.c

index 37d4073..b95dfd9 100644 (file)
@@ -8,17 +8,34 @@
 #define MSG_DATATYPE_H
 #include "xbt/misc.h"
 #include "xbt/file_stat.h"
+#include "simgrid/simix.h"
 #include "simgrid_config.h"     // for HAVE_TRACING
 
 SG_BEGIN_DECL()
 
-/* ******************************** Host ************************************ */
+/* ******************************** Mailbox ************************************ */
+
+/** @brief Mailbox datatype
+ *  @ingroup msg_task_usage
+ *
+ * Object representing a communication rendez-vous point, on which
+ * the sender finds the receiver it wants to communicate with. As a
+ * MSG user, you will only rarely manipulate any of these objects
+ * directly, since most of the public interface (such as
+ * #MSG_task_send and friends) hide this object behind a string
+ * alias. That mean that you don't provide the mailbox on which you
+ * want to send your task, but only the name of this mailbox. */
+typedef struct s_smx_rvpoint *msg_mailbox_t;
+
 
-typedef struct simdata_host *simdata_host_t;
+/* ******************************** Host ************************************ */
 
 typedef struct m_host {
   char *name;                   /**< @brief host name if any */
-  simdata_host_t simdata;       /**< @brief simulator data */
+  smx_host_t smx_host;          /**< SIMIX representation of this host   */
+#ifdef MSG_USE_DEPRECATED
+  msg_mailbox_t *mailboxes;     /**< the channels  */
+#endif
 } s_m_host_t;
 
 /** @brief Host datatype  
@@ -129,19 +146,6 @@ typedef struct s_smx_process *m_process_t;
 typedef int m_channel_t;
 #endif
 
-/* ******************************** Mailbox ************************************ */
-
-/** @brief Mailbox datatype
- *  @ingroup msg_task_usage
- * 
- * Object representing a communication rendez-vous point, on which
- * the sender finds the receiver it wants to communicate with. As a
- * MSG user, you will only rarely manipulate any of these objects
- * directly, since most of the public interface (such as
- * #MSG_task_send and friends) hide this object behind a string
- * alias. That mean that you don't provide the mailbox on which you
- * want to send your task, but only the name of this mailbox. */
-typedef struct s_smx_rvpoint *msg_mailbox_t;
 
 
 SG_END_DECL()
index 7755839..60dd791 100644 (file)
@@ -53,7 +53,7 @@ MSG_error_t MSG_task_execute(m_task_t task)
   p_simdata = SIMIX_process_self_get_data(self);
   simdata->isused=1;
   simdata->compute =
-      simcall_host_execute(task->name, p_simdata->m_host->simdata->smx_host,
+      simcall_host_execute(task->name, p_simdata->m_host->smx_host,
                            simdata->computation_amount,
                            simdata->priority);
 #ifdef HAVE_TRACING
@@ -146,7 +146,7 @@ MSG_parallel_task_create(const char *name, int host_nb,
   simdata->comm_amount = communication_amount;
 
   for (i = 0; i < host_nb; i++)
-    simdata->host_list[i] = host_list[i]->simdata->smx_host;
+    simdata->host_list[i] = host_list[i]->smx_host;
 
   return task;
 }
index 02a3375..40d0ef4 100644 (file)
 m_host_t __MSG_host_create(smx_host_t workstation)
 {
   const char *name;
-  simdata_host_t simdata = xbt_new0(s_simdata_host_t, 1);
   m_host_t host = xbt_new0(s_m_host_t, 1);
 
   name = SIMIX_host_get_name(workstation);
   /* Host structure */
   host->name = xbt_strdup(name);
-  host->simdata = simdata;
 
-  simdata->smx_host = workstation;
+  host->smx_host = workstation;
 
 #ifdef MSG_USE_DEPRECATED
   int i;
   char alias[MAX_ALIAS_NAME + 1] = { 0 };       /* buffer used to build the key of the mailbox */
 
   if (msg_global->max_channel > 0)
-    simdata->mailboxes = xbt_new0(msg_mailbox_t, msg_global->max_channel);
+    host->mailboxes = xbt_new0(msg_mailbox_t, msg_global->max_channel);
 
   for (i = 0; i < msg_global->max_channel; i++) {
     sprintf(alias, "%s:%d", name, i);
 
     /* the key of the mailbox (in this case) is build from the name of the host and the channel number */
-    simdata->mailboxes[i] = MSG_mailbox_new(alias);
+    host->mailboxes[i] = MSG_mailbox_new(alias);
     memset(alias, 0, MAX_ALIAS_NAME + 1);
   }
 #endif
@@ -86,7 +84,7 @@ m_host_t MSG_get_host_by_name(const char *name)
  */
 MSG_error_t MSG_host_set_data(m_host_t host, void *data)
 {
-  SIMIX_host_set_data(host->simdata->smx_host,data);
+  SIMIX_host_set_data(host->smx_host,data);
 
   return MSG_OK;
 }
@@ -101,7 +99,7 @@ MSG_error_t MSG_host_set_data(m_host_t host, void *data)
 void *MSG_host_get_data(m_host_t host)
 {
 
-  return SIMIX_host_get_data(host->simdata->smx_host);
+  return SIMIX_host_get_data(host->smx_host);
 }
 
 /** \ingroup m_host_management
@@ -114,9 +112,6 @@ void *MSG_host_get_data(m_host_t host)
 const char *MSG_host_get_name(m_host_t host)
 {
 
-  xbt_assert((host != NULL)
-              && (host->simdata != NULL), "Invalid parameters");
-
   /* Return data */
   return (host->name);
 }
@@ -136,20 +131,16 @@ m_host_t MSG_host_self(void)
  */
 void __MSG_host_destroy(m_host_t host)
 {
-  simdata_host_t simdata = NULL;
 
   xbt_assert((host != NULL), "Invalid parameters");
 
   /* Clean simulator data */
-  simdata = (host)->simdata;
 
 #ifdef MSG_USE_DEPRECATED
   if (msg_global->max_channel > 0)
-    free(simdata->mailboxes);
+    free(host->mailboxes);
 #endif
 
-  free(simdata);
-
   /* Clean host structure */
   free(host->name);
   free(host);
@@ -219,7 +210,7 @@ double MSG_get_host_speed(m_host_t h)
 {
   xbt_assert((h != NULL), "Invalid parameters");
 
-  return (simcall_host_get_speed(h->simdata->smx_host));
+  return (simcall_host_get_speed(h->smx_host));
 }
 
 /** \ingroup m_host_management
@@ -244,7 +235,7 @@ xbt_dict_t MSG_host_get_properties(m_host_t host)
 {
   xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
 
-  return (simcall_host_get_properties(host->simdata->smx_host));
+  return (simcall_host_get_properties(host->smx_host));
 }
 
 
@@ -257,5 +248,5 @@ xbt_dict_t MSG_host_get_properties(m_host_t host)
 int MSG_host_is_avail(m_host_t host)
 {
   xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
-  return (simcall_host_get_state(host->simdata->smx_host));
+  return (simcall_host_get_state(host->smx_host));
 }
index 7279654..9b94299 100644 (file)
@@ -41,7 +41,7 @@ MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
                                          m_host_t host)
 {
   return simcall_rdv_comm_count_by_host(mailbox,
-                                      host->simdata->smx_host);
+                                      host->smx_host);
 }
 
 msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias)
index 9c8fa72..7a812dd 100644 (file)
 SG_BEGIN_DECL()
 
 /**************** datatypes **********************************/
-typedef struct simdata_host {
-  smx_host_t smx_host;          /* SURF modeling                                                                */
-  msg_mailbox_t *mailboxes;     /* mailboxes to store msg tasks of of the host  */
-} s_simdata_host_t;
 
 /********************************* Task **************************************/
 
index 43b782b..60e0386 100644 (file)
@@ -231,7 +231,7 @@ MSG_error_t MSG_process_migrate(m_process_t process, m_host_t host)
   m_host_t now = simdata->m_host;
   TRACE_msg_process_change_host(process, now, host);
 #endif
-  simcall_process_change_host(process, host->simdata->smx_host);
+  simcall_process_change_host(process, host->smx_host);
   return MSG_OK;
 }