Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove completely the energy concern from the core
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 11 Jan 2016 10:43:06 +0000 (11:43 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 11 Jan 2016 10:46:37 +0000 (11:46 +0100)
- It is moved to the plugin only.
- In particular, there is nothing in the core headers anymore
- SMPI still defines some energy methods
- the command-line config still needs to know the init method

Also, I'm sorry, but I renamed simgrid::Host->(p_cpu/p_netcard) to
pimpl_cpu/pimpl_netcard. I should have separated the rename, sorry.

31 files changed:
examples/msg/energy/consumption/energy_consumption.c
examples/msg/energy/onoff/onoff.c
examples/msg/energy/vm/energy_vm.c
include/simgrid/Host.hpp
include/simgrid/host.h
include/simgrid/msg.h
include/simgrid/plugins.h [deleted file]
include/simgrid/simix.h
src/include/surf/surf.h
src/instr/instr_paje_containers.cpp
src/msg/msg_host.cpp
src/simgrid/host.cpp
src/simix/libsmx.cpp
src/simix/smx_host.cpp
src/smpi/smpi_dvfs.c
src/surf/cpu_cas01.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_ti.cpp
src/surf/host_clm03.cpp
src/surf/host_ptask_L07.cpp
src/surf/plugins/energy.cpp
src/surf/plugins/energy.hpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.cpp
src/surf/surf_routing.cpp
src/surf/surf_routing_generic.cpp
src/surf/vm_hl13.cpp
teshsuite/simdag/platforms/flatifier.cpp
teshsuite/surf/surf_usage/surf_usage.cpp
teshsuite/surf/surf_usage/surf_usage2.cpp
tools/cmake/DefinePackages.cmake

index e058370..d523bbc 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "simgrid/msg.h"
 #include "xbt/sysdep.h"         /* calloc */
 
 #include "simgrid/msg.h"
 #include "xbt/sysdep.h"         /* calloc */
-#include "simgrid/plugins.h"
+#include "simgrid/plugins/energy.h"
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
@@ -30,14 +30,14 @@ int dvfs(int argc, char *argv[])
   XBT_INFO("Energetic profile: %s",
                  MSG_host_get_property_value(host,"watt_per_state"));
   XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
   XBT_INFO("Energetic profile: %s",
                  MSG_host_get_property_value(host,"watt_per_state"));
   XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
-                 MSG_host_get_current_power_peak(host), MSG_host_get_consumed_energy(host));
+                 MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
 
   double start = MSG_get_clock();
   XBT_INFO("Sleep for 10 seconds");
   MSG_process_sleep(10);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J",
                  MSG_get_clock()-start,
 
   double start = MSG_get_clock();
   XBT_INFO("Sleep for 10 seconds");
   MSG_process_sleep(10);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J",
                  MSG_get_clock()-start,
-                 MSG_host_get_current_power_peak(host), MSG_host_get_consumed_energy(host));
+                 MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
 
   // Run a task
   start = MSG_get_clock();
 
   // Run a task
   start = MSG_get_clock();
@@ -47,9 +47,9 @@ int dvfs(int argc, char *argv[])
   MSG_task_destroy(task1);
   XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW depending on load; Energy dissipated=%.0f J",
                  MSG_get_clock()-start,
   MSG_task_destroy(task1);
   XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW depending on load; Energy dissipated=%.0f J",
                  MSG_get_clock()-start,
-                 MSG_host_get_current_power_peak(host), MSG_host_get_wattmin_at(host,MSG_host_get_pstate(host)),
-                 MSG_host_get_wattmax_at(host,MSG_host_get_pstate(host)),
-                 MSG_host_get_consumed_energy(host));
+                 MSG_host_get_current_power_peak(host), sg_host_get_wattmin_at(host,MSG_host_get_pstate(host)),
+                 sg_host_get_wattmax_at(host,MSG_host_get_pstate(host)),
+                 sg_host_get_consumed_energy(host));
 
   // ========= Change power peak =========
   int pstate=2;
 
   // ========= Change power peak =========
   int pstate=2;
@@ -67,24 +67,24 @@ int dvfs(int argc, char *argv[])
   MSG_task_destroy(task1);
   XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
                  MSG_get_clock()-start,
   MSG_task_destroy(task1);
   XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
                  MSG_get_clock()-start,
-                 MSG_host_get_current_power_peak(host), MSG_host_get_consumed_energy(host));
+                 MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
 
   start = MSG_get_clock();
   XBT_INFO("Sleep for 4 seconds");
   MSG_process_sleep(4);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
                  MSG_get_clock()-start,
 
   start = MSG_get_clock();
   XBT_INFO("Sleep for 4 seconds");
   MSG_process_sleep(4);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
                  MSG_get_clock()-start,
-                 MSG_host_get_current_power_peak(host), MSG_host_get_consumed_energy(host));
+                 MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
 
   // =========== Turn the other host off ==========
   XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated %.0f J so far.",
 
   // =========== Turn the other host off ==========
   XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated %.0f J so far.",
-                 MSG_host_get_consumed_energy(MSG_host_by_name("MyHost2")) );
+                 sg_host_get_consumed_energy(MSG_host_by_name("MyHost2")) );
   MSG_host_off(MSG_host_by_name("MyHost2"));
   start = MSG_get_clock();
   MSG_process_sleep(10);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
                  MSG_get_clock()-start,
   MSG_host_off(MSG_host_by_name("MyHost2"));
   start = MSG_get_clock();
   MSG_process_sleep(10);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
                  MSG_get_clock()-start,
-                 MSG_host_get_current_power_peak(host), MSG_host_get_consumed_energy(host));
+                 MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
   return 0;
 }
 
   return 0;
 }
 
index 6287a86..56ce160 100644 (file)
@@ -4,11 +4,11 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include<stdio.h>
+#include <stdio.h>
 
 #include "simgrid/msg.h"
 #include "xbt/sysdep.h"         /* calloc */
 
 #include "simgrid/msg.h"
 #include "xbt/sysdep.h"         /* calloc */
-#include "simgrid/plugins.h"
+#include "simgrid/plugins/energy.h"
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
@@ -70,25 +70,25 @@ static int onoff(int argc, char *argv[]) {
        XBT_INFO("Energetic profile: %s",
                        MSG_host_get_property_value(host1,"watt_per_state"));
        XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
        XBT_INFO("Energetic profile: %s",
                        MSG_host_get_property_value(host1,"watt_per_state"));
        XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
-                       MSG_host_get_current_power_peak(host1), MSG_host_get_consumed_energy(host1));
+                       MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
 
        XBT_INFO("Sleep for 10 seconds");
        MSG_process_sleep(10);
        XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
 
        XBT_INFO("Sleep for 10 seconds");
        MSG_process_sleep(10);
        XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
-                       MSG_host_get_current_power_peak(host1), MSG_host_get_consumed_energy(host1));
+                       MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
 
        simulate_shutdown(host1);
        XBT_INFO("Host1 is now OFF. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
 
        simulate_shutdown(host1);
        XBT_INFO("Host1 is now OFF. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
-                       MSG_host_get_current_power_peak(host1), MSG_host_get_consumed_energy(host1));
+                       MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
 
        XBT_INFO("Sleep for 10 seconds");
        MSG_process_sleep(10);
        XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
 
        XBT_INFO("Sleep for 10 seconds");
        MSG_process_sleep(10);
        XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
-                       MSG_host_get_current_power_peak(host1), MSG_host_get_consumed_energy(host1));
+                       MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
 
        simulate_bootup(host1);
        XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
 
        simulate_bootup(host1);
        XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
-                       MSG_host_get_current_power_peak(host1), MSG_host_get_consumed_energy(host1));
+                       MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
 
 
        return 0;
 
 
        return 0;
index d05c3ff..ee2b7fe 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "simgrid/msg.h"
 #include "xbt/sysdep.h"         /* calloc */
 
 #include "simgrid/msg.h"
 #include "xbt/sysdep.h"         /* calloc */
-#include "simgrid/plugins.h"
+#include "simgrid/plugins/energy.h"
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
index 6e1f6c0..7d1a51b 100644 (file)
@@ -30,8 +30,8 @@ public:
        int getCoreAmount();
 
        /* FIXME: these should be protected, but it leads to many errors */
        int getCoreAmount();
 
        /* FIXME: these should be protected, but it leads to many errors */
-       surf::Cpu     *p_cpu = nullptr;
-       surf::NetCard *p_netcard = nullptr;
+       surf::Cpu     *pimpl_cpu = nullptr;
+       surf::NetCard *pimpl_netcard = nullptr;
 private:
   simgrid::xbt::string name_ = "noname";
 public:
 private:
   simgrid::xbt::string name_ = "noname";
 public:
@@ -48,8 +48,6 @@ public:
   double getPowerPeakAt(int pstate_index);
   void setPState(int pstate_index);
   int getPState();
   double getPowerPeakAt(int pstate_index);
   void setPState(int pstate_index);
   int getPState();
-  double getWattMinAt(int pstate);
-  double getWattMaxAt(int pstate);
   void getParams(vm_params_t params);
   void setParams(vm_params_t params);
   xbt_dict_t getMountedStorageList();
   void getParams(vm_params_t params);
   void setParams(vm_params_t params);
   xbt_dict_t getMountedStorageList();
index 2c3ab38..e66461d 100644 (file)
@@ -61,7 +61,6 @@ 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(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()
 
 
 SG_END_DECL()
 
index 11fa465..de9e014 100644 (file)
@@ -305,8 +305,6 @@ 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_on(msg_host_t h);
 XBT_PUBLIC(int) MSG_host_is_off(msg_host_t h);
 XBT_PUBLIC(xbt_swag_t) MSG_host_get_process_list(msg_host_t h);
 XBT_PUBLIC(int) MSG_host_is_on(msg_host_t h);
 XBT_PUBLIC(int) MSG_host_is_off(msg_host_t h);
-XBT_PUBLIC(double) MSG_host_get_wattmin_at(msg_host_t host, int pstate);
-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(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);
@@ -321,8 +319,6 @@ XBT_PUBLIC(xbt_dict_t) MSG_host_get_mounted_storage_list(msg_host_t host);
 XBT_PUBLIC(xbt_dynar_t) MSG_host_get_attached_storage_list(msg_host_t host);
 XBT_PUBLIC(xbt_dict_t) MSG_host_get_storage_content(msg_host_t host);
 
 XBT_PUBLIC(xbt_dynar_t) MSG_host_get_attached_storage_list(msg_host_t host);
 XBT_PUBLIC(xbt_dict_t) MSG_host_get_storage_content(msg_host_t host);
 
-XBT_PUBLIC(double) MSG_host_get_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,
 /*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 --git a/include/simgrid/plugins.h b/include/simgrid/plugins.h
deleted file mode 100644 (file)
index 0855430..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright (c) 2014. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef PLUGINS_H_
-#define PLUGINS_H_
-
-SG_BEGIN_DECL()
-
-/** \ingroup SURF_plugins
- *  \brief The cpu energy consumption plugin
- */
-XBT_PUBLIC(void) sg_energy_plugin_init(void);
-
-SG_END_DECL()
-
-#endif /* PLUGINS_H_ */
index 52f292a..8cfd2db 100644 (file)
@@ -258,8 +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(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(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);
 
 XBT_PUBLIC(smx_synchro_t) simcall_process_execute(const char *name,
                                                 double flops_amount,
 
 XBT_PUBLIC(smx_synchro_t) simcall_process_execute(const char *name,
                                                 double flops_amount,
index 04a4b1c..14af542 100644 (file)
@@ -20,7 +20,6 @@
 #include "surf/surf_routing.h"
 #include "simgrid/platf_interface.h"
 #include "simgrid/datatypes.h"
 #include "surf/surf_routing.h"
 #include "simgrid/platf_interface.h"
 #include "simgrid/datatypes.h"
-#include "simgrid/plugins.h"
 #include "simgrid/forward.h"
 
 SG_BEGIN_DECL()
 #include "simgrid/forward.h"
 
 SG_BEGIN_DECL()
@@ -447,17 +446,6 @@ XBT_PUBLIC(double) surf_host_get_current_power_peak(sg_host_t host);
  */
 XBT_PUBLIC(double) surf_host_get_power_peak_at(sg_host_t host, int pstate_index);
 
  */
 XBT_PUBLIC(double) surf_host_get_power_peak_at(sg_host_t host, int pstate_index);
 
-XBT_PUBLIC(double) surf_host_get_wattmin_at(sg_host_t resource, int pstate);
-XBT_PUBLIC(double) surf_host_get_wattmax_at(sg_host_t resource, int pstate);
-
-/**
- * @brief Get the consumed energy (in joules) of an host
- *
- * @param host The surf host
- * @return The consumed energy
- */
-XBT_PUBLIC(double) surf_host_get_consumed_energy(sg_host_t host);
-
 /**
  * @brief Get the list of storages mounted on an host
  *
 /**
  * @brief Get the list of storages mounted on an host
  *
index 3ce483c..f9606bd 100644 (file)
@@ -60,7 +60,7 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe
   //Search for network_element_t
   switch (kind){
     case INSTR_HOST:
   //Search for network_element_t
   switch (kind){
     case INSTR_HOST:
-      newContainer->net_elm = sg_host->p_netcard;
+      newContainer->net_elm = sg_host->pimpl_netcard;
       if(!newContainer->net_elm) xbt_die("Element '%s' not found",name);
       break;
     case INSTR_ROUTER:
       if(!newContainer->net_elm) xbt_die("Element '%s' not found",name);
       break;
     case INSTR_ROUTER:
index 31fd77f..8bf4125 100644 (file)
@@ -348,31 +348,6 @@ int MSG_host_get_nb_pstates(msg_host_t host) {
          return sg_host_get_nb_pstates(host);
 }
 
          return sg_host_get_nb_pstates(host);
 }
 
-/** \ingroup m_host_management
- * \brief Return the total energy consumed by a host (in Joules). See also @ref SURF_plugin_energy.
- *
- * \param  host host to test
- * \return Returns the consumed energy
- */
-double MSG_host_get_consumed_energy(msg_host_t host) {
-         xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
-         return sg_host_get_consumed_energy(host);
-}
-/** \ingroup m_host_management
- * \brief Returns the amount of watt dissipated at the given pstate when the host is idling
- *
- */
-double MSG_host_get_wattmin_at(msg_host_t host, int pstate){
-       return host->getWattMinAt(pstate);
-}
-/** \ingroup m_host_management
- * \brief Returns the amount of watt dissipated at the given pstate when the host burns CPU at 100%
- *
- */
-double MSG_host_get_wattmax_at(msg_host_t host, int pstate){
-       return host->getWattMaxAt(pstate);
-}
-
 /** \ingroup m_host_management
  * \brief Return the list of mount point names on an host.
  * \param host a host
 /** \ingroup m_host_management
  * \brief Return the list of mount point names on an host.
  * \param host a host
index 9d3255b..0f61893 100644 (file)
@@ -138,15 +138,7 @@ double sg_host_get_available_speed(sg_host_t host){
  *  @return 1 if the host is active or 0 if it has crashed.
  */
 int sg_host_is_on(sg_host_t host) {
  *  @return 1 if the host is active or 0 if it has crashed.
  */
 int sg_host_is_on(sg_host_t host) {
-       return host->p_cpu->isOn();
-}
-
-/** @brief Returns the total energy consumed by the host (in Joules).
- *
- *  See also @ref SURF_plugin_energy.
- */
-double sg_host_get_consumed_energy(sg_host_t host) {
-       return surf_host_get_consumed_energy(host);
+       return host->pimpl_cpu->isOn();
 }
 
 /** @brief Returns the number of power states for a host.
 }
 
 /** @brief Returns the number of power states for a host.
@@ -154,7 +146,7 @@ double sg_host_get_consumed_energy(sg_host_t host) {
  *  See also @ref SURF_plugin_energy.
  */
 int sg_host_get_nb_pstates(sg_host_t host) {
  *  See also @ref SURF_plugin_energy.
  */
 int sg_host_get_nb_pstates(sg_host_t host) {
-  return host->p_cpu->getNbPStates();
+  return host->pimpl_cpu->getNbPStates();
 }
 
 /** @brief Gets the pstate at which that host currently runs.
 }
 
 /** @brief Gets the pstate at which that host currently runs.
@@ -198,10 +190,10 @@ void Host::turnOff()
 }
 
 bool Host::isOn() {
 }
 
 bool Host::isOn() {
-  return p_cpu->isOn();
+  return pimpl_cpu->isOn();
 }
 bool Host::isOff() {
 }
 bool Host::isOff() {
-  return ! p_cpu->isOn();
+  return ! pimpl_cpu->isOn();
 }
 
 
 }
 
 
@@ -233,11 +225,11 @@ double Host::getPowerPeakAt(int pstate_index)
 
 /** @brief Get the speed of the cpu associated to a host */
 double Host::getSpeed() {
 
 /** @brief Get the speed of the cpu associated to a host */
 double Host::getSpeed() {
-       return p_cpu->getSpeed(1.0);
+       return pimpl_cpu->getSpeed(1.0);
 }
 /** @brief Returns the number of core of the processor. */
 int Host::getCoreAmount() {
 }
 /** @brief Returns the number of core of the processor. */
 int Host::getCoreAmount() {
-       return p_cpu->getCore();
+       return pimpl_cpu->getCore();
 }
 
 Host* Host::by_name_or_null(const char* name)
 }
 
 Host* Host::by_name_or_null(const char* name)
@@ -259,29 +251,13 @@ Host* Host::by_name_or_create(const char* name)
 void Host::setPState(int pstate_index)
 {
   simgrid::simix::kernel(std::bind(
 void Host::setPState(int pstate_index)
 {
   simgrid::simix::kernel(std::bind(
-      &simgrid::surf::Cpu::setPState, p_cpu, pstate_index
+      &simgrid::surf::Cpu::setPState, pimpl_cpu, pstate_index
   ));
 }
 /** @brief Retrieve the pstate at which the host is currently running */
 int Host::getPState()
 {
   ));
 }
 /** @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)
-{
-  return simgrid::simix::kernel(std::bind(
-      surf_host_get_wattmin_at, this, pstate
-  ));
-}
-
-/** Get the amount of watt dissipated at the given pstate when the host burns CPU at 100% */
-double Host::getWattMaxAt(int pstate)
-{
-  return simgrid::simix::kernel(std::bind(
-      surf_host_get_wattmax_at, this, pstate
-  ));
+  return pimpl_cpu->getPState();
 }
 
 void Host::getParams(vm_params_t params)
 }
 
 void Host::getParams(vm_params_t params)
index 4f1d8cd..7d8618a 100644 (file)
@@ -63,20 +63,6 @@ double simcall_host_get_power_peak_at(sg_host_t host, int pstate_index)
   return host->getPowerPeakAt(pstate_index);
 }
 
   return host->getPowerPeakAt(pstate_index);
 }
 
-/** \ingroup simix_host_management
- * \deprecated */
-double simcall_host_get_wattmin_at(msg_host_t host, int pstate)
-{
-  return host->getWattMinAt(pstate);
-}
-
-/** \ingroup simix_host_management
- *  \deprecated */
-double simcall_host_get_wattmax_at(msg_host_t host, int pstate)
-{
-  return host->getWattMaxAt(pstate);
-}
-
 /** \deprecated */
 void simcall_host_get_params(sg_host_t vm, vm_params_t params)
 {
 /** \deprecated */
 void simcall_host_get_params(sg_host_t vm, vm_params_t params)
 {
index 91b7ef9..92cf8ee 100644 (file)
@@ -313,7 +313,7 @@ smx_synchro_t SIMIX_process_execute(smx_process_t issuer, const char *name,
   /* set surf's action */
   if (!MC_is_active() && !MC_record_replay_is_active()) {
 
   /* set surf's action */
   if (!MC_is_active() && !MC_record_replay_is_active()) {
 
-    synchro->execution.surf_exec = issuer->host->p_cpu->execute(flops_amount);
+    synchro->execution.surf_exec = issuer->host->pimpl_cpu->execute(flops_amount);
     synchro->execution.surf_exec->setData(synchro);
     synchro->execution.surf_exec->setPriority(priority);
 
     synchro->execution.surf_exec->setData(synchro);
     synchro->execution.surf_exec->setPriority(priority);
 
@@ -325,7 +325,7 @@ smx_synchro_t SIMIX_process_execute(smx_process_t issuer, const char *name,
       /* just a double check to confirm that this host is the host where this task is running. */
       xbt_assert(synchro->execution.host == issuer->host);
       static_cast<simgrid::surf::CpuAction*>(synchro->execution.surf_exec)
       /* just a double check to confirm that this host is the host where this task is running. */
       xbt_assert(synchro->execution.host == issuer->host);
       static_cast<simgrid::surf::CpuAction*>(synchro->execution.surf_exec)
-        ->setAffinity(issuer->host->p_cpu, affinity_mask);
+        ->setAffinity(issuer->host->pimpl_cpu, affinity_mask);
     }
   }
 
     }
   }
 
@@ -432,7 +432,7 @@ void SIMIX_process_execution_set_affinity(smx_synchro_t synchro, sg_host_t host,
     /* just a double check to confirm that this host is the host where this task is running. */
     xbt_assert(synchro->execution.host == host);
     static_cast<simgrid::surf::CpuAction*>(synchro->execution.surf_exec)
     /* just a double check to confirm that this host is the host where this task is running. */
     xbt_assert(synchro->execution.host == host);
     static_cast<simgrid::surf::CpuAction*>(synchro->execution.surf_exec)
-      ->setAffinity(host->p_cpu, mask);
+      ->setAffinity(host->pimpl_cpu, mask);
   }
 }
 
   }
 }
 
index feb2051..6b8d99e 100644 (file)
@@ -4,6 +4,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "simgrid/plugins/energy.h" // FIXME: this plugin should be separated from the core
 #include "xbt/log.h"
 #include "simgrid/simix.h"
 #include "smpi/smpi.h"
 #include "xbt/log.h"
 #include "simgrid/simix.h"
 #include "smpi/smpi.h"
index ae4a965..9893b57 100644 (file)
@@ -115,7 +115,7 @@ void CpuCas01Model::addTraces()
   /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
   /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->p_cpu);
+    CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->pimpl_cpu);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -125,7 +125,7 @@ void CpuCas01Model::addTraces()
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->p_cpu);
+    CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->pimpl_cpu);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
index ab78cd7..e50e704 100644 (file)
@@ -149,7 +149,7 @@ Cpu::Cpu(Model *model, simgrid::Host *host, lmm_constraint_t constraint,
  , m_speedScale(speedScale)
  , m_host(host)
 {
  , m_speedScale(speedScale)
  , m_host(host)
 {
-  host->p_cpu = this;
+  host->pimpl_cpu = this;
   xbt_assert(m_speedScale > 0, "Available speed has to be >0");
 
   // Copy the power peak array:
   xbt_assert(m_speedScale > 0, "Available speed has to be >0");
 
   // Copy the power peak array:
index 8490a1e..f3feb36 100644 (file)
@@ -501,7 +501,7 @@ void CpuTiModel::addTraces()
 /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->p_cpu);
+    CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->pimpl_cpu);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -517,7 +517,7 @@ void CpuTiModel::addTraces()
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->p_cpu);
+    CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->pimpl_cpu);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
index 1df2fb2..2987833 100644 (file)
@@ -81,11 +81,11 @@ Action *HostCLM03Model::executeParallelTask(int host_nb,
   Action *action =NULL;
   if ((host_nb == 1)
       && (cost_or_zero(bytes_amount, 0) == 0.0)){
   Action *action =NULL;
   if ((host_nb == 1)
       && (cost_or_zero(bytes_amount, 0) == 0.0)){
-    action = host_list[0]->p_cpu->execute(flops_amount[0]);
+    action = host_list[0]->pimpl_cpu->execute(flops_amount[0]);
   } else if ((host_nb == 1)
            && (cost_or_zero(flops_amount, 0) == 0.0)) {
   } else if ((host_nb == 1)
            && (cost_or_zero(flops_amount, 0) == 0.0)) {
-    action = surf_network_model->communicate(host_list[0]->p_netcard,
-                                                host_list[0]->p_netcard,
+    action = surf_network_model->communicate(host_list[0]->pimpl_netcard,
+                                                host_list[0]->pimpl_netcard,
                                                                                         bytes_amount[0], rate);
   } else if ((host_nb == 2)
              && (cost_or_zero(flops_amount, 0) == 0.0)
                                                                                         bytes_amount[0], rate);
   } else if ((host_nb == 2)
              && (cost_or_zero(flops_amount, 0) == 0.0)
@@ -100,8 +100,8 @@ Action *HostCLM03Model::executeParallelTask(int host_nb,
       }
     }
     if (nb == 1){
       }
     }
     if (nb == 1){
-      action = surf_network_model->communicate(host_list[0]->p_netcard,
-                                                  host_list[1]->p_netcard,
+      action = surf_network_model->communicate(host_list[0]->pimpl_netcard,
+                                                  host_list[1]->pimpl_netcard,
                                                                                           value, rate);
     }
   } else
                                                                                           value, rate);
     }
   } else
index cd1c12a..72a1aef 100644 (file)
@@ -201,7 +201,7 @@ L07Action::L07Action(Model *model, int host_nb,
 
   this->p_netcardList->reserve(host_nb);
   for (int i = 0; i<host_nb; i++)
 
   this->p_netcardList->reserve(host_nb);
   for (int i = 0; i<host_nb; i++)
-         this->p_netcardList->push_back(host_list[i]->p_netcard);
+         this->p_netcardList->push_back(host_list[i]->pimpl_netcard);
 
   /* Compute the number of affected resources... */
   for (int i = 0; i < host_nb; i++) {
 
   /* Compute the number of affected resources... */
   for (int i = 0; i < host_nb; i++) {
@@ -249,7 +249,7 @@ L07Action::L07Action(Model *model, int host_nb,
 
   for (int i = 0; i < host_nb; i++)
     lmm_expand(model->getMaxminSystem(),
 
   for (int i = 0; i < host_nb; i++)
     lmm_expand(model->getMaxminSystem(),
-              host_list[i]->p_cpu->getConstraint(),
+              host_list[i]->pimpl_cpu->getConstraint(),
                this->getVariable(), flops_amount[i]);
 
   for (int i = 0; i < host_nb; i++) {
                this->getVariable(), flops_amount[i]);
 
   for (int i = 0; i < host_nb; i++) {
@@ -341,7 +341,7 @@ void HostL07Model::addTraces()
   /* Connect traces relative to cpu */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
   /* Connect traces relative to cpu */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->p_cpu);
+    CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->pimpl_cpu);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -351,7 +351,7 @@ void HostL07Model::addTraces()
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->p_cpu);
+    CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->pimpl_cpu);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
index feacbf1..8ebcc67 100644 (file)
@@ -4,6 +4,8 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include <simgrid/plugins/energy.h>
+#include <simgrid/simix.hpp>
 #include <src/surf/plugins/energy.hpp>
 #include <src/surf/cpu_interface.hpp>
 #include <src/surf/virtual_machine.hpp>
 #include <src/surf/plugins/energy.hpp>
 #include <src/surf/cpu_interface.hpp>
 #include <src/surf/virtual_machine.hpp>
@@ -86,72 +88,6 @@ static void update_consumption(simgrid::surf::Host *host, HostEnergy *host_energ
            host->getName(), start_time, finish_time, host->p_cpu->m_speedPeak, previous_energy, energy_this_step);
 }
 
            host->getName(), start_time, finish_time, host->p_cpu->m_speedPeak, previous_energy, energy_this_step);
 }
 
-/** \ingroup SURF_plugin_energy
- * \brief Enable energy plugin
- * \details Enable energy plugin to get joules consumption of each cpu. You should call this function before #MSG_init().
- */
-void sg_energy_plugin_init() {
-  if (simgrid::energy::surf_energy == NULL) {
-
-       simgrid::energy::surf_energy = new std::map<simgrid::surf::Host*, simgrid::energy::HostEnergy*>();
-
-       /* The following attaches an anonymous function to the Host::onCreation signal */
-       /* Search for "C++ lambda" for more information on the syntax used here */
-       simgrid::surf::Host::onCreation.connect([](simgrid::surf::Host *host) {
-         if (dynamic_cast<simgrid::surf::VirtualMachine*>(host)) // Ignore virtual machines
-           return;
-
-         (*simgrid::energy::surf_energy)[host] = new HostEnergy(host);
-       });
-
-       simgrid::surf::Host::onDestruction.connect([](simgrid::surf::Host *host) {
-         if (dynamic_cast<simgrid::surf::VirtualMachine*>(host)) // Ignore virtual machines
-           return;
-
-         std::map<simgrid::surf::Host*, HostEnergy*>::iterator host_energy_it = simgrid::energy::surf_energy->find(host);
-         xbt_assert(host_energy_it != simgrid::energy::surf_energy->end(), "The host is not in surf_energy.");
-
-         HostEnergy *host_energy = host_energy_it->second;
-         update_consumption(host, host_energy);
-
-         XBT_INFO("Total energy of host %s: %f Joules", host->getName(), host_energy->getConsumedEnergy());
-         host_energy_it->second->unref();
-         simgrid::energy::surf_energy->erase(host_energy_it);
-       });
-
-       simgrid::surf::CpuAction::onStateChange.connect([](simgrid::surf::CpuAction *action,
-           e_surf_action_state_t old,
-           e_surf_action_state_t cur) {
-         const char *name = getActionCpu(action)->getName();
-         simgrid::surf::Host *host = sg_host_by_name(name)->extension<simgrid::surf::Host>();
-         simgrid::surf::VirtualMachine *vm = dynamic_cast<simgrid::surf::VirtualMachine*>(host);
-         if (vm) // If it's a VM, take the corresponding PM
-             host = vm->getPm()->extension<simgrid::surf::Host>();
-
-         HostEnergy *host_energy = (*simgrid::energy::surf_energy)[host];
-
-         if(host_energy->last_updated < surf_get_clock())
-           update_consumption(host, host_energy);
-
-       });
-
-       simgrid::surf::Host::onStateChange.connect([] (simgrid::surf::Host *host) {
-         if (dynamic_cast<simgrid::surf::VirtualMachine*>(host)) // Ignore virtual machines
-           return;
-
-         HostEnergy *host_energy = (*simgrid::energy::surf_energy)[host];
-
-         if(host_energy->last_updated < surf_get_clock())
-           update_consumption(host, host_energy);
-       });
-
-       simgrid::surf::surfExitCallbacks.connect([]() {
-         delete simgrid::energy::surf_energy;
-         simgrid::energy::surf_energy = NULL;
-       });
-  }
-}
-
 namespace simgrid {
 namespace energy {
 
 namespace simgrid {
 namespace energy {
 
@@ -277,5 +213,112 @@ xbt_dynar_t HostEnergy::getWattsRangeList()
        return power_range_list;
 }
 
        return power_range_list;
 }
 
+
+double surf_host_get_wattmin_at(sg_host_t host, int pstate){
+  xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
+  std::map<simgrid::surf::Host*, HostEnergy*>::iterator hostIt = surf_energy->find(host->extension<simgrid::surf::Host>());
+  return hostIt->second->getWattMinAt(pstate);
+}
+double surf_host_get_wattmax_at(sg_host_t host, int pstate){
+  xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
+  std::map<simgrid::surf::Host*, HostEnergy*>::iterator hostIt = surf_energy->find(host->extension<simgrid::surf::Host>());
+  return hostIt->second->getWattMaxAt(pstate);
+}
+
+double surf_host_get_consumed_energy(sg_host_t host){
+  xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
+  std::map<simgrid::surf::Host*, HostEnergy*>::iterator hostIt = surf_energy->find(host->extension<simgrid::surf::Host>());
+  return hostIt->second->getConsumedEnergy();
+}
+
+}
+}
+
+/* **************************** Public interface *************************** */
+
+/** \ingroup SURF_plugin_energy
+ * \brief Enable energy plugin
+ * \details Enable energy plugin to get joules consumption of each cpu. You should call this function before #MSG_init().
+ */
+void sg_energy_plugin_init() {
+  if (simgrid::energy::surf_energy == NULL) {
+
+  simgrid::energy::surf_energy = new std::map<simgrid::surf::Host*, simgrid::energy::HostEnergy*>();
+
+  /* The following attaches an anonymous function to the Host::onCreation signal */
+  /* Search for "C++ lambda" for more information on the syntax used here */
+  simgrid::surf::Host::onCreation.connect([](simgrid::surf::Host *host) {
+    if (dynamic_cast<simgrid::surf::VirtualMachine*>(host)) // Ignore virtual machines
+      return;
+
+    (*simgrid::energy::surf_energy)[host] = new HostEnergy(host);
+  });
+
+  simgrid::surf::Host::onDestruction.connect([](simgrid::surf::Host *host) {
+    if (dynamic_cast<simgrid::surf::VirtualMachine*>(host)) // Ignore virtual machines
+      return;
+
+    std::map<simgrid::surf::Host*, HostEnergy*>::iterator host_energy_it = simgrid::energy::surf_energy->find(host);
+    xbt_assert(host_energy_it != simgrid::energy::surf_energy->end(), "The host is not in surf_energy.");
+
+    HostEnergy *host_energy = host_energy_it->second;
+    update_consumption(host, host_energy);
+
+    XBT_INFO("Total energy of host %s: %f Joules", host->getName(), host_energy->getConsumedEnergy());
+    host_energy_it->second->unref();
+    simgrid::energy::surf_energy->erase(host_energy_it);
+  });
+
+  simgrid::surf::CpuAction::onStateChange.connect([](simgrid::surf::CpuAction *action,
+      e_surf_action_state_t old,
+      e_surf_action_state_t cur) {
+    const char *name = getActionCpu(action)->getName();
+    simgrid::surf::Host *host = sg_host_by_name(name)->extension<simgrid::surf::Host>();
+    simgrid::surf::VirtualMachine *vm = dynamic_cast<simgrid::surf::VirtualMachine*>(host);
+    if (vm) // If it's a VM, take the corresponding PM
+        host = vm->getPm()->extension<simgrid::surf::Host>();
+
+    HostEnergy *host_energy = (*simgrid::energy::surf_energy)[host];
+
+    if(host_energy->last_updated < surf_get_clock())
+      update_consumption(host, host_energy);
+
+  });
+
+  simgrid::surf::Host::onStateChange.connect([] (simgrid::surf::Host *host) {
+    if (dynamic_cast<simgrid::surf::VirtualMachine*>(host)) // Ignore virtual machines
+      return;
+
+    HostEnergy *host_energy = (*simgrid::energy::surf_energy)[host];
+
+    if(host_energy->last_updated < surf_get_clock())
+      update_consumption(host, host_energy);
+  });
+
+  simgrid::surf::surfExitCallbacks.connect([]() {
+    delete simgrid::energy::surf_energy;
+    simgrid::energy::surf_energy = NULL;
+  });
+  }
+}
+
+/** @brief Returns the total energy consumed by the host so far (in Joules)
+ *
+ *  See also @ref SURF_plugin_energy.
+ */
+double sg_host_get_consumed_energy(sg_host_t host) {
+  return simgrid::energy::surf_host_get_consumed_energy(host);
+}
+
+/** @brief Get the amount of watt dissipated at the given pstate when the host is idling */
+double sg_host_get_wattmin_at(sg_host_t host, int pstate) {
+  return simgrid::simix::kernel(std::bind(
+      simgrid::energy::surf_host_get_wattmin_at, host, pstate
+  ));
 }
 }
+/** @brief  Returns the amount of watt dissipated at the given pstate when the host burns CPU at 100% */
+double sg_host_get_wattmax_at(sg_host_t host, int pstate) {
+  return simgrid::simix::kernel(std::bind(
+      simgrid::energy::surf_host_get_wattmax_at, host, pstate
+  ));
 }
 }
index de22070..389abd9 100644 (file)
@@ -1,4 +1,6 @@
-/* Copyright (c) 2014-2015. The SimGrid Team.
+/* energy.hpp: internal interface to the energy plugin                      */
+
+/* Copyright (c) 2014-2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -41,7 +43,12 @@ public:
   int refcount = 1;
 };
 
   int refcount = 1;
 };
 
+XBT_PUBLIC(double) surf_host_get_wattmin_at(sg_host_t resource, int pstate);
+XBT_PUBLIC(double) surf_host_get_wattmax_at(sg_host_t resource, int pstate);
+XBT_PUBLIC(double) surf_host_get_consumed_energy(sg_host_t host);
 }
 }
 
 }
 }
 
+
+
 #endif /* ENERGY_CALLBACK_HPP_ */
 #endif /* ENERGY_CALLBACK_HPP_ */
index 20b8c08..82cd73b 100644 (file)
@@ -18,7 +18,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
  * TOOLS *
  *********/
 
  * TOOLS *
  *********/
 
-static simgrid::surf::Host *get_casted_host(sg_host_t host){
+static simgrid::surf::Host *get_casted_host(sg_host_t host){ //FIXME: killme
   return host->extension<simgrid::surf::Host>();
 }
 
   return host->extension<simgrid::surf::Host>();
 }
 
@@ -236,7 +236,7 @@ void surf_vm_model_create(const char *name, sg_host_t ind_phys_host){
 }
 
 surf_action_t surf_network_model_communicate(surf_network_model_t model, sg_host_t src, sg_host_t dst, double size, double rate){
 }
 
 surf_action_t surf_network_model_communicate(surf_network_model_t model, sg_host_t src, sg_host_t dst, double size, double rate){
-  return model->communicate(src->p_netcard, dst->p_netcard, size, rate);
+  return model->communicate(src->pimpl_netcard, dst->pimpl_netcard, size, rate);
 }
 
 const char *surf_resource_name(surf_cpp_resource_t resource){
 }
 
 const char *surf_resource_name(surf_cpp_resource_t resource){
@@ -244,7 +244,7 @@ const char *surf_resource_name(surf_cpp_resource_t resource){
 }
 
 surf_action_t surf_host_sleep(sg_host_t host, double duration){
 }
 
 surf_action_t surf_host_sleep(sg_host_t host, double duration){
-       return host->p_cpu->sleep(duration);
+       return host->pimpl_cpu->sleep(duration);
 }
 
 xbt_dict_t sg_host_get_properties(sg_host_t host) {
 }
 
 xbt_dict_t sg_host_get_properties(sg_host_t host) {
@@ -252,36 +252,17 @@ xbt_dict_t sg_host_get_properties(sg_host_t host) {
 }
 
 double surf_host_get_available_speed(sg_host_t host){
 }
 
 double surf_host_get_available_speed(sg_host_t host){
-  return host->p_cpu->getAvailableSpeed();
+  return host->pimpl_cpu->getAvailableSpeed();
 }
 
 double surf_host_get_current_power_peak(sg_host_t host){
 }
 
 double surf_host_get_current_power_peak(sg_host_t host){
-  return host->p_cpu->getCurrentPowerPeak();
+  return host->pimpl_cpu->getCurrentPowerPeak();
 }
 
 double surf_host_get_power_peak_at(sg_host_t host, int pstate_index){
 }
 
 double surf_host_get_power_peak_at(sg_host_t host, int pstate_index){
-  return host->p_cpu->getPowerPeakAt(pstate_index);
+  return host->pimpl_cpu->getPowerPeakAt(pstate_index);
 }
 
 }
 
-using simgrid::energy::HostEnergy;
-using simgrid::energy::surf_energy;
-
-double surf_host_get_wattmin_at(sg_host_t resource, int pstate){
-  xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
-  std::map<simgrid::surf::Host*, HostEnergy*>::iterator hostIt = surf_energy->find(get_casted_host(resource));
-  return hostIt->second->getWattMinAt(pstate);
-}
-double surf_host_get_wattmax_at(sg_host_t resource, int pstate){
-  xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
-  std::map<simgrid::surf::Host*, HostEnergy*>::iterator hostIt = surf_energy->find(get_casted_host(resource));
-  return hostIt->second->getWattMaxAt(pstate);
-}
-
-double surf_host_get_consumed_energy(sg_host_t resource){
-  xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
-  std::map<simgrid::surf::Host*, HostEnergy*>::iterator hostIt = surf_energy->find(get_casted_host(resource));
-  return hostIt->second->getConsumedEnergy();
-}
 
 xbt_dict_t surf_host_get_mounted_storage_list(sg_host_t host){
   return get_casted_host(host)->getMountedStorageList();
 
 xbt_dict_t surf_host_get_mounted_storage_list(sg_host_t host){
   return get_casted_host(host)->getMountedStorageList();
@@ -355,8 +336,8 @@ void surf_host_set_params(sg_host_t host, vm_params_t params){
 }
 
 void surf_vm_destroy(sg_host_t vm){ // FIXME:DEADCODE
 }
 
 void surf_vm_destroy(sg_host_t vm){ // FIXME:DEADCODE
-  vm->p_cpu = nullptr;
-  vm->p_netcard = nullptr;
+  vm->pimpl_cpu = nullptr;
+  vm->pimpl_netcard = nullptr;
 }
 
 void surf_vm_suspend(sg_host_t vm){
 }
 
 void surf_vm_suspend(sg_host_t vm){
@@ -388,7 +369,7 @@ void surf_vm_set_bound(sg_host_t vm, double bound){
 }
 
 void surf_vm_set_affinity(sg_host_t vm, sg_host_t host, unsigned long mask){
 }
 
 void surf_vm_set_affinity(sg_host_t vm, sg_host_t host, unsigned long mask){
-  return get_casted_vm(vm)->setAffinity(host->p_cpu, mask);
+  return get_casted_vm(vm)->setAffinity(host->pimpl_cpu, mask);
 }
 
 xbt_dict_t surf_storage_get_content(surf_resource_t resource){
 }
 
 xbt_dict_t surf_storage_get_content(surf_resource_t resource){
@@ -464,7 +445,7 @@ double surf_action_get_cost(surf_action_t action){
 }
 
 void surf_cpu_action_set_affinity(surf_action_t action, sg_host_t host, unsigned long mask) {
 }
 
 void surf_cpu_action_set_affinity(surf_action_t action, sg_host_t host, unsigned long mask) {
-  static_cast<simgrid::surf::CpuAction*>(action)->setAffinity(host->p_cpu, mask);
+  static_cast<simgrid::surf::CpuAction*>(action)->setAffinity(host->pimpl_cpu, mask);
 }
 
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
 }
 
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
index 39ca1f4..a69aac5 100644 (file)
@@ -43,6 +43,8 @@ simgrid::surf::signal<void(void)> surfExitCallbacks;
 }
 }
 
 }
 }
 
+#include <simgrid/plugins/energy.h> // FIXME: this plugin should not be linked to the core
+
 s_surf_model_description_t surf_plugin_description[] = {
     {"Energy", "Cpu energy consumption.", sg_energy_plugin_init},
      {NULL, NULL,  NULL}      /* this array must be NULL terminated */
 s_surf_model_description_t surf_plugin_description[] = {
     {"Energy", "Cpu energy consumption.", sg_energy_plugin_init},
      {NULL, NULL,  NULL}      /* this array must be NULL terminated */
index 857f147..6e3d4f8 100644 (file)
@@ -59,7 +59,7 @@ static xbt_dict_t random_value = NULL;
 simgrid::surf::NetCard *sg_netcard_by_name_or_null(const char *name)
 {
   sg_host_t h = sg_host_by_name(name);
 simgrid::surf::NetCard *sg_netcard_by_name_or_null(const char *name)
 {
   sg_host_t h = sg_host_by_name(name);
-  simgrid::surf::NetCard *net_elm = h==NULL?NULL: h->p_netcard;
+  simgrid::surf::NetCard *net_elm = h==NULL?NULL: h->pimpl_netcard;
   if (!net_elm)
        net_elm = (simgrid::surf::NetCard*) xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL);
   return net_elm;
   if (!net_elm)
        net_elm = (simgrid::surf::NetCard*) xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL);
   return net_elm;
@@ -127,7 +127,7 @@ struct s_model_type routing_models[] = {
  */
 void sg_platf_new_netcard(sg_platf_host_link_cbarg_t netcard)
 {
  */
 void sg_platf_new_netcard(sg_platf_host_link_cbarg_t netcard)
 {
-  simgrid::surf::NetCard *info = sg_host_by_name(netcard->id)->p_netcard;
+  simgrid::surf::NetCard *info = sg_host_by_name(netcard->id)->pimpl_netcard;
   xbt_assert(info, "Host '%s' not found!", netcard->id);
   xbt_assert(current_routing->p_modelDesc == &routing_models[SURF_MODEL_CLUSTER] ||
       current_routing->p_modelDesc == &routing_models[SURF_MODEL_VIVALDI],
   xbt_assert(info, "Host '%s' not found!", netcard->id);
   xbt_assert(current_routing->p_modelDesc == &routing_models[SURF_MODEL_CLUSTER] ||
       current_routing->p_modelDesc == &routing_models[SURF_MODEL_VIVALDI],
@@ -170,7 +170,7 @@ simgrid::surf::NetCard *routing_add_host(
                                                    current_routing);
   netcard->setId(current_routing->parsePU(netcard));
   sg_host_t h = sg_host_by_name_or_create(host->id);
                                                    current_routing);
   netcard->setId(current_routing->parsePU(netcard));
   sg_host_t h = sg_host_by_name_or_create(host->id);
-  h->p_netcard = netcard;
+  h->pimpl_netcard = netcard;
   XBT_DEBUG("Having set name '%s' id '%d'", host->id, netcard->getId());
   simgrid::surf::routingEdgeCreatedCallbacks(netcard);
 
   XBT_DEBUG("Having set name '%s' id '%d'", host->id, netcard->getId());
   simgrid::surf::routingEdgeCreatedCallbacks(netcard);
 
index 1dc0d18..3173d9c 100644 (file)
@@ -449,7 +449,7 @@ As *AsGeneric::autonomousSystemExist(char *element)
 
 As *AsGeneric::processingUnitsExist(char *element)
 {
 
 As *AsGeneric::processingUnitsExist(char *element)
 {
-  As *element_as = sg_host_by_name(element)->p_netcard ->getRcComponent();
+  As *element_as = sg_host_by_name(element)->pimpl_netcard ->getRcComponent();
   if (element_as == this)
     return element_as;
   return asExist(element_as);
   if (element_as == this)
     return element_as;
   return asExist(element_as);
index 3109c8e..95bc2db 100644 (file)
@@ -135,7 +135,7 @@ Action *VMHL13Model::executeParallelTask(int host_nb,
 #define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
   if ((host_nb == 1)
       && (cost_or_zero(bytes_amount, 0) == 0.0))
 #define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
   if ((host_nb == 1)
       && (cost_or_zero(bytes_amount, 0) == 0.0))
-    return host_list[0]->p_cpu->execute(flops_amount[0]);
+    return host_list[0]->pimpl_cpu->execute(flops_amount[0]);
   else if ((host_nb == 1)
            && (cost_or_zero(flops_amount, 0) == 0.0))
     return surf_network_model_communicate(surf_network_model, host_list[0], host_list[0],bytes_amount[0], rate);
   else if ((host_nb == 1)
            && (cost_or_zero(flops_amount, 0) == 0.0))
     return surf_network_model_communicate(surf_network_model, host_list[0], host_list[0],bytes_amount[0], rate);
@@ -176,15 +176,15 @@ VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t hos
    * from the VM name, we have to make sure that the system does not call the
    * free callback for the network resource object. The network resource object
    * is still used by the physical machine. */
    * from the VM name, we have to make sure that the system does not call the
    * free callback for the network resource object. The network resource object
    * is still used by the physical machine. */
-  p_netElm = host_PM->p_netcard;
+  p_netElm = host_PM->pimpl_netcard;
   sg_host_t host_VM = sg_host_by_name_or_create(name);
   sg_host_t host_VM = sg_host_by_name_or_create(name);
-  host_VM->p_netcard = p_netElm;
+  host_VM->pimpl_netcard = p_netElm;
 
   p_vm_state = SURF_VM_STATE_CREATED;
 
   // //// CPU  RELATED STUFF ////
   // Roughly, create a vcpu resource by using the values of the sub_cpu one.
 
   p_vm_state = SURF_VM_STATE_CREATED;
 
   // //// CPU  RELATED STUFF ////
   // Roughly, create a vcpu resource by using the values of the sub_cpu one.
-  CpuCas01 *sub_cpu = static_cast<CpuCas01*>(host_PM->p_cpu);
+  CpuCas01 *sub_cpu = static_cast<CpuCas01*>(host_PM->pimpl_cpu);
 
   p_cpu = surf_cpu_model_vm->createCpu(host_VM, // the machine hosting the VM
       sub_cpu->getSpeedPeakList(),        // host->power_peak,
 
   p_cpu = surf_cpu_model_vm->createCpu(host_VM, // the machine hosting the VM
       sub_cpu->getSpeedPeakList(),        // host->power_peak,
@@ -244,14 +244,14 @@ void VMHL13::migrate(sg_host_t host_dest)
    const char *pm_name_dst = surfHost_dst->getName();
 
    /* update net_elm with that of the destination physical host */
    const char *pm_name_dst = surfHost_dst->getName();
 
    /* update net_elm with that of the destination physical host */
-   sg_host_by_name(vm_name)->p_netcard = p_netElm = sg_host_by_name(pm_name_dst)->p_netcard;
+   sg_host_by_name(vm_name)->pimpl_netcard = p_netElm = sg_host_by_name(pm_name_dst)->pimpl_netcard;
 
    p_hostPM = host_dest;
 
    /* Update vcpu's action for the new pm */
    {
      /* create a cpu action bound to the pm model at the destination. */
 
    p_hostPM = host_dest;
 
    /* Update vcpu's action for the new pm */
    {
      /* create a cpu action bound to the pm model at the destination. */
-     CpuAction *new_cpu_action = static_cast<CpuAction*>(host_dest->p_cpu->execute(0));
+     CpuAction *new_cpu_action = static_cast<CpuAction*>(host_dest->pimpl_cpu->execute(0));
 
      e_surf_action_state_t state = p_action->getState();
      if (state != SURF_ACTION_DONE)
 
      e_surf_action_state_t state = p_action->getState();
      if (state != SURF_ACTION_DONE)
index 4a2fd86..1adbc2c 100644 (file)
@@ -193,14 +193,14 @@ int main(int argc, char **argv)
     sg_host_t host1, host2;
     xbt_dict_foreach(host_list, cursor_src, src, host1) // Routes from host
     {
     sg_host_t host1, host2;
     xbt_dict_foreach(host_list, cursor_src, src, host1) // Routes from host
     {
-      value1 = sg_host_by_name(src)->p_netcard;
+      value1 = sg_host_by_name(src)->pimpl_netcard;
       xbt_dict_foreach(host_list, cursor_dst, dst, host2) //to host
       {
         printf("  <route src=\"%s\" dst=\"%s\">\n  "
             ,src
             ,dst);
         xbt_dynar_t route=NULL;
       xbt_dict_foreach(host_list, cursor_dst, dst, host2) //to host
       {
         printf("  <route src=\"%s\" dst=\"%s\">\n  "
             ,src
             ,dst);
         xbt_dynar_t route=NULL;
-        value2 = sg_host_by_name(dst)->p_netcard;
+        value2 = sg_host_by_name(dst)->pimpl_netcard;
         routing_get_route_and_latency(value1, value2, &route,NULL);
         for(i=0;i<xbt_dynar_length(route) ;i++)
         {
         routing_get_route_and_latency(value1, value2, &route,NULL);
         for(i=0;i<xbt_dynar_length(route) ;i++)
         {
@@ -263,7 +263,7 @@ int main(int argc, char **argv)
           printf("  <route src=\"%s\" dst=\"%s\">\n  "
               ,src, dst);
           xbt_dynar_t route=NULL;
           printf("  <route src=\"%s\" dst=\"%s\">\n  "
               ,src, dst);
           xbt_dynar_t route=NULL;
-          value2 = sg_host_by_name(dst)->p_netcard;
+          value2 = sg_host_by_name(dst)->pimpl_netcard;
           routing_get_route_and_latency((sg_netcard_t)value1,(sg_netcard_t)value2,&route, NULL);
           for(i=0;i<xbt_dynar_length(route) ;i++)
           {
           routing_get_route_and_latency((sg_netcard_t)value1,(sg_netcard_t)value2,&route, NULL);
           for(i=0;i<xbt_dynar_length(route) ;i++)
           {
index 5713c53..fa8a962 100644 (file)
@@ -58,12 +58,12 @@ void test(char *platform)
   hostB = sg_host_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
   hostB = sg_host_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
-  XBT_DEBUG("%s : %p", surf_cpu_name(hostA->p_cpu), hostA);
-  XBT_DEBUG("%s : %p", surf_cpu_name(hostB->p_cpu), hostB);
+  XBT_DEBUG("%s : %p", surf_cpu_name(hostA->pimpl_cpu), hostA);
+  XBT_DEBUG("%s : %p", surf_cpu_name(hostB->pimpl_cpu), hostB);
 
   /* Let's do something on it */
 
   /* Let's do something on it */
-  actionA = hostA->p_cpu->execute(1000.0);
-  actionB = hostB->p_cpu->execute(1000.0);
+  actionA = hostA->pimpl_cpu->execute(1000.0);
+  actionB = hostB->pimpl_cpu->execute(1000.0);
   actionC = surf_host_sleep(hostB, 7.32);
 
   /* Use whatever calling style you want... */
   actionC = surf_host_sleep(hostB, 7.32);
 
   /* Use whatever calling style you want... */
index ed16cdb..8a2b672 100644 (file)
@@ -58,8 +58,8 @@ void test(char *platform)
   XBT_DEBUG("%s : %p", sg_host_get_name(hostB), hostB);
 
   /* Let's do something on it */
   XBT_DEBUG("%s : %p", sg_host_get_name(hostB), hostB);
 
   /* Let's do something on it */
-  hostA->p_cpu->execute(1000.0);
-  hostB->p_cpu->execute(1000.0);
+  hostA->pimpl_cpu->execute(1000.0);
+  hostB->pimpl_cpu->execute(1000.0);
   surf_host_sleep(hostB, 7.32);
 
   surf_network_model_communicate(surf_network_model, hostA, hostB, 150.0, -1.0);
   surf_host_sleep(hostB, 7.32);
 
   surf_network_model_communicate(surf_network_model, hostA, hostB, 150.0, -1.0);
index f2bc31f..53f54d0 100644 (file)
@@ -660,6 +660,7 @@ set(headers_to_install
   include/simdag/simdag.h
   include/simdag/datatypes.h
   
   include/simdag/simdag.h
   include/simdag/datatypes.h
   
+  include/simgrid/plugins/energy.h
   include/simgrid/instr.h
   include/simgrid/msg.h
   include/simgrid/simdag.h
   include/simgrid/instr.h
   include/simgrid/msg.h
   include/simgrid/simdag.h
@@ -669,7 +670,6 @@ set(headers_to_install
   include/simgrid/forward.h
   include/simgrid/platf.h
   include/simgrid/platf_generator.h
   include/simgrid/forward.h
   include/simgrid/platf.h
   include/simgrid/platf_generator.h
-  include/simgrid/plugins.h
   include/simgrid/simix.h
   include/simgrid/simix.hpp
   include/simgrid/host.h
   include/simgrid/simix.h
   include/simgrid/simix.hpp
   include/simgrid/host.h