Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
unify the naming of that property
[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 <utility>
12
13 #include "src/surf/HostImpl.hpp"
14
15 #ifndef ENERGY_CALLBACK_HPP_
16 #define ENERGY_CALLBACK_HPP_
17
18 namespace simgrid {
19 namespace energy {
20
21 class XBT_PRIVATE HostEnergy;
22
23 class PowerRange {
24   public: 
25   double idle;
26   double min;
27   double max;
28
29   PowerRange(double idle, double min, double max) : idle(idle), min(min), max(max) {
30   }
31 };
32
33 class HostEnergy {
34 public:
35   static simgrid::xbt::Extension<simgrid::s4u::Host, HostEnergy> EXTENSION_ID;
36
37   explicit HostEnergy(simgrid::s4u::Host *ptr);
38   ~HostEnergy();
39
40   double getCurrentWattsValue(double cpu_load);
41   double getConsumedEnergy();
42   double getWattMinAt(int pstate);
43   double getWattMaxAt(int pstate);
44   void update();
45
46 private:
47   void initWattsRangeList();
48   simgrid::s4u::Host *host = nullptr;
49   std::vector<PowerRange> power_range_watts_list;   /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
50 public:
51   double watts_off = 0.0; /*< Consumption when the machine is turned off (shutdown) */
52   double total_energy = 0.0; /*< Total energy consumed by the host */
53   double last_updated;       /*< Timestamp of the last energy update event*/
54 };
55
56 }
57 }
58
59 #endif /* ENERGY_CALLBACK_HPP_ */