Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove completely the energy concern from the core
[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   HostEnergy(simgrid::surf::Host *ptr);
27   ~HostEnergy();
28
29   double getCurrentWattsValue(double cpu_load);
30   double getConsumedEnergy();
31   double getWattMinAt(int pstate);
32   double getWattMaxAt(int pstate);
33
34   xbt_dynar_t getWattsRangeList();
35   xbt_dynar_t power_range_watts_list;   /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
36   double watts_off;                      /*< Consumption when the machine is turned off (shutdown) */
37   double total_energy;                                  /*< Total energy consumed by the host */
38   double last_updated;                                  /*< Timestamp of the last energy update event*/
39   simgrid::surf::Host *host;
40
41   void unref() {if (--refcount == 0) delete this;}
42   void ref() {refcount++;}
43   int refcount = 1;
44 };
45
46 XBT_PUBLIC(double) surf_host_get_wattmin_at(sg_host_t resource, int pstate);
47 XBT_PUBLIC(double) surf_host_get_wattmax_at(sg_host_t resource, int pstate);
48 XBT_PUBLIC(double) surf_host_get_consumed_energy(sg_host_t host);
49 }
50 }
51
52
53
54 #endif /* ENERGY_CALLBACK_HPP_ */