X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/13e0c316176dfe56c04b66d96b65a174e76d0549..02ea6400fac5265cad1af98d468964d444fc82cb:/src/surf/plugins/energy.hpp diff --git a/src/surf/plugins/energy.hpp b/src/surf/plugins/energy.hpp index decb552edc..26fa2999a3 100644 --- a/src/surf/plugins/energy.hpp +++ b/src/surf/plugins/energy.hpp @@ -1,33 +1,59 @@ -/* - * callback.hpp - * - * Created on: Jan 10, 2014 - * Author: bedaride - */ -#include "../cpu_interface.hpp" -#include +/* energy.hpp: internal interface to the energy plugin */ -#ifndef CALLBACK_HPP_ -#define CALLBACK_HPP_ +/* Copyright (c) 2014-2016. The SimGrid Team. + * All rights reserved. */ -class CpuEnergy; -typedef CpuEnergy *CpuEnergyPtr; +/* 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. */ -extern std::map *surf_energy; +#include -class CpuEnergy { +#include + +#include "src/surf/HostImpl.hpp" + +#ifndef ENERGY_CALLBACK_HPP_ +#define ENERGY_CALLBACK_HPP_ + +namespace simgrid { +namespace energy { + +class XBT_PRIVATE HostEnergy; + +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(CpuPtr ptr); - ~CpuEnergy(); + static simgrid::xbt::Extension EXTENSION_ID; + + explicit HostEnergy(simgrid::s4u::Host *ptr); + ~HostEnergy(); double getCurrentWattsValue(double cpu_load); double getConsumedEnergy(); - xbt_dynar_t getWattsRangeList(); + double getWattMinAt(int pstate); + double getWattMaxAt(int pstate); + void update(); - xbt_dynar_t power_range_watts_list; /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */ - double total_energy; /*< Total energy consumed by the host */ - double last_updated; /*< Timestamp of the last energy update event*/ - CpuPtr cpu; +private: + void initWattsRangeList(); + simgrid::s4u::Host *host = nullptr; + std::vector 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_ */