Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #65 from fabienchaix/master
[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 <map>
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 HostEnergy {
24 public:
25   static simgrid::xbt::Extension<simgrid::s4u::Host, HostEnergy> EXTENSION_ID;
26   typedef std::pair<double,double> power_range;
27
28   HostEnergy(simgrid::s4u::Host *ptr);
29   ~HostEnergy();
30
31   double getCurrentWattsValue(double cpu_load);
32   double getConsumedEnergy();
33   double getWattMinAt(int pstate);
34   double getWattMaxAt(int pstate);
35   void update();
36
37 private:
38   void initWattsRangeList();
39   simgrid::s4u::Host *host = nullptr;
40   std::vector<power_range> power_range_watts_list;   /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
41 public:
42   double watts_off = 0.0; /*< Consumption when the machine is turned off (shutdown) */
43   double total_energy = 0.0; /*< Total energy consumed by the host */
44   double last_updated;       /*< Timestamp of the last energy update event*/
45 };
46
47 }
48 }
49
50 #endif /* ENERGY_CALLBACK_HPP_ */