Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[ENERGY] Introduce idle/1core/maxCore energy consumption
[simgrid.git] / src / surf / plugins / energy.hpp
index 8f8d5bd..26fa299 100644 (file)
@@ -1,35 +1,59 @@
-/* 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
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "../cpu_interface.hpp"
-#include <map>
+#include <xbt/base.h>
+
+#include <utility>
+
+#include "src/surf/HostImpl.hpp"
 
-#ifndef CALLBACK_HPP_
-#define CALLBACK_HPP_
+#ifndef ENERGY_CALLBACK_HPP_
+#define ENERGY_CALLBACK_HPP_
 
-class CpuEnergy;
+namespace simgrid {
+namespace energy {
 
-extern std::map<Cpu*, CpuEnergy*> *surf_energy;
+class XBT_PRIVATE HostEnergy;
 
-class CpuEnergy {
+class PowerRange {
+  public: 
+  double idle;
+  double min;
+  double max;
+
+  PowerRange(double idle, double min, double max) : idle(idle), min(min), max(max) {
+  }
+};
+
+class HostEnergy {
 public:
-  CpuEnergy(Cpu *ptr);
-  ~CpuEnergy();
+  static simgrid::xbt::Extension<simgrid::s4u::Host, HostEnergy> EXTENSION_ID;
+
+  explicit HostEnergy(simgrid::s4u::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*/
-  Cpu *cpu;
+private:
+  void initWattsRangeList();
+  simgrid::s4u::Host *host = nullptr;
+  std::vector<PowerRange> 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*/
 };
 
-#endif /* CALLBACK_HPP_ */
+}
+}
+
+#endif /* ENERGY_CALLBACK_HPP_ */