#include <xbt/string.hpp>
#include <xbt/Extendable.hpp>
+
namespace simgrid {
XBT_PUBLIC_CLASS Host :
public simgrid::xbt::Extendable<Host> {
public:
- surf::Cpu *p_cpu = nullptr;
- surf::NetCard *p_netcard = nullptr;
+ double getSpeed();
+ int getCoreAmount();
+ /* FIXME: these should be protected, but it leads to many errors */
+ surf::Cpu *p_cpu = nullptr;
+ surf::NetCard *p_netcard = nullptr;
private:
simgrid::xbt::string name_ = "noname";
public:
XBT_PUBLIC(void) sg_host_init(void);
// =========== user-level functions ===============
-XBT_PUBLIC(double) sg_host_get_speed(sg_host_t host);
XBT_PUBLIC(double) sg_host_get_available_speed(sg_host_t host);
-XBT_PUBLIC(int) sg_host_get_core(sg_host_t host);
XBT_PUBLIC(int) sg_host_get_state(sg_host_t host);
XBT_PUBLIC(int) sg_host_get_nb_pstates(sg_host_t host);
* \brief Return the speed of the processor (in flop/s), regardless of
the current load on the machine.
*/
-double MSG_get_host_speed(msg_host_t h)
-{
- xbt_assert((h != NULL), "Invalid parameters");
-
- return sg_host_get_speed(h);
+double MSG_get_host_speed(msg_host_t host) {
+ return host->getSpeed();
}
* \param host a host
* \return the number of cores
*/
-int MSG_host_get_core_number(msg_host_t host)
-{
- xbt_assert((host != NULL), "Invalid parameters");
-
- return sg_host_get_core(host);
+int MSG_host_get_core_number(msg_host_t host) {
+ return host->getCoreAmount();
}
/** \ingroup m_host_management
#include "src/simdag/simdag_private.h"
#include "simgrid/simdag.h"
-#include "simgrid/host.h"
+#include "simgrid/Host.hpp"
#include "xbt/dict.h"
#include "xbt/lib.h"
#include "xbt/sysdep.h"
*/
double SD_workstation_get_power(SD_workstation_t workstation)
{
- return sg_host_get_speed(workstation);
+ return workstation->getSpeed();
}
/**
* \brief Returns the amount of cores of a workstation
* \return the amount of cores of this workstation
*/
int SD_workstation_get_cores(SD_workstation_t workstation) {
- return sg_host_get_core(workstation);
+ return workstation->getCoreAmount();
}
/**
// =========== user-level functions ===============
// ================================================
-/** @brief Get the speed of the cpu associated to a host */
-double sg_host_get_speed(sg_host_t host){
- return host->p_cpu->getSpeed(1.0);
-}
double sg_host_get_available_speed(sg_host_t host){
return surf_host_get_available_speed(host);
}
-/** @brief Returns the number of core of the processor. */
-int sg_host_get_core(sg_host_t host) {
- return host->p_cpu->getCore();
-}
/** @brief Returns the state of a host.
* @return 1 if the host is active or 0 if it has crashed.
*/
{
}
+/** @brief Get the speed of the cpu associated to a host */
+double Host::getSpeed() {
+ return p_cpu->getSpeed(1.0);
+}
+/** @brief Returns the number of core of the processor. */
+int Host::getCoreAmount() {
+ return p_cpu->getCore();
+}
+
Host* Host::by_name_or_null(const char* name)
{
return (Host*) xbt_dict_get_or_null(host_list, name);