Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[energy] sanitize what's a simcall and what's not; inline some calls
[simgrid.git] / src / surf / plugins / energy.hpp
index a1ee85c..1ac1444 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
@@ -6,7 +8,7 @@
 
 #include <xbt/base.h>
 
-#include "../host_interface.hpp"
+#include "src/surf/host_interface.hpp"
 #include <map>
 
 #ifndef ENERGY_CALLBACK_HPP_
@@ -17,28 +19,28 @@ namespace energy {
 
 class XBT_PRIVATE HostEnergy;
 
-extern XBT_PRIVATE std::map<simgrid::surf::Host*, HostEnergy*> *surf_energy;
-
 class HostEnergy {
 public:
-  HostEnergy(simgrid::surf::Host *ptr);
+  static simgrid::xbt::Extension<simgrid::Host, HostEnergy> EXTENSION_ID;
+  typedef std::pair<double,double> power_range;
+
+  HostEnergy(simgrid::Host *ptr);
   ~HostEnergy();
 
   double getCurrentWattsValue(double cpu_load);
   double getConsumedEnergy();
   double getWattMinAt(int pstate);
   double getWattMaxAt(int pstate);
+  void update();
 
-  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++;}
-  int refcount = 1;
+private:
+  void initWattsRangeList();
+  simgrid::Host *host = nullptr;
+  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*/
 };
 
 }