From: Martin Quinson Date: Sun, 10 Jan 2016 09:42:16 +0000 (+0100) Subject: Do the Right Thing for the host_(get/set)_pstate X-Git-Tag: v3_13~1293 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/be27c3513d2b7d273749db733659600b10dc0a54?ds=sidebyside Do the Right Thing for the host_(get/set)_pstate - 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. --- diff --git a/include/simgrid/Host.hpp b/include/simgrid/Host.hpp index 42fa5ec1da..6e1f6c0784 100644 --- a/include/simgrid/Host.hpp +++ b/include/simgrid/Host.hpp @@ -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); diff --git a/include/simgrid/host.h b/include/simgrid/host.h index 428e2b7f6c..2c3ab3892e 100644 --- a/include/simgrid/host.h +++ b/include/simgrid/host.h @@ -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() diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index b2d96615fd..11fa465a37 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -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); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index ec27cee46e..52f292a25a 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -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); diff --git a/src/msg/msg_host.cpp b/src/msg/msg_host.cpp index 85bf83fedf..31fd77f1cf 100644 --- a/src/msg/msg_host.cpp +++ b/src/msg/msg_host.cpp @@ -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. * diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index b3f5bd6962..9d3255bd83 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -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) diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 7d1ff6e0d8..4f1d8cd0fd 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -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) diff --git a/src/smpi/smpi_dvfs.c b/src/smpi/smpi_dvfs.c index 57da46421e..feb2051c9b 100644 --- a/src/smpi/smpi_dvfs.c +++ b/src/smpi/smpi_dvfs.c @@ -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