1 /* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
8 // FIXME: this plugin should be separated from the core
9 #include "simgrid/s4u/Host.hpp"
10 #include <simgrid/plugins/energy.h>
11 #include <simgrid/simix.h>
13 #include <smpi/smpi.h>
15 #include "src/internal_config.h"
17 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_dvfs, smpi, "Logging specific to SMPI (experimental DVFS support)");
20 * \brief Return the speed of the processor (in flop/s) at a given pstate
22 * \param pstate_index pstate to test
23 * \return Returns the processor speed associated with pstate_index
25 double smpi_get_host_power_peak_at(int pstate_index)
27 return sg_host_self()->getPstateSpeed(pstate_index);
31 * \brief Return the current speed of the processor (in flop/s)
33 * \return Returns the current processor speed
35 double smpi_get_host_current_power_peak()
37 return sg_host_self()->getSpeed();
41 * \brief Return the number of pstates defined for the current host
43 int smpi_get_host_nb_pstates()
45 return sg_host_get_nb_pstates(sg_host_self());
49 * \brief Sets the pstate at which the processor should run
51 * \param pstate_index pstate to switch to
53 void smpi_set_host_pstate(int pstate_index)
55 sg_host_set_pstate(sg_host_self(), pstate_index);
57 /** @brief Gets the pstate at which the processor currently running */
58 int smpi_get_host_pstate() {
59 return sg_host_get_pstate(sg_host_self());
63 * \brief Return the total energy consumed by a host (in Joules)
65 * \return Returns the consumed energy
67 double smpi_get_host_consumed_energy() {
68 return sg_host_get_consumed_energy(sg_host_self());
73 #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
76 typedef long int integer;
78 typedef char *address;
79 typedef short int shortint;
81 typedef double doublereal;
91 extern "C" XBT_PUBLIC(doublereal) smpi_get_host_power_peak_at_(integer *pstate_index);
92 doublereal smpi_get_host_power_peak_at_(integer *pstate_index)
94 return static_cast<doublereal>(smpi_get_host_power_peak_at((int)*pstate_index));
97 extern "C" XBT_PUBLIC(doublereal) smpi_get_host_current_power_peak_();
98 doublereal smpi_get_host_current_power_peak_()
100 return smpi_get_host_current_power_peak();
103 extern "C" XBT_PUBLIC(integer) smpi_get_host_nb_pstates_();
104 integer smpi_get_host_nb_pstates_()
106 return static_cast<integer>(smpi_get_host_nb_pstates());
109 extern "C" XBT_PUBLIC(void) smpi_set_host_pstate_(integer *pstate_index);
110 void smpi_set_host_pstate_(integer *pstate_index)
112 smpi_set_host_pstate(static_cast<int>(*pstate_index));
115 extern "C" XBT_PUBLIC(doublereal) smpi_get_host_consumed_energy_();
116 doublereal smpi_get_host_consumed_energy_()
118 return static_cast<doublereal>(smpi_get_host_consumed_energy());