X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f1d82814654e3d8602757919ab8070adf627d28b..02ea6400fac5265cad1af98d468964d444fc82cb:/src/surf/plugins/energy.hpp diff --git a/src/surf/plugins/energy.hpp b/src/surf/plugins/energy.hpp index 076c16ef6a..26fa2999a3 100644 --- a/src/surf/plugins/energy.hpp +++ b/src/surf/plugins/energy.hpp @@ -8,8 +8,9 @@ #include -#include "src/surf/host_interface.hpp" -#include +#include + +#include "src/surf/HostImpl.hpp" #ifndef ENERGY_CALLBACK_HPP_ #define ENERGY_CALLBACK_HPP_ @@ -19,40 +20,40 @@ namespace energy { class XBT_PRIVATE HostEnergy; -extern XBT_PRIVATE std::map *surf_energy; +class PowerRange { + public: + double idle; + double min; + double max; + + PowerRange(double idle, double min, double max) : idle(idle), min(min), max(max) { + } +}; class HostEnergy { public: - typedef std::pair power_range; + static simgrid::xbt::Extension EXTENSION_ID; - HostEnergy(simgrid::surf::Host *ptr); + explicit HostEnergy(simgrid::s4u::Host *ptr); ~HostEnergy(); double getCurrentWattsValue(double cpu_load); double getConsumedEnergy(); double getWattMinAt(int pstate); double getWattMaxAt(int pstate); - - void unref() {if (--refcount == 0) delete this;} - void ref() {refcount++;} + void update(); private: void initWattsRangeList(); - int refcount = 1; - simgrid::surf::Host *host; - std::vector power_range_watts_list; /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */ + simgrid::s4u::Host *host = nullptr; + std::vector power_range_watts_list; /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */ public: double watts_off = 0.0; /*< Consumption when the machine is turned off (shutdown) */ double total_energy = 0.0; /*< Total energy consumed by the host */ double last_updated; /*< Timestamp of the last energy update event*/ }; -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_ */