Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1ac1444f56905f5c2b279aa2ac9fd57e776fa454
[simgrid.git] / src / surf / plugins / energy.hpp
1 /* energy.hpp: internal interface to the energy plugin                      */
2
3 /* Copyright (c) 2014-2016. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #include <xbt/base.h>
10
11 #include "src/surf/host_interface.hpp"
12 #include <map>
13
14 #ifndef ENERGY_CALLBACK_HPP_
15 #define ENERGY_CALLBACK_HPP_
16
17 namespace simgrid {
18 namespace energy {
19
20 class XBT_PRIVATE HostEnergy;
21
22 class HostEnergy {
23 public:
24   static simgrid::xbt::Extension<simgrid::Host, HostEnergy> EXTENSION_ID;
25   typedef std::pair<double,double> power_range;
26
27   HostEnergy(simgrid::Host *ptr);
28   ~HostEnergy();
29
30   double getCurrentWattsValue(double cpu_load);
31   double getConsumedEnergy();
32   double getWattMinAt(int pstate);
33   double getWattMaxAt(int pstate);
34   void update();
35
36 private:
37   void initWattsRangeList();
38   simgrid::Host *host = nullptr;
39   std::vector<power_range> power_range_watts_list;   /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
40 public:
41   double watts_off = 0.0; /*< Consumption when the machine is turned off (shutdown) */
42   double total_energy = 0.0; /*< Total energy consumed by the host */
43   double last_updated;       /*< Timestamp of the last energy update event*/
44 };
45
46 }
47 }
48
49 #endif /* ENERGY_CALLBACK_HPP_ */