X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/45c3f1cfee86fb48c96d53f8267f99b6db6e3d7a..34bbb917a7967e63d8eaa841cdb79f3c711f7ecc:/src/surf/plugins/energy.hpp diff --git a/src/surf/plugins/energy.hpp b/src/surf/plugins/energy.hpp index 5839da8b7c..04a413cb37 100644 --- a/src/surf/plugins/energy.hpp +++ b/src/surf/plugins/energy.hpp @@ -1,33 +1,54 @@ -/* Copyright (c) 2014. 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 + +#include "src/surf/host_interface.hpp" #include -#ifndef CALLBACK_HPP_ -#define CALLBACK_HPP_ +#ifndef ENERGY_CALLBACK_HPP_ +#define ENERGY_CALLBACK_HPP_ -class CpuEnergy; -typedef CpuEnergy *CpuEnergyPtr; +namespace simgrid { +namespace energy { -extern std::map *surf_energy; +class XBT_PRIVATE HostEnergy; -class CpuEnergy { +class HostEnergy { public: - CpuEnergy(CpuPtr ptr); - ~CpuEnergy(); + static simgrid::xbt::Extension EXTENSION_ID; + typedef std::pair power_range; + + HostEnergy(simgrid::Host *ptr); + ~HostEnergy(); double getCurrentWattsValue(double cpu_load); double getConsumedEnergy(); - xbt_dynar_t getWattsRangeList(); - - 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; + double getWattMinAt(int pstate); + double getWattMaxAt(int pstate); + void update(); + +private: + void initWattsRangeList(); + simgrid::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_ */ +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_ */