Logo AND Algorithmique Numérique Distribuée

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