Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / smpi / smpi_dvfs.c
1 /* Copyright (c) 2013. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "xbt/log.h"
8 #include "simgrid/simix.h"
9 #include "smpi/smpi.h"
10
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_dvfs, smpi,
12                                 "Logging specific to SMPI (experimental DVFS support)");
13
14 /**
15  * \brief Return the speed of the processor (in flop/s) at a given pstate
16  *
17  * \param pstate_index pstate to test
18  * \return Returns the processor speed associated with pstate_index
19  */
20 double smpi_get_host_power_peak_at(int pstate_index)
21 {
22   return simcall_host_get_power_peak_at(SIMIX_host_self(), pstate_index);
23 }
24
25 /**
26  * \brief Return the current speed of the processor (in flop/s)
27  *
28  * \return Returns the current processor speed
29  */
30 double smpi_get_host_current_power_peak(void)
31 {
32   return simcall_host_get_current_power_peak(SIMIX_host_self());
33 }
34
35 /**
36  * \brief Return the number of pstates defined for host
37  */
38 int smpi_get_host_nb_pstates(void)
39 {
40   return simcall_host_get_nb_pstates(SIMIX_host_self());
41 }
42
43 /**
44  * \brief Sets the speed of the processor (in flop/s) at a given pstate
45  *
46  * \param pstate_index pstate to switch to
47  */
48 void smpi_set_host_power_peak_at(int pstate_index)
49 {
50   simcall_host_set_power_peak_at(SIMIX_host_self(), pstate_index);
51 }
52
53 /**
54  * \brief Return the total energy consumed by a host (in Joules)
55  *
56  * \return Returns the consumed energy
57  */
58 double smpi_get_host_consumed_energy(void)
59 {
60   return simcall_host_get_consumed_energy(SIMIX_host_self());
61 }
62
63 #include "smpi/smpif.h"
64
65 #ifdef SMPI_F2C
66
67 XBT_PUBLIC(doublereal) smpi_get_host_power_peak_at_(integer *pstate_index);
68 doublereal smpi_get_host_power_peak_at_(integer *pstate_index)
69 {
70   return (doublereal)smpi_get_host_power_peak_at((int)*pstate_index);
71 }
72
73 XBT_PUBLIC(doublereal) smpi_get_host_current_power_peak_(void);
74 doublereal smpi_get_host_current_power_peak_(void)
75 {
76   return smpi_get_host_current_power_peak();
77 }
78
79 XBT_PUBLIC(integer) smpi_get_host_nb_pstates_(void);
80 integer smpi_get_host_nb_pstates_(void)
81 {
82   return (integer)smpi_get_host_nb_pstates();
83 }
84
85 XBT_PUBLIC(void) smpi_set_host_power_peak_at_(integer *pstate_index);
86 void smpi_set_host_power_peak_at_(integer *pstate_index)
87 {
88   smpi_set_host_power_peak_at((int)*pstate_index);
89 }
90
91 XBT_PUBLIC(doublereal) smpi_get_host_consumed_energy_(void);
92 doublereal smpi_get_host_consumed_energy_(void)
93 {
94   return (doublereal)smpi_get_host_consumed_energy();
95 }
96
97 #endif