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"
19 // FIXME: rework these bindings, or kill them completely
21 #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
24 typedef long int integer;
26 typedef double doublereal;
29 * @brief Return the speed of the processor (in flop/s) at a given pstate
31 * @param pstate_index pstate to test
32 * @return Returns the processor speed associated with pstate_index
34 extern "C" XBT_PUBLIC doublereal smpi_get_host_power_peak_at_(integer* pstate_index);
35 doublereal smpi_get_host_power_peak_at_(integer *pstate_index)
37 return static_cast<doublereal>(sg_host_self()->get_pstate_speed(static_cast<int>(*pstate_index)));
41 * @brief Return the current speed of the processor (in flop/s)
43 * @return Returns the current processor speed
45 extern "C" XBT_PUBLIC doublereal smpi_get_host_current_power_peak_();
46 doublereal smpi_get_host_current_power_peak_()
48 return static_cast<doublereal>(sg_host_self()->get_speed());
52 * @brief Return the number of pstates defined for the current host
54 extern "C" XBT_PUBLIC integer smpi_get_host_nb_pstates_();
55 integer smpi_get_host_nb_pstates_()
57 return static_cast<integer>(sg_host_self()->get_pstate_count());
61 * @brief Sets the pstate at which the processor should run
63 * @param pstate_index pstate to switch to
65 extern "C" XBT_PUBLIC void smpi_set_host_pstate_(integer* pstate_index);
66 void smpi_set_host_pstate_(integer *pstate_index)
68 sg_host_set_pstate(sg_host_self(), (static_cast<int>(*pstate_index)));
72 * @brief Gets the pstate at which the processor currently running
74 extern "C" XBT_PUBLIC integer smpi_get_host_pstate_();
75 integer smpi_get_host_pstate_()
77 return static_cast<integer>(sg_host_get_pstate(sg_host_self()));
80 * @brief Return the total energy consumed by a host (in Joules)
82 * @return Returns the consumed energy
84 extern "C" XBT_PUBLIC doublereal smpi_get_host_consumed_energy_();
85 doublereal smpi_get_host_consumed_energy_()
87 return static_cast<doublereal>(sg_host_get_consumed_energy(sg_host_self()));