Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make MSG fade away (part 2)
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 23 Jan 2018 14:14:54 +0000 (15:14 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 23 Jan 2018 14:14:54 +0000 (15:14 +0100)
move more function to sg_host_* and add the MSG macros
fix dumb 32-bit tests too

include/simgrid/host.h
include/simgrid/msg.h
src/msg/msg_host.cpp
src/simgrid/host.cpp
teshsuite/msg/app-token-ring/app-token-ring.c
teshsuite/msg/platform-properties/platform-properties.c

index 8e76b05..60696b6 100644 (file)
@@ -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
  *
index dd20c30..be2b3f0 100644 (file)
@@ -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)
index 48fab18..784265c 100644 (file)
@@ -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);
 }
 
-
-
 }
index c1200be..3c9fe63 100644 (file)
@@ -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);
index 4316fd6..5018672 100644 (file)
@@ -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,
index b87f640..69bc00a 100644 (file)
@@ -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) {