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 076c16e..1ac1444 100644 (file)
@@ -19,27 +19,23 @@ namespace energy {
 
 class XBT_PRIVATE HostEnergy;
 
-extern XBT_PRIVATE std::map<simgrid::surf::Host*, HostEnergy*> *surf_energy;
-
 class HostEnergy {
 public:
+  static simgrid::xbt::Extension<simgrid::Host, HostEnergy> EXTENSION_ID;
   typedef std::pair<double,double> power_range;
 
-  HostEnergy(simgrid::surf::Host *ptr);
+  HostEnergy(simgrid::Host *ptr);
   ~HostEnergy();
 
   double getCurrentWattsValue(double cpu_load);
   double getConsumedEnergy();
   double getWattMinAt(int pstate);
   double getWattMaxAt(int pstate);
-
-  void unref() {if (--refcount == 0) delete this;}
-  void ref() {refcount++;}
+  void update();
 
 private:
   void initWattsRangeList();
-  int refcount = 1;
-  simgrid::surf::Host *host;
+  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) */
@@ -47,12 +43,7 @@ public:
   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_ */