Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[energy] C++-ification, remove nested xbt_dynar
[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 extern XBT_PRIVATE std::map<simgrid::surf::Host*, HostEnergy*> *surf_energy;
23
24 class HostEnergy {
25 public:
26   typedef std::pair<double,double> power_range;
27
28   HostEnergy(simgrid::surf::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
36   void unref() {if (--refcount == 0) delete this;}
37   void ref() {refcount++;}
38
39 private:
40   void initWattsRangeList();
41   int refcount = 1;
42   simgrid::surf::Host *host;
43   std::vector<power_range> power_range_watts_list;   /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
44 public:
45   double watts_off = 0.0; /*< Consumption when the machine is turned off (shutdown) */
46   double total_energy = 0.0; /*< Total energy consumed by the host */
47   double last_updated;       /*< Timestamp of the last energy update event*/
48 };
49
50 XBT_PUBLIC(double) surf_host_get_wattmin_at(sg_host_t resource, int pstate);
51 XBT_PUBLIC(double) surf_host_get_wattmax_at(sg_host_t resource, int pstate);
52 XBT_PUBLIC(double) surf_host_get_consumed_energy(sg_host_t host);
53 }
54 }
55
56
57
58 #endif /* ENERGY_CALLBACK_HPP_ */