Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[energy] C++-ification, remove nested xbt_dynar
[simgrid.git] / src / surf / plugins / energy.hpp
index de22070..076c16e 100644 (file)
@@ -1,4 +1,6 @@
-/* Copyright (c) 2014-2015. The SimGrid Team.
+/* energy.hpp: internal interface to the energy plugin                      */
+
+/* Copyright (c) 2014-2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -21,6 +23,8 @@ extern XBT_PRIVATE std::map<simgrid::surf::Host*, HostEnergy*> *surf_energy;
 
 class HostEnergy {
 public:
+  typedef std::pair<double,double> power_range;
+
   HostEnergy(simgrid::surf::Host *ptr);
   ~HostEnergy();
 
@@ -29,19 +33,26 @@ public:
   double getWattMinAt(int pstate);
   double getWattMaxAt(int pstate);
 
-  xbt_dynar_t getWattsRangeList();
-  xbt_dynar_t power_range_watts_list;   /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
-  double watts_off;                      /*< Consumption when the machine is turned off (shutdown) */
-  double total_energy;                                 /*< Total energy consumed by the host */
-  double last_updated;                                 /*< Timestamp of the last energy update event*/
-  simgrid::surf::Host *host;
-
   void unref() {if (--refcount == 0) delete this;}
   void ref() {refcount++;}
+
+private:
+  void initWattsRangeList();
   int refcount = 1;
+  simgrid::surf::Host *host;
+  std::vector<power_range> power_range_watts_list;   /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
+public:
+  double watts_off = 0.0; /*< Consumption when the machine is turned off (shutdown) */
+  double total_energy = 0.0; /*< Total energy consumed by the host */
+  double last_updated;       /*< Timestamp of the last energy update event*/
 };
 
+XBT_PUBLIC(double) surf_host_get_wattmin_at(sg_host_t resource, int pstate);
+XBT_PUBLIC(double) surf_host_get_wattmax_at(sg_host_t resource, int pstate);
+XBT_PUBLIC(double) surf_host_get_consumed_energy(sg_host_t host);
 }
 }
 
+
+
 #endif /* ENERGY_CALLBACK_HPP_ */