Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'dvfs'
authoracarpena <alexandra.carpen-amarie@inria.fr>
Fri, 5 Jul 2013 01:53:41 +0000 (01:53 +0000)
committeracarpena <alexandra.carpen-amarie@inria.fr>
Fri, 5 Jul 2013 01:53:41 +0000 (01:53 +0000)
Added DVFS and energy consumption support.

1  2 
include/msg/msg.h
include/simgrid/simix.h
src/msg/msg_host.c
src/simix/smx_host.c
src/simix/smx_host_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c

diff --combined include/msg/msg.h
@@@ -101,10 -101,15 +101,16 @@@ XBT_PUBLIC(int) MSG_get_host_msgload(ms
  /* int MSG_get_msgload(void); This function lacks specification; discard it */
  XBT_PUBLIC(double) MSG_get_host_speed(msg_host_t h);
  XBT_PUBLIC(int) MSG_host_get_core_number(msg_host_t h);
 +XBT_PUBLIC(xbt_swag_t) MSG_host_get_process_list(msg_host_t h);
  XBT_PUBLIC(int) MSG_host_is_avail(msg_host_t h);
  XBT_PUBLIC(void) __MSG_host_destroy(msg_host_priv_t host);
  
+ XBT_PUBLIC(double) MSG_get_host_power_peak_at(msg_host_t h, int pstate_index);
+ XBT_PUBLIC(double) MSG_get_host_current_power_peak(msg_host_t h);
+ XBT_PUBLIC(int) MSG_get_host_nb_pstates(msg_host_t h);
+ XBT_PUBLIC(void) MSG_set_host_power_peak_at(msg_host_t h, int pstate);
+ XBT_PUBLIC(double) MSG_get_host_consumed_energy(msg_host_t h);
  /*property handlers*/
  XBT_PUBLIC(xbt_dict_t) MSG_host_get_properties(msg_host_t host);
  XBT_PUBLIC(const char *) MSG_host_get_property_value(msg_host_t host,
diff --combined include/simgrid/simix.h
@@@ -259,6 -259,7 +259,7 @@@ XBT_PUBLIC(void*) SIMIX_host_self_get_d
  XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
  XBT_PUBLIC(void) SIMIX_host_set_data(smx_host_t host, void *data);
  
  /********************************* Process ************************************/
  XBT_PUBLIC(int) SIMIX_process_count(void);
  XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
@@@ -294,7 -295,6 +295,7 @@@ XBT_PUBLIC(smx_host_t) simcall_host_get
  XBT_PUBLIC(const char *) simcall_host_get_name(smx_host_t host);
  XBT_PUBLIC(xbt_dict_t) simcall_host_get_properties(smx_host_t host);
  XBT_PUBLIC(int) simcall_host_get_core(smx_host_t host);
 +XBT_PUBLIC(xbt_swag_t) simcall_host_get_process_list(smx_host_t host);
  XBT_PUBLIC(double) simcall_host_get_speed(smx_host_t host);
  XBT_PUBLIC(double) simcall_host_get_available_speed(smx_host_t host);
  /* Two possible states, 1 - CPU ON and 0 CPU OFF */
@@@ -303,6 -303,12 +304,12 @@@ XBT_PUBLIC(void *) simcall_host_get_dat
  
  XBT_PUBLIC(void) simcall_host_set_data(smx_host_t host, void *data);
  
+ XBT_PUBLIC(double) simcall_host_get_current_power_peak(smx_host_t host);
+ XBT_PUBLIC(double) simcall_host_get_power_peak_at(smx_host_t host, int pstate_index);
+ XBT_PUBLIC(int) simcall_host_get_nb_pstates(smx_host_t host);
+ XBT_PUBLIC(void) simcall_host_set_power_peak_at(smx_host_t host, int pstate_index);
+ XBT_PUBLIC(double) simcall_host_get_consumed_energy(smx_host_t host);
  XBT_PUBLIC(smx_action_t) simcall_host_execute(const char *name, smx_host_t host,
                                                  double computation_amount,
                                                  double priority);
diff --combined src/msg/msg_host.c
@@@ -204,10 -204,7 +204,10 @@@ double MSG_get_host_speed(msg_host_t h
  
  
  /** \ingroup m_host_management
 - * \brief Return the number of core.
 + * \brief Return the number of cores.
 + *
 + * \param host a host
 + * \return the number of cores
   */
  int MSG_host_get_core_number(msg_host_t h)
  {
    return (simcall_host_get_core(h));
  }
  
 +/** \ingroup m_host_management
 + * \brief Return the list of processes attached to an host.
 + *
 + * \param host a host
 + * \return a swag with the attached processes
 + */
 +xbt_swag_t MSG_host_get_process_list(msg_host_t h)
 +{
 +  xbt_assert((h != NULL), "Invalid parameters");
 +
 +  return (simcall_host_get_process_list(h));
 +}
 +
 +
  /** \ingroup m_host_management
   * \brief Returns the value of a given host property
   *
@@@ -280,3 -263,62 +280,62 @@@ int MSG_host_is_avail(msg_host_t host
    xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
    return (simcall_host_get_state(host));
  }
+ /** \ingroup m_host_management
+  * \brief Return the speed of the processor (in flop/s) at a given pstate
+  *
+  * \param  host host to test
+  * \param pstate_index pstate to test
+  * \return Returns the processor speed associated with pstate_index
+  */
+ double MSG_get_host_power_peak_at(msg_host_t host, int pstate_index) {
+         xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
+         return (simcall_host_get_power_peak_at(host, pstate_index));
+ }
+ /** \ingroup m_host_management
+  * \brief Return the current speed of the processor (in flop/s)
+  *
+  * \param  host host to test
+  * \return Returns the current processor speed
+  */
+ double MSG_get_host_current_power_peak(msg_host_t host) {
+         xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
+         return simcall_host_get_current_power_peak(host);
+ }
+ /** \ingroup m_host_management
+  * \brief Return the number of pstates defined for a host
+  *
+  * \param  host host to test
+  */
+ int MSG_get_host_nb_pstates(msg_host_t host) {
+         xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
+         return (simcall_host_get_nb_pstates(host));
+ }
+ /** \ingroup m_host_management
+  * \brief Sets the speed of the processor (in flop/s) at a given pstate
+  *
+  * \param  host host to test
+  * \param pstate_index pstate to switch to
+  */
+ void MSG_set_host_power_peak_at(msg_host_t host, int pstate_index) {
+         xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
+         simcall_host_set_power_peak_at(host, pstate_index);
+ }
+ /** \ingroup m_host_management
+  * \brief Return the total energy consumed by a host (in Joules)
+  *
+  * \param  host host to test
+  * \return Returns the consumed energy
+  */
+ double MSG_get_host_consumed_energy(msg_host_t host) {
+         xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
+         return simcall_host_get_consumed_energy(host);
+ }
diff --combined src/simix/smx_host.c
@@@ -158,16 -158,6 +158,16 @@@ int SIMIX_host_get_core(smx_host_t host
        get_core(host);
  }
  
 +xbt_swag_t SIMIX_pre_host_get_process_list(smx_simcall_t simcall, smx_host_t host){
 +  return SIMIX_host_get_process_list(host);
 +}
 +
 +xbt_swag_t SIMIX_host_get_process_list(smx_host_t host){
 +  xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 +  smx_host_priv_t host_priv = SIMIX_host_priv(host);
 +
 +  return host_priv->process_list;
 +}
  
  
  double SIMIX_pre_host_get_available_speed(smx_simcall_t simcall, smx_host_t host){
@@@ -180,6 -170,55 +180,55 @@@ double SIMIX_host_get_available_speed(s
        get_available_speed(host);
  }
  
+ double SIMIX_pre_host_get_current_power_peak(smx_simcall_t simcall, smx_host_t host){
+   return SIMIX_host_get_current_power_peak(host);
+ }
+ double SIMIX_host_get_current_power_peak(smx_host_t host) {
+         xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
+         return surf_workstation_model->extension.workstation.
+                     get_current_power_peak(host);
+ }
+ double SIMIX_pre_host_get_power_peak_at(smx_simcall_t simcall, smx_host_t host, int pstate_index){
+   return SIMIX_host_get_power_peak_at(host, pstate_index);
+ }
+ double SIMIX_host_get_power_peak_at(smx_host_t host, int pstate_index) {
+         xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
+         return surf_workstation_model->extension.workstation.
+             get_power_peak_at(host, pstate_index);
+ }
+ int SIMIX_pre_host_get_nb_pstates(smx_simcall_t simcall, smx_host_t host){
+   return SIMIX_host_get_nb_pstates(host);
+ }
+ int SIMIX_host_get_nb_pstates(smx_host_t host) {
+         xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
+         return surf_workstation_model->extension.workstation.
+             get_nb_pstates(host);
+ }
+ void SIMIX_pre_host_set_power_peak_at(smx_simcall_t simcall, smx_host_t host, int pstate_index){
+   SIMIX_host_set_power_peak_at(host, pstate_index);
+ }
+ void SIMIX_host_set_power_peak_at(smx_host_t host, int pstate_index) {
+         xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
+         surf_workstation_model->extension.workstation.
+             set_power_peak_at(host, pstate_index);
+ }
+ double SIMIX_pre_host_get_consumed_energy(smx_simcall_t simcall, smx_host_t host){
+   return SIMIX_host_get_consumed_energy(host);
+ }
+ double SIMIX_host_get_consumed_energy(smx_host_t host) {
+         xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
+         return surf_workstation_model->extension.workstation.
+                     get_consumed_energy(host);
+ }
  int SIMIX_pre_host_get_state(smx_simcall_t simcall, smx_host_t host){
    return SIMIX_host_get_state(host);
  }
@@@ -39,10 -39,14 +39,15 @@@ void SIMIX_host_restart_processes(smx_h
  void SIMIX_host_autorestart(smx_host_t host);
  xbt_dict_t SIMIX_host_get_properties(smx_host_t host);
  int SIMIX_host_get_core(smx_host_t host);
 +xbt_swag_t SIMIX_host_get_process_list(smx_host_t host);
  double SIMIX_host_get_speed(smx_host_t host);
  double SIMIX_host_get_available_speed(smx_host_t host);
  int SIMIX_host_get_state(smx_host_t host);
+ double SIMIX_host_get_current_power_peak(smx_host_t host);
+ double SIMIX_host_get_power_peak_at(smx_host_t host, int pstate_index);
+ int SIMIX_host_get_nb_pstates(smx_host_t host);
+ double SIMIX_host_get_consumed_energy(smx_host_t host);
+ void SIMIX_host_set_power_peak_at(smx_host_t host, int pstate_index);
  smx_action_t SIMIX_host_execute(const char *name,
      smx_host_t host, double computation_amount, double priority);
  smx_action_t SIMIX_host_parallel_execute(const char *name,
@@@ -62,10 -66,14 +67,15 @@@ const char* SIMIX_pre_host_self_get_nam
  const char* SIMIX_pre_host_get_name(smx_simcall_t, smx_host_t);
  xbt_dict_t SIMIX_pre_host_get_properties(smx_simcall_t, smx_host_t);
  int SIMIX_pre_host_get_core(smx_simcall_t, smx_host_t);
 +xbt_swag_t SIMIX_pre_host_get_process_list(smx_simcall_t, smx_host_t host);
  double SIMIX_pre_host_get_speed(smx_simcall_t, smx_host_t);
  double SIMIX_pre_host_get_available_speed(smx_simcall_t, smx_host_t);
  int SIMIX_pre_host_get_state(smx_simcall_t, smx_host_t);
+ double SIMIX_pre_host_get_current_power_peak(smx_simcall_t, smx_host_t);
+ double SIMIX_pre_host_get_power_peak_at(smx_simcall_t, smx_host_t host, int pstate_index);
+ int SIMIX_pre_host_get_nb_pstates(smx_simcall_t, smx_host_t host);
+ void SIMIX_pre_host_set_power_peak_at(smx_simcall_t, smx_host_t host, int pstate_index);
+ double SIMIX_pre_host_get_consumed_energy(smx_simcall_t, smx_host_t);
  void* SIMIX_pre_host_self_get_data(smx_simcall_t);
  void* SIMIX_pre_host_get_data(smx_simcall_t, smx_host_t);
  void SIMIX_pre_host_set_data(smx_simcall_t, smx_host_t, void*);
@@@ -263,12 -263,16 +263,17 @@@ ACTION(SIMCALL_HOST_GET_BY_NAME, host_g
  ACTION(SIMCALL_HOST_GET_NAME, host_get_name, WITH_ANSWER, TSTRING(result), TSPEC(host, smx_host_t)) sep \
  ACTION(SIMCALL_HOST_GET_PROPERTIES, host_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSPEC(host, smx_host_t)) sep \
  ACTION(SIMCALL_HOST_GET_CORE, host_get_core, WITH_ANSWER, TINT(result), TSPEC(host, smx_host_t)) sep \
 +ACTION(SIMCALL_HOST_GET_PROCESS_LIST, host_get_process_list, WITH_ANSWER, TSPEC(result, xbt_swag_t), TSPEC(host, smx_host_t)) sep \
  ACTION(SIMCALL_HOST_GET_SPEED, host_get_speed, WITH_ANSWER, TDOUBLE(result), TSPEC(host, smx_host_t)) sep \
  ACTION(SIMCALL_HOST_GET_AVAILABLE_SPEED, host_get_available_speed, WITH_ANSWER, TDOUBLE(result), TSPEC(host, smx_host_t)) sep \
  ACTION(SIMCALL_HOST_GET_STATE, host_get_state, WITH_ANSWER, TINT(result), TSPEC(host, smx_host_t)) sep \
  ACTION(SIMCALL_HOST_GET_DATA, host_get_data, WITH_ANSWER, TPTR(result), TSPEC(host, smx_host_t)) sep \
  ACTION(SIMCALL_HOST_SET_DATA, host_set_data, WITH_ANSWER, TVOID(result), TSPEC(host, smx_host_t), TPTR(data)) sep \
+ ACTION(SIMCALL_HOST_GET_CURRENT_POWER_PEAK, host_get_current_power_peak, WITH_ANSWER, TDOUBLE(result), TSPEC(host, smx_host_t)) sep \
+ ACTION(SIMCALL_HOST_GET_POWER_PEAK_AT, host_get_power_peak_at, WITH_ANSWER, TDOUBLE(result), TSPEC(host, smx_host_t), TINT(pstate_index)) sep \
+ ACTION(SIMCALL_HOST_GET_NB_PSTATES, host_get_nb_pstates, WITH_ANSWER, TINT(result), TSPEC(host, smx_host_t)) sep \
+ ACTION(SIMCALL_HOST_SET_POWER_PEAK_AT, host_set_power_peak_at, WITH_ANSWER, TVOID(result), TSPEC(host, smx_host_t), TINT(pstate_index)) sep \
+ ACTION(SIMCALL_HOST_GET_CONSUMED_ENERGY, host_get_consumed_energy, WITH_ANSWER, TDOUBLE(result), TSPEC(host, smx_host_t)) sep \
  ACTION(SIMCALL_HOST_EXECUTE, host_execute, WITH_ANSWER, TSPEC(result, smx_action_t), TSTRING(name), TSPEC(host, smx_host_t), TDOUBLE(computation_amount), TDOUBLE(priority)) sep \
  ACTION(SIMCALL_HOST_PARALLEL_EXECUTE, host_parallel_execute, WITH_ANSWER, TSPEC(result, smx_action_t), TSTRING(name), TINT(host_nb), TSPEC(host_list, smx_host_t*), TSPEC(computation_amount, double*), TSPEC(communication_amount, double*), TDOUBLE(amount), TDOUBLE(rate)) sep \
  ACTION(SIMCALL_HOST_EXECUTION_DESTROY, host_execution_destroy, WITH_ANSWER, TVOID(result), TSPEC(execution, smx_action_t)) sep \
diff --combined src/simix/smx_user.c
@@@ -94,17 -94,6 +94,17 @@@ int simcall_host_get_core(smx_host_t ho
    return simcall_BODY_host_get_core(host);
  }
  
 +/**
 + * \ingroup simix_host_management
 + * \brief Returns the list of processes attached to the host.
 + *
 + * \param host A SIMIX host
 + * \return the swag of attached processes
 + */
 +xbt_swag_t simcall_host_get_process_list(smx_host_t host)
 +{
 +  return simcall_BODY_host_get_process_list(host);
 +}
  
  
  /**
@@@ -156,6 -145,69 +156,69 @@@ void simcall_host_set_data(smx_host_t h
    simcall_host_set_data(host, data);
  }
  
+ /**
+  * \ingroup simix_host_management
+  * \brief Returns the power peak of a host.
+  *
+  * \param host A SIMIX host
+  * \return the current power peak value (double)
+  */
+ double simcall_host_get_current_power_peak(smx_host_t host)
+ {
+   return simcall_BODY_host_get_current_power_peak(host);
+ }
+ /**
+  * \ingroup simix_host_management
+  * \brief Returns one power peak (in flops/s) of a host at a given pstate
+  *
+  * \param host A SIMIX host
+  * \param pstate_index pstate to test
+  * \return the current power peak value (double) for pstate_index
+  */
+ double simcall_host_get_power_peak_at(smx_host_t host, int pstate_index)
+ {
+   return simcall_BODY_host_get_power_peak_at(host, pstate_index);
+ }
+ /**
+  * \ingroup simix_host_management
+  * \brief Returns the number of power states for a host.
+  *
+  * \param host A SIMIX host
+  * \return the number of power states
+  */
+ int simcall_host_get_nb_pstates(smx_host_t host)
+ {
+   return simcall_BODY_host_get_nb_pstates(host);
+ }
+ /**
+  * \ingroup simix_host_management
+  * \brief Sets a new power peak for a host.
+  *
+  * \param host A SIMIX host
+  * \param pstate_index The pstate to which the CPU power will be set
+  * \return void
+  */
+ void simcall_host_set_power_peak_at(smx_host_t host, int pstate_index)
+ {
+       simcall_BODY_host_set_power_peak_at(host, pstate_index);
+ }
+ /**
+  * \ingroup simix_host_management
+  * \brief Returns the total energy consumed by the host (in Joules)
+  *
+  * \param host A SIMIX host
+  * \return the energy consumed by the host (double)
+  */
+ double simcall_host_get_consumed_energy(smx_host_t host)
+ {
+   return simcall_BODY_host_get_consumed_energy(host);
+ }
  /**
   * \ingroup simix_host_management
   * \brief Creates an action that executes some computation of an host.
   * \param priority computation priority
   * \return A new SIMIX execution action
   */
  smx_action_t simcall_host_execute(const char *name, smx_host_t host,
                                      double computation_amount,
                                      double priority)