1 /* Copyright (c) 2013-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/plugins/energy.h" // FIXME: this plugin should be separated from the core
9 #include "simgrid/simix.h"
10 #include "smpi/smpi.h"
11 #include "src/internal_config.h"
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_dvfs, smpi,
14 "Logging specific to SMPI (experimental DVFS support)");
17 * \brief Return the speed of the processor (in flop/s) at a given pstate
19 * \param pstate_index pstate to test
20 * \return Returns the processor speed associated with pstate_index
22 double smpi_get_host_power_peak_at(int pstate_index)
24 return simcall_host_get_power_peak_at(SIMIX_host_self(), pstate_index);
28 * \brief Return the current speed of the processor (in flop/s)
30 * \return Returns the current processor speed
32 double smpi_get_host_current_power_peak(void)
34 return simcall_host_get_current_power_peak(SIMIX_host_self());
38 * \brief Return the number of pstates defined for the current host
40 int smpi_get_host_nb_pstates(void)
42 return sg_host_get_nb_pstates(SIMIX_host_self());
46 * \brief Sets the pstate at which the processor should run
48 * \param pstate_index pstate to switch to
50 void smpi_set_host_pstate(int pstate_index)
52 sg_host_set_pstate(SIMIX_host_self(), pstate_index);
55 * \brief Gets the pstate at which the processor currently running
57 * \param pstate_index pstate to switch to
59 int smpi_get_host_pstate() {
60 return sg_host_get_pstate(SIMIX_host_self());
64 * \brief Return the total energy consumed by a host (in Joules)
66 * \return Returns the consumed energy
68 double smpi_get_host_consumed_energy(void) {
69 return sg_host_get_consumed_energy(SIMIX_host_self());
75 #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
77 typedef unsigned int uinteger;
79 typedef long int integer;
80 typedef unsigned long int uinteger;
82 typedef char *address;
83 typedef short int shortint;
85 typedef double doublereal;
86 typedef struct { real r, i; } complex;
87 typedef struct { doublereal r, i; } doublecomplex;
89 XBT_PUBLIC(doublereal) smpi_get_host_power_peak_at_(integer *pstate_index);
90 doublereal smpi_get_host_power_peak_at_(integer *pstate_index)
92 return (doublereal)smpi_get_host_power_peak_at((int)*pstate_index);
95 XBT_PUBLIC(doublereal) smpi_get_host_current_power_peak_(void);
96 doublereal smpi_get_host_current_power_peak_(void)
98 return smpi_get_host_current_power_peak();
101 XBT_PUBLIC(integer) smpi_get_host_nb_pstates_(void);
102 integer smpi_get_host_nb_pstates_(void)
104 return (integer)smpi_get_host_nb_pstates();
107 XBT_PUBLIC(void) smpi_set_host_pstate_(integer *pstate_index);
108 void smpi_set_host_pstate_(integer *pstate_index)
110 smpi_set_host_pstate((int)*pstate_index);
113 XBT_PUBLIC(doublereal) smpi_get_host_consumed_energy_(void);
114 doublereal smpi_get_host_consumed_energy_(void)
116 return (doublereal)smpi_get_host_consumed_energy();