Logo AND Algorithmique Numérique Distribuée

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