Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do the Right Thing for the host_(get/set)_pstate
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 10 Jan 2016 09:42:16 +0000 (10:42 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 10 Jan 2016 09:42:16 +0000 (10:42 +0100)
- The prefered public interface is in simgrid::Host
  - the getter directly calls pimpl_cpu->getPState()
  - the setter simcalls to the pimpl, without diverting to simix
  - (this will be automatically forwarded to Java with SWIG one day)
- The C public interface is sg_host_(get/set)_pstate
  - MSG_host_(get/set)_pstate is #defined to this for compatibility
  - SMPI adapts the interface in smpi_host_(get/set)_pstate to make
      the receiver host implicit.
    I don't see the point but don't want to mess with SMPI yet.

One day, the whole of SimGrid will be organized this way. One day.

include/simgrid/Host.hpp
include/simgrid/host.h
include/simgrid/msg.h
include/simgrid/simix.h
src/msg/msg_host.cpp
src/simgrid/host.cpp
src/simix/libsmx.cpp
src/smpi/smpi_dvfs.c

index 42fa5ec..6e1f6c0 100644 (file)
@@ -46,7 +46,8 @@ public:
   xbt_swag_t getProcessList();
   double getCurrentPowerPeak();
   double getPowerPeakAt(int pstate_index);
-  void setPstate(int pstate_index);
+  void setPState(int pstate_index);
+  int getPState();
   double getWattMinAt(int pstate);
   double getWattMaxAt(int pstate);
   void getParams(vm_params_t params);
index 428e2b7..2c3ab38 100644 (file)
@@ -60,6 +60,7 @@ XBT_PUBLIC(int) sg_host_is_on(sg_host_t host);
 
 XBT_PUBLIC(int) sg_host_get_nb_pstates(sg_host_t host);
 XBT_PUBLIC(int) sg_host_get_pstate(sg_host_t host);
+XBT_PUBLIC(void) sg_host_set_pstate(sg_host_t host,int pstate);
 XBT_PUBLIC(double) sg_host_get_consumed_energy(sg_host_t host);
 
 SG_END_DECL()
index b2d9661..11fa465 100644 (file)
@@ -311,8 +311,8 @@ XBT_PUBLIC(double) MSG_host_get_wattmax_at(msg_host_t host, int pstate);
 XBT_PUBLIC(double) MSG_host_get_power_peak_at(msg_host_t h, int pstate);
 XBT_PUBLIC(double) MSG_host_get_current_power_peak(msg_host_t h);
 XBT_PUBLIC(int)    MSG_host_get_nb_pstates(msg_host_t h);
-XBT_PUBLIC(void)   MSG_host_set_pstate(msg_host_t h, int pstate);
-XBT_PUBLIC(int)    MSG_host_get_pstate(msg_host_t host);
+#define MSG_host_get_pstate(h)         sg_host_get_pstate(h)
+#define MSG_host_set_pstate(h, pstate) sg_host_set_pstate(h, pstate)
 XBT_PUBLIC(xbt_dynar_t) MSG_hosts_as_dynar(void);
 XBT_PUBLIC(int) MSG_get_host_number(void);
 XBT_PUBLIC(void) MSG_host_get_params(msg_host_t ind_pm, vm_params_t params);
index ec27cee..52f292a 100644 (file)
@@ -258,7 +258,6 @@ XBT_PUBLIC(void) simcall_host_set_data(sg_host_t host, void *data);
 
 XBT_PUBLIC(double) simcall_host_get_current_power_peak(sg_host_t host);
 XBT_PUBLIC(double) simcall_host_get_power_peak_at(sg_host_t host, int pstate_index);
-XBT_PUBLIC(void) simcall_host_set_pstate(sg_host_t host, int pstate_index);
 XBT_PUBLIC(double) simcall_host_get_wattmin_at(sg_host_t host, int pstate);
 XBT_PUBLIC(double) simcall_host_get_wattmax_at(sg_host_t host, int pstate);
 
index 85bf83f..31fd77f 100644 (file)
@@ -348,25 +348,6 @@ int MSG_host_get_nb_pstates(msg_host_t host) {
          return sg_host_get_nb_pstates(host);
 }
 
-/** \ingroup m_host_management
- * \brief Sets the speed of the processor (in flop/s) at a given pstate. See also @ref SURF_plugin_energy.
- *
- * \param  host host to test
- * \param pstate_index pstate to switch to
- */
-void MSG_host_set_pstate(msg_host_t host, int pstate_index) {
-         xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
-    host->setPstate(pstate_index);
-}
-/** \ingroup m_host_management
- * \brief Gets the pstate at which the given host is currently running. See also @ref SURF_plugin_energy.
- *
- * \param  host host to test
- */
-int MSG_host_get_pstate(msg_host_t host) {
-         return sg_host_get_pstate(host);
-}
-
 /** \ingroup m_host_management
  * \brief Return the total energy consumed by a host (in Joules). See also @ref SURF_plugin_energy.
  *
index b3f5bd6..9d3255b 100644 (file)
@@ -162,7 +162,14 @@ int sg_host_get_nb_pstates(sg_host_t host) {
  *  See also @ref SURF_plugin_energy.
  */
 int sg_host_get_pstate(sg_host_t host) {
-       return host->p_cpu->getPState();
+  return host->getPState();
+}
+/** @brief Sets the pstate at which that host should run.
+ *
+ *  See also @ref SURF_plugin_energy.
+ */
+void sg_host_set_pstate(sg_host_t host,int pstate) {
+  host->setPState(pstate);
 }
 
 namespace simgrid {
@@ -248,13 +255,18 @@ Host* Host::by_name_or_create(const char* name)
   return host;
 }
 
-/** Set the pstate at which the host should run */
-void Host::setPstate(int pstate_index)
+/** @brief Set the pstate at which the host should run */
+void Host::setPState(int pstate_index)
 {
   simgrid::simix::kernel(std::bind(
       &simgrid::surf::Cpu::setPState, p_cpu, pstate_index
   ));
 }
+/** @brief Retrieve the pstate at which the host is currently running */
+int Host::getPState()
+{
+  return p_cpu->getPState();
+}
 
 /** Get the amount of watt dissipated at the given pstate when the host is idling */
 double Host::getWattMinAt(int pstate)
index 7d1ff6e..4f1d8cd 100644 (file)
@@ -63,13 +63,6 @@ double simcall_host_get_power_peak_at(sg_host_t host, int pstate_index)
   return host->getPowerPeakAt(pstate_index);
 }
 
-/** \ingroup simix_host_management
- * \deprecated */
-void simcall_host_set_pstate(sg_host_t host, int pstate_index)
-{
-  host->setPstate(pstate_index);
-}
-
 /** \ingroup simix_host_management
  * \deprecated */
 double simcall_host_get_wattmin_at(msg_host_t host, int pstate)
index 57da464..feb2051 100644 (file)
@@ -48,7 +48,7 @@ int smpi_get_host_nb_pstates(void)
  */
 void smpi_set_host_pstate(int pstate_index)
 {
-  simcall_host_set_pstate(SIMIX_host_self(), pstate_index);
+  sg_host_set_pstate(SIMIX_host_self(), pstate_index);
 }
 /**
  * \brief Gets the pstate at which the processor currently running