From d0672b1000bacd57037a1138e90553af71b50a53 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 27 Apr 2012 22:35:49 +0200 Subject: [PATCH] simplify msg_host_t by inlining the simdata field --- include/msg/datatypes.h | 36 ++++++++++++++++++++---------------- src/msg/msg_gos.c | 4 ++-- src/msg/msg_host.c | 27 +++++++++------------------ src/msg/msg_mailbox.c | 2 +- src/msg/msg_private.h | 4 ---- src/msg/msg_process.c | 2 +- 6 files changed, 33 insertions(+), 42 deletions(-) diff --git a/include/msg/datatypes.h b/include/msg/datatypes.h index 37d407320d..b95dfd9317 100644 --- a/include/msg/datatypes.h +++ b/include/msg/datatypes.h @@ -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() diff --git a/src/msg/msg_gos.c b/src/msg/msg_gos.c index 7755839fa3..60dd79109b 100644 --- a/src/msg/msg_gos.c +++ b/src/msg/msg_gos.c @@ -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; } diff --git a/src/msg/msg_host.c b/src/msg/msg_host.c index 02a3375faf..40d0ef4471 100644 --- a/src/msg/msg_host.c +++ b/src/msg/msg_host.c @@ -26,28 +26,26 @@ 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)); } diff --git a/src/msg/msg_mailbox.c b/src/msg/msg_mailbox.c index 7279654fc4..9b94299312 100644 --- a/src/msg/msg_mailbox.c +++ b/src/msg/msg_mailbox.c @@ -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) diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index 9c8fa72c39..7a812dd0dd 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -20,10 +20,6 @@ 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 **************************************/ diff --git a/src/msg/msg_process.c b/src/msg/msg_process.c index 43b782b53a..60e03864b5 100644 --- a/src/msg/msg_process.c +++ b/src/msg/msg_process.c @@ -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; } -- 2.20.1