Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] Move some code in a simgrid::surf namespace
[simgrid.git] / src / surf / plugins / energy.hpp
index decb552..a1ee85c 100644 (file)
@@ -1,33 +1,47 @@
-/*
- * callback.hpp
- *
- *  Created on: Jan 10, 2014
- *      Author: bedaride
- */
-#include "../cpu_interface.hpp"
+/* Copyright (c) 2014-2015. 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 <xbt/base.h>
+
+#include "../host_interface.hpp"
 #include <map>
 
-#ifndef CALLBACK_HPP_
-#define CALLBACK_HPP_
+#ifndef ENERGY_CALLBACK_HPP_
+#define ENERGY_CALLBACK_HPP_
+
+namespace simgrid {
+namespace energy {
 
-class CpuEnergy;
-typedef CpuEnergy *CpuEnergyPtr;
+class XBT_PRIVATE HostEnergy;
 
-extern std::map<CpuPtr, CpuEnergyPtr> *surf_energy;
+extern XBT_PRIVATE std::map<simgrid::surf::Host*, HostEnergy*> *surf_energy;
 
-class CpuEnergy {
+class HostEnergy {
 public:
-  CpuEnergy(CpuPtr ptr);
-  ~CpuEnergy();
+  HostEnergy(simgrid::surf::Host *ptr);
+  ~HostEnergy();
 
   double getCurrentWattsValue(double cpu_load);
   double getConsumedEnergy();
-  xbt_dynar_t getWattsRangeList();
+  double getWattMinAt(int pstate);
+  double getWattMaxAt(int pstate);
 
-  xbt_dynar_t power_range_watts_list;          /*< List of (min_power,max_power) pairs corresponding to each cpu 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*/
-  CpuPtr cpu;
+  simgrid::surf::Host *host;
+
+  void unref() {if (--refcount == 0) delete this;}
+  void ref() {refcount++;}
+  int refcount = 1;
 };
 
-#endif /* CALLBACK_HPP_ */
+}
+}
+
+#endif /* ENERGY_CALLBACK_HPP_ */