From 87abed69d2734abfc0474c30b6f6d04b25a2c8ac Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 23 Jan 2018 15:14:54 +0100 Subject: [PATCH] Make MSG fade away (part 2) move more function to sg_host_* and add the MSG macros fix dumb 32-bit tests too --- include/simgrid/host.h | 30 +++++++ include/simgrid/msg.h | 11 --- src/msg/msg_host.cpp | 82 ------------------- src/simgrid/host.cpp | 60 ++++++++++++++ teshsuite/msg/app-token-ring/app-token-ring.c | 2 +- .../platform-properties/platform-properties.c | 2 +- 6 files changed, 92 insertions(+), 95 deletions(-) diff --git a/include/simgrid/host.h b/include/simgrid/host.h index 8e76b051d8..60696b6496 100644 --- a/include/simgrid/host.h +++ b/include/simgrid/host.h @@ -46,11 +46,29 @@ XBT_PUBLIC(sg_host_t) sg_host_by_name(const char *name); #define MSG_host_by_name(name) sg_host_by_name(name) #define MSG_get_host_by_name(n) sg_host_by_name(n) /* Rewrite the old name into the new one transparently */ +/** \ingroup m_host_management + * + * \brief Return the name of the #msg_host_t. */ XBT_PUBLIC(const char*) sg_host_get_name(sg_host_t host); +#define MSG_host_get_name(host) sg_host_get_name(host) // ========== User Data ============== +/** \ingroup m_host_management + * + * \brief Return the user data of a #msg_host_t. + * + * This functions returns the user data associated to \a host if it is possible. + */ XBT_PUBLIC(void*) sg_host_user(sg_host_t host); +#define MSG_host_get_data(host) sg_host_user(host) +/** \ingroup m_host_management + * + * \brief Set the user data of a #msg_host_t. + * + * This functions attach \a data to \a host if it is possible. + */ XBT_PUBLIC(void) sg_host_user_set(sg_host_t host, void* userdata); +#define MSG_host_set_data(host, data) sg_host_user_set(host, data) XBT_PUBLIC(void) sg_host_user_destroy(sg_host_t host); // ========= storage related functions ============ @@ -78,6 +96,9 @@ XBT_PUBLIC(double) sg_host_speed(sg_host_t host); #define MSG_host_get_speed(host) sg_host_speed(host) XBT_PUBLIC(double) sg_host_get_available_speed(sg_host_t host); +XBT_PUBLIC(int) sg_host_core_count(sg_host_t host); +#define MSG_host_get_core_number(host) sg_host_core_count(host) + /** \ingroup m_process_management * \brief Return the location on which a process is running. * \param process a process (nullptr means the current one) @@ -101,6 +122,15 @@ XBT_PUBLIC(int) sg_host_get_pstate(sg_host_t host); XBT_PUBLIC(void) sg_host_set_pstate(sg_host_t host,int pstate); #define MSG_host_set_pstate(h, pstate) sg_host_set_pstate(h, pstate) /* (same here) */ +XBT_PUBLIC(void) sg_host_turn_on(sg_host_t host); +#define MSG_host_on(h) sg_host_turn_on(h) +XBT_PUBLIC(void) sg_host_turn_off(sg_host_t host); +#define MSG_host_off(h) sg_host_turn_off(h) +XBT_PUBLIC(int) sg_host_is_on(sg_host_t host); +#define MSG_host_is_on(h) sg_host_is_on(h) +XBT_PUBLIC(int) sg_host_is_off(sg_host_t host); +#define MSG_host_is_off(h) sg_host_is_off(h) + /** \ingroup m_host_management * \brief Returns a xbt_dict_t consisting of the list of properties assigned to this host * diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index dd20c3081a..be2b3f057a 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -183,18 +183,7 @@ XBT_PUBLIC(sg_size_t) MSG_storage_read(msg_storage_t storage, sg_size_t size); XBT_PUBLIC(sg_size_t) MSG_storage_write(msg_storage_t storage, sg_size_t size); /************************** Host handling ***********************************/ -XBT_PUBLIC(msg_error_t) MSG_host_set_data(msg_host_t host, void *data); -XBT_PUBLIC(void *) MSG_host_get_data(msg_host_t host); -/** \ingroup m_host_management - * - * \brief Return the name of the #msg_host_t. */ -#define MSG_host_get_name(host) sg_host_get_name(host) -XBT_PUBLIC(void) MSG_host_on(msg_host_t host); -XBT_PUBLIC(void) MSG_host_off(msg_host_t host); -XBT_PUBLIC(int) MSG_host_get_core_number(msg_host_t h); XBT_PUBLIC(void) MSG_host_get_process_list(msg_host_t h, xbt_dynar_t whereto); -XBT_PUBLIC(int) MSG_host_is_on(msg_host_t h); -XBT_PUBLIC(int) MSG_host_is_off(msg_host_t h); XBT_ATTRIB_DEPRECATED_v320("Use MSG_host_get_speed(): v3.20 will drop MSG_host_get_current_power_peak() " "completely.") static inline double MSG_host_get_current_power_peak(msg_host_t host) diff --git a/src/msg/msg_host.cpp b/src/msg/msg_host.cpp index 48fab18c92..784265ce1a 100644 --- a/src/msg/msg_host.cpp +++ b/src/msg/msg_host.cpp @@ -23,61 +23,6 @@ extern "C" { */ /********************************* Host **************************************/ -/** \ingroup m_host_management - * - * \brief Set the user data of a #msg_host_t. - * - * This functions attach \a data to \a host if it is possible. - */ -msg_error_t MSG_host_set_data(msg_host_t host, void *data) { - sg_host_user_set(host, data); - return MSG_OK; -} - -/** \ingroup m_host_management - * - * \brief Return the user data of a #msg_host_t. - * - * This functions returns the user data associated to \a host if it is possible. - */ -void *MSG_host_get_data(msg_host_t host) { - return sg_host_user(host); -} - -/** \ingroup m_host_management - * - * \brief Start the host if it is off - * - * See also #MSG_host_is_on() and #MSG_host_is_off() to test the current state of the host and @ref plugin_energy - * for more info on DVFS. - */ -void MSG_host_on(msg_host_t host) -{ - host->turnOn(); -} - -/** \ingroup m_host_management - * - * \brief Stop the host if it is on - * - * See also #MSG_host_is_on() and #MSG_host_is_off() to test the current state of the host and @ref plugin_energy - * for more info on DVFS. - */ -void MSG_host_off(msg_host_t host) -{ - host->turnOff(); -} - - -/** \ingroup m_host_management - * \brief Return the number of cores. - * - * \param host a host - * \return the number of cores - */ -int MSG_host_get_core_number(msg_host_t host) { - return host->getCoreCount(); -} /** \ingroup m_host_management * \brief Return the list of processes attached to an host. @@ -94,31 +39,6 @@ void MSG_host_get_process_list(msg_host_t host, xbt_dynar_t whereto) } } -/** @ingroup m_host_management - * @brief Determine if a host is up and running. - * - * See also #MSG_host_on() and #MSG_host_off() to switch the host ON and OFF and @ref plugin_energy for more info on - * DVFS. - * - * @param host host to test - * @return Returns true if the host is up and running, and false if it's currently down - */ -int MSG_host_is_on(msg_host_t host) -{ - return host->isOn(); -} - -/** @ingroup m_host_management - * @brief Determine if a host is currently off. - * - * See also #MSG_host_on() and #MSG_host_off() to switch the host ON and OFF and @ref plugin_energy for more info on - * DVFS. - */ -int MSG_host_is_off(msg_host_t host) -{ - return host->isOff(); -} - /** \ingroup m_host_management * \brief Return the speed of the processor (in flop/s) at a given pstate. See also @ref plugin_energy. * @@ -131,6 +51,4 @@ double MSG_host_get_power_peak_at(msg_host_t host, int pstate_index) { return host->getPstateSpeed(pstate_index); } - - } diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index c1200be21f..3c9fe63827 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -126,6 +126,17 @@ double sg_host_speed(sg_host_t host) return host->getSpeed(); } +/** \ingroup m_host_management + * \brief Return the number of cores. + * + * \param host a host + * \return the number of cores + */ +int sg_host_core_count(sg_host_t host) +{ + return host->getCoreCount(); +} + double sg_host_get_available_speed(sg_host_t host) { return host->pimpl_cpu->getAvailableSpeed(); @@ -154,6 +165,55 @@ void sg_host_set_pstate(sg_host_t host,int pstate) { host->setPstate(pstate); } +/** \ingroup m_host_management + * + * \brief Start the host if it is off + * + * See also #sg_host_is_on() and #sg_host_is_off() to test the current state of the host and @ref plugin_energy + * for more info on DVFS. + */ +void sg_host_turn_on(sg_host_t host) +{ + host->turnOn(); +} + +/** \ingroup m_host_management + * + * \brief Stop the host if it is on + * + * See also #MSG_host_is_on() and #MSG_host_is_off() to test the current state of the host and @ref plugin_energy + * for more info on DVFS. + */ +void sg_host_turn_off(sg_host_t host) +{ + host->turnOff(); +} + +/** @ingroup m_host_management + * @brief Determine if a host is up and running. + * + * See also #sg_host_turn_on() and #sg_host_turn_off() to switch the host ON and OFF and @ref plugin_energy for more + * info on DVFS. + * + * @param host host to test + * @return Returns true if the host is up and running, and false if it's currently down + */ +int sg_host_is_on(sg_host_t host) +{ + return host->isOn(); +} + +/** @ingroup m_host_management + * @brief Determine if a host is currently off. + * + * See also #sg_host_turn_on() and #sg_host_turn_off() to switch the host ON and OFF and @ref plugin_energy for more + * info on DVFS. + */ +int sg_host_is_off(sg_host_t host) +{ + return host->isOff(); +} + /** @brief Get the properties of an host */ xbt_dict_t sg_host_get_properties(sg_host_t host) { xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f); diff --git a/teshsuite/msg/app-token-ring/app-token-ring.c b/teshsuite/msg/app-token-ring/app-token-ring.c index 4316fd6e4c..50186721ca 100644 --- a/teshsuite/msg/app-token-ring/app-token-ring.c +++ b/teshsuite/msg/app-token-ring/app-token-ring.c @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) MSG_create_environment(argv[1]); /* - Load the platform description */ xbt_dynar_t hosts = MSG_hosts_as_dynar(); - XBT_INFO("Number of hosts '%lu'", MSG_get_host_number()); + XBT_INFO("Number of hosts '%zu'", MSG_get_host_number()); unsigned int i; msg_host_t h; xbt_dynar_foreach (hosts, i, diff --git a/teshsuite/msg/platform-properties/platform-properties.c b/teshsuite/msg/platform-properties/platform-properties.c index b87f6409bd..69bc00aac4 100644 --- a/teshsuite/msg/platform-properties/platform-properties.c +++ b/teshsuite/msg/platform-properties/platform-properties.c @@ -114,7 +114,7 @@ int main(int argc, char* argv[]) MSG_create_environment(argv[1]); - XBT_INFO("There are %lu hosts in the environment", MSG_get_host_number()); + XBT_INFO("There are %zu hosts in the environment", MSG_get_host_number()); xbt_dynar_t hosts = MSG_hosts_as_dynar(); xbt_dynar_foreach (hosts, i, host) { -- 2.20.1