1 /* Copyright (c) 2013-2019. 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()->get_pstate_speed(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()->get_speed();
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;
80 typedef double doublereal;
85 struct doublecomplex {
90 extern "C" XBT_PUBLIC doublereal smpi_get_host_power_peak_at_(integer* pstate_index);
91 doublereal smpi_get_host_power_peak_at_(integer *pstate_index)
93 return static_cast<doublereal>(sg_host_self()->get_pstate_speed((int)*pstate_index));
96 extern "C" XBT_PUBLIC doublereal smpi_get_host_current_power_peak_();
97 doublereal smpi_get_host_current_power_peak_()
99 return sg_host_self()->get_speed();
102 extern "C" XBT_PUBLIC integer smpi_get_host_nb_pstates_();
103 integer smpi_get_host_nb_pstates_()
105 return static_cast<integer>(sg_host_self()->get_pstate_count());
108 extern "C" XBT_PUBLIC void smpi_set_host_pstate_(integer* pstate_index);
109 void smpi_set_host_pstate_(integer *pstate_index)
111 sg_host_set_pstate(sg_host_self(), (static_cast<int>(*pstate_index)));
114 extern "C" XBT_PUBLIC doublereal smpi_get_host_consumed_energy_();
115 doublereal smpi_get_host_consumed_energy_()
117 return static_cast<doublereal>(sg_host_get_consumed_energy(sg_host_self()));