Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove completely the energy concern from the core
[simgrid.git] / src / smpi / smpi_dvfs.c
1 /* Copyright (c) 2013-2015. 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 "simgrid/plugins/energy.h" // FIXME: this plugin should be separated from the core
8 #include "xbt/log.h"
9 #include "simgrid/simix.h"
10 #include "smpi/smpi.h"
11 #include "src/internal_config.h"
12
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_dvfs, smpi,
14                                 "Logging specific to SMPI (experimental DVFS support)");
15
16 /**
17  * \brief Return the speed of the processor (in flop/s) at a given pstate
18  *
19  * \param pstate_index pstate to test
20  * \return Returns the processor speed associated with pstate_index
21  */
22 double smpi_get_host_power_peak_at(int pstate_index)
23 {
24   return simcall_host_get_power_peak_at(SIMIX_host_self(), pstate_index);
25 }
26
27 /**
28  * \brief Return the current speed of the processor (in flop/s)
29  *
30  * \return Returns the current processor speed
31  */
32 double smpi_get_host_current_power_peak(void)
33 {
34   return simcall_host_get_current_power_peak(SIMIX_host_self());
35 }
36
37 /**
38  * \brief Return the number of pstates defined for the current host
39  */
40 int smpi_get_host_nb_pstates(void)
41 {
42   return sg_host_get_nb_pstates(SIMIX_host_self());
43 }
44
45 /**
46  * \brief Sets the pstate at which the processor should run
47  *
48  * \param pstate_index pstate to switch to
49  */
50 void smpi_set_host_pstate(int pstate_index)
51 {
52   sg_host_set_pstate(SIMIX_host_self(), pstate_index);
53 }
54 /**
55  * \brief Gets the pstate at which the processor currently running
56  *
57  * \param pstate_index pstate to switch to
58  */
59 int smpi_get_host_pstate() {
60   return sg_host_get_pstate(SIMIX_host_self());
61 }
62
63 /**
64  * \brief Return the total energy consumed by a host (in Joules)
65  *
66  * \return Returns the consumed energy
67  */
68 double smpi_get_host_consumed_energy(void) {
69   return sg_host_get_consumed_energy(SIMIX_host_self());
70 }
71
72
73 #ifdef SMPI_FORTRAN
74
75 #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
76 typedef int integer;
77 typedef unsigned int uinteger;
78 #else
79 typedef long int integer;
80 typedef unsigned long int uinteger;
81 #endif
82 typedef char *address;
83 typedef short int shortint;
84 typedef float real;
85 typedef double doublereal;
86 typedef struct { real r, i; } complex;
87 typedef struct { doublereal r, i; } doublecomplex;
88
89 XBT_PUBLIC(doublereal) smpi_get_host_power_peak_at_(integer *pstate_index);
90 doublereal smpi_get_host_power_peak_at_(integer *pstate_index)
91 {
92   return (doublereal)smpi_get_host_power_peak_at((int)*pstate_index);
93 }
94
95 XBT_PUBLIC(doublereal) smpi_get_host_current_power_peak_(void);
96 doublereal smpi_get_host_current_power_peak_(void)
97 {
98   return smpi_get_host_current_power_peak();
99 }
100
101 XBT_PUBLIC(integer) smpi_get_host_nb_pstates_(void);
102 integer smpi_get_host_nb_pstates_(void)
103 {
104   return (integer)smpi_get_host_nb_pstates();
105 }
106
107 XBT_PUBLIC(void) smpi_set_host_pstate_(integer *pstate_index);
108 void smpi_set_host_pstate_(integer *pstate_index)
109 {
110   smpi_set_host_pstate((int)*pstate_index);
111 }
112
113 XBT_PUBLIC(doublereal) smpi_get_host_consumed_energy_(void);
114 doublereal smpi_get_host_consumed_energy_(void)
115 {
116   return (doublereal)smpi_get_host_consumed_energy();
117 }
118
119 #endif