From 24e3d7b3bb3312445ad0986fc67853995031bea0 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Wed, 13 Jan 2016 14:43:24 +0100 Subject: [PATCH] Merge simgrid::Host into simgrid::s4u::Host --- examples/s4u/io/s4u_io_test.cpp | 3 +- include/simgrid/Host.hpp | 70 ------------ include/simgrid/forward.h | 19 ++-- include/simgrid/host.h | 2 +- include/simgrid/s4u/host.hpp | 70 +++++++++--- src/bindings/java/jmsg.cpp | 2 +- src/mc/mc_smx.cpp | 6 +- src/msg/msg_global.cpp | 2 +- src/msg/msg_host.cpp | 6 +- src/msg/msg_vm.cpp | 4 +- src/s4u/s4u_actor.cpp | 2 +- src/s4u/s4u_file.cpp | 10 +- src/s4u/s4u_host.cpp | 171 ++++++++++++++++++++++++---- src/simdag/sd_workstation.cpp | 2 +- src/simgrid/host.cpp | 179 +++--------------------------- src/simix/smx_global.cpp | 2 +- src/simix/smx_host.cpp | 2 +- src/surf/cpu_cas01.cpp | 4 +- src/surf/cpu_cas01.hpp | 4 +- src/surf/cpu_interface.cpp | 8 +- src/surf/cpu_interface.hpp | 13 ++- src/surf/cpu_ti.cpp | 4 +- src/surf/cpu_ti.hpp | 4 +- src/surf/host_interface.cpp | 14 +-- src/surf/host_interface.hpp | 8 +- src/surf/host_ptask_L07.cpp | 4 +- src/surf/host_ptask_L07.hpp | 4 +- src/surf/network_constant.cpp | 2 +- src/surf/network_ib.cpp | 6 +- src/surf/network_ns3.cpp | 6 +- src/surf/ns3/ns3_interface.h | 2 +- src/surf/plugins/energy.cpp | 28 ++--- src/surf/plugins/energy.hpp | 6 +- src/surf/sg_platf.cpp | 4 +- src/surf/surf_c_bindings.cpp | 2 +- src/surf/surf_interface.cpp | 4 +- src/surf/surf_routing.cpp | 2 +- src/surf/surf_routing_vivaldi.cpp | 8 +- src/surf/virtual_machine.cpp | 4 +- src/surf/virtual_machine.hpp | 4 +- src/surf/vm_hl13.cpp | 7 +- tools/cmake/DefinePackages.cmake | 1 - 42 files changed, 328 insertions(+), 377 deletions(-) delete mode 100644 include/simgrid/Host.hpp diff --git a/examples/s4u/io/s4u_io_test.cpp b/examples/s4u/io/s4u_io_test.cpp index eee430357a..846ac4c735 100644 --- a/examples/s4u/io/s4u_io_test.cpp +++ b/examples/s4u/io/s4u_io_test.cpp @@ -17,7 +17,8 @@ public: : simgrid::s4u::Actor(procname,host,argc,argv){} void show_info(boost::unordered_map &mounts) { - XBT_INFO("Storage info on %s:", simgrid::s4u::Host::current()->name()); + XBT_INFO("Storage info on %s:", + simgrid::s4u::Host::current()->name().c_str()); for (const auto&kv : mounts) { const char* mountpoint = kv.first.c_str(); diff --git a/include/simgrid/Host.hpp b/include/simgrid/Host.hpp deleted file mode 100644 index 50e1fa1d4a..0000000000 --- a/include/simgrid/Host.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (c) 2015. The SimGrid Team. - * All rights reserved. */ - -/* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ - -#ifndef SIMGRID_HOST_HPP -#define SIMGRID_HOST_HPP - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -namespace simgrid { - -XBT_PUBLIC_CLASS Host : -public simgrid::xbt::Extendable { - -public: - double getSpeed(); - int getCoreAmount(); - - /* FIXME: these should be protected, but it leads to many errors */ - surf::Cpu *pimpl_cpu = nullptr; - surf::NetCard *pimpl_netcard = nullptr; -private: - simgrid::xbt::string name_ = "noname"; -public: - Host(std::string const& name); - ~Host(); - simgrid::xbt::string const& getName() const { return name_; } - void turnOn(); - void turnOff(); - bool isOn(); - bool isOff(); - xbt_dict_t getProperties(); - xbt_swag_t getProcessList(); - double getCurrentPowerPeak(); - double getPowerPeakAt(int pstate_index); - void setPState(int pstate_index); - int getPState(); - void getParams(vm_params_t params); - void setParams(vm_params_t params); - xbt_dict_t getMountedStorageList(); - xbt_dynar_t getAttachedStorageList(); - - static Host* by_name_or_null(const char* name); - static Host* by_name_or_create(const char* name); - - /*** Called on each newly created object */ - static simgrid::xbt::signal onCreation; - /*** Called just before destructing an object */ - static simgrid::xbt::signal onDestruction; - /*** Called when the machine is turned on or off */ - static simgrid::xbt::signal onStateChange; -}; - -} - -#endif diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 2961972572..5f77905506 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -12,21 +12,22 @@ #ifdef __cplusplus namespace simgrid { -class Host; + namespace s4u { + class Host; + } + namespace surf { + class Cpu; + class NetCard; + class As; + class Link; + } } namespace simgrid { -namespace surf { -class Cpu; -class NetCard; -class As; -class Link; - -} } -typedef simgrid::Host simgrid_Host; +typedef simgrid::s4u::Host simgrid_Host; typedef simgrid::surf::Cpu surf_Cpu; typedef simgrid::surf::NetCard surf_NetCard; typedef simgrid::surf::As surf_As; diff --git a/include/simgrid/host.h b/include/simgrid/host.h index 3de390582e..282fa76291 100644 --- a/include/simgrid/host.h +++ b/include/simgrid/host.h @@ -15,7 +15,7 @@ #include #ifdef __cplusplus -#include +#include #endif SG_BEGIN_DECL() diff --git a/include/simgrid/s4u/host.hpp b/include/simgrid/s4u/host.hpp index 8eab63d441..0de509fe02 100644 --- a/include/simgrid/s4u/host.hpp +++ b/include/simgrid/s4u/host.hpp @@ -9,8 +9,13 @@ #include #include -#include "xbt/base.h" -#include "simgrid/simix.h" +#include +#include +#include +#include + +#include +#include namespace simgrid { namespace s4u { @@ -30,12 +35,14 @@ class File; * You can retrieve a particular host using @link{simgrid::s4u::Host.byName()}, * and actors can retrieve the host on which they run using @link{simgrid::s4u::Host.current()}. */ -XBT_PUBLIC_CLASS Host { - friend Actor; - friend File; +XBT_PUBLIC_CLASS Host : + public simgrid::xbt::Extendable { + + // friend Actor; + // friend File; private: Host(const char *name); -protected: +public: // TODO, make me private ~Host(); public: /** Retrieves an host from its name. */ @@ -43,7 +50,10 @@ public: /** Retrieves the host on which the current actor is running */ static s4u::Host *current(); - const char* name(); + static Host* by_name_or_null(const char* name); + static Host* by_name_or_create(const char* name); + + simgrid::xbt::string const& name() const { return name_; } /** Turns that host on if it was previously off * @@ -55,9 +65,24 @@ public: void turnOff(); /** Returns if that host is currently up and running */ bool isOn(); - + bool isOff() { return !isOn(); } + + double getSpeed(); + int getCoreAmount(); + xbt_dict_t getProperties(); + xbt_swag_t getProcessList(); + double getCurrentPowerPeak(); + double getPowerPeakAt(int pstate_index); + void setPState(int pstate_index); + int getNbPStates() const; + int getPState(); + void getParams(vm_params_t params); + void setParams(vm_params_t params); + xbt_dict_t getMountedStorageList(); + xbt_dynar_t getAttachedStorageList(); /** Allows to store user data on that host */ + // TODO, use the extension stuff instead void set_userdata(void *data) {p_userdata = data;} /** Retrieves the previously stored data */ void* userdata() {return p_userdata;} @@ -68,20 +93,39 @@ public: * * Do not change the returned value in any way. */ + // TODO, do not use Storage&, this looks dangerous! boost::unordered_map &mountedStorages(); + private: + simgrid::xbt::string name_ = "noname"; boost::unordered_map *mounts = NULL; // caching + void* p_userdata = NULL; -protected: - sg_host_t inferior() {return p_inferior;} -private: - void*p_userdata=NULL; - sg_host_t p_inferior; +public: + // FIXME: these should be protected, but it leads to many errors + // Use the extensions stuff for this? Go through simgrid::surf::Host? + surf::Cpu *pimpl_cpu = nullptr; + surf::NetCard *pimpl_netcard = nullptr; + +public: static boost::unordered_map *hosts; + + /*** Called on each newly created object */ + static simgrid::xbt::signal onCreation; + /*** Called just before destructing an object */ + static simgrid::xbt::signal onDestruction; + /*** Called when the machine is turned on or off */ + static simgrid::xbt::signal onStateChange; }; }} // namespace simgrid::s4u +extern int MSG_HOST_LEVEL; +extern int SD_HOST_LEVEL; +extern int SIMIX_HOST_LEVEL; +extern int ROUTING_HOST_LEVEL; +extern int USER_HOST_LEVEL; + #endif /* SIMGRID_S4U_HOST_HPP */ #if 0 diff --git a/src/bindings/java/jmsg.cpp b/src/bindings/java/jmsg.cpp index 1b700b7a52..a3479b3a53 100644 --- a/src/bindings/java/jmsg.cpp +++ b/src/bindings/java/jmsg.cpp @@ -134,7 +134,7 @@ Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs) MSG_init(&argc, argv); - JAVA_HOST_LEVEL = simgrid::Host::extension_create(__JAVA_host_priv_free); + JAVA_HOST_LEVEL = simgrid::s4u::Host::extension_create(__JAVA_host_priv_free); JAVA_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, __JAVA_storage_priv_free); for (index = 0; index < argc; index++) diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index 325ea151e8..0343dae79b 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -180,7 +180,7 @@ const char* MC_smx_process_get_host_name(smx_process_t p) simgrid::mc::Process* process = &mc_model_checker->process(); - /* Horrible hack to find the offset of the id in the simgrid::Host. + /* Horrible hack to find the offset of the id in the simgrid::s4u::Host. Offsetof is not supported for non-POD types but this should work in pratice for the targets currently supported by the MC @@ -188,10 +188,10 @@ const char* MC_smx_process_get_host_name(smx_process_t p) (such as virtual base). We are using a (C++11) unrestricted union in order to avoid - any construction/destruction of the simgrid::Host. + any construction/destruction of the simgrid::s4u::Host. */ union fake_host { - simgrid::Host host; + simgrid::s4u::Host host; fake_host() {} ~fake_host() {} }; diff --git a/src/msg/msg_global.cpp b/src/msg/msg_global.cpp index 922fb423f0..a025930960 100644 --- a/src/msg/msg_global.cpp +++ b/src/msg/msg_global.cpp @@ -68,7 +68,7 @@ void MSG_init_nocheck(int *argc, char **argv) { SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX); sg_platf_postparse_add_cb(MSG_post_create_environment); - simgrid::Host::onCreation.connect([](simgrid::Host& host) { + simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) { MSG_host_create_(&host); }); } diff --git a/src/msg/msg_host.cpp b/src/msg/msg_host.cpp index 8bf412515f..140253967e 100644 --- a/src/msg/msg_host.cpp +++ b/src/msg/msg_host.cpp @@ -9,7 +9,7 @@ #include "xbt/sysdep.h" #include "xbt/log.h" #include "simgrid/simix.h" -#include "simgrid/Host.hpp" +#include XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg); @@ -73,7 +73,7 @@ msg_host_t __MSG_host_create(sg_host_t host) // FIXME: don't return our paramete */ msg_host_t MSG_host_by_name(const char *name) { - return simgrid::Host::by_name_or_null(name); + return simgrid::s4u::Host::by_name_or_null(name); } /** \ingroup m_host_management @@ -181,7 +181,7 @@ msg_host_t *MSG_get_host_table(void) xbt_lib_cursor_t cursor; const char *id; - simgrid::Host* host; + simgrid::s4u::Host* host; xbt_dict_foreach(host_list, cursor, id, host) if(routing_get_network_element_type(key) == SURF_NETWORK_ELEMENT_HOST) array[i++] = host->facet(MSG_HOST_LEVEL); diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 905f3a94f0..6510b2a29d 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -209,8 +209,8 @@ msg_vm_t MSG_vm_create_core(msg_host_t ind_pm, const char *name) { /* make sure the VM of the same name does not exit */ { - simgrid::Host* ind_host_tmp = - (simgrid::Host*) xbt_dict_get_or_null(host_list, name); + simgrid::s4u::Host* ind_host_tmp = + (simgrid::s4u::Host*) xbt_dict_get_or_null(host_list, name); if (ind_host_tmp != nullptr && sg_host_simix(ind_host_tmp) != nullptr) { XBT_ERROR("host %s already exits", name); return nullptr; diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 6176ef7954..1753479708 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -35,7 +35,7 @@ s4u::Actor::Actor(const char *name, s4u::Host *host, int argc, char **argv) : s4u::Actor::Actor(name,host, argc,argv, -1) { } s4u::Actor::Actor(const char *name, s4u::Host *host, int argc, char **argv, double killTime) { - p_smx_process = simcall_process_create(name, s4u_actor_runner, this, host->name(), killTime, argc, argv, NULL/*properties*/,0); + p_smx_process = simcall_process_create(name, s4u_actor_runner, this, host->name().c_str(), killTime, argc, argv, NULL/*properties*/,0); xbt_assert(p_smx_process,"Cannot create the actor"); // TRACE_msg_process_create(procname, simcall_process_get_PID(p_smx_process), host->getInferior()); diff --git a/src/s4u/s4u_file.cpp b/src/s4u/s4u_file.cpp index 94a594745d..e68d191414 100644 --- a/src/s4u/s4u_file.cpp +++ b/src/s4u/s4u_file.cpp @@ -23,19 +23,19 @@ namespace s4u { File::File(const char*fullpath, void *userdata) { // this cannot fail because we get a xbt_die if the mountpoint does not exist - p_inferior = simcall_file_open(fullpath, Host::current()->inferior()); + p_inferior = simcall_file_open(fullpath, Host::current()); p_path = fullpath; } File::~File() { - simcall_file_close(p_inferior, Host::current()->inferior()); + simcall_file_close(p_inferior, Host::current()); } sg_size_t File::read(sg_size_t size) { - return simcall_file_read(p_inferior, size, Host::current()->inferior()); + return simcall_file_read(p_inferior, size, Host::current()); } sg_size_t File::write(sg_size_t size) { - return simcall_file_write(p_inferior,size, Host::current()->inferior()); + return simcall_file_write(p_inferior,size, Host::current()); } sg_size_t File::size() { return simcall_file_get_size(p_inferior); @@ -51,7 +51,7 @@ void File::move(const char*fullpath) { simcall_file_move(p_inferior,fullpath); } void File::unlink() { - sg_host_t attached = Host::current()->inferior(); // FIXME: we should check where this file is attached + sg_host_t attached = Host::current(); // FIXME: we should check where this file is attached simcall_file_unlink(p_inferior,attached); } diff --git a/src/s4u/s4u_host.cpp b/src/s4u/s4u_host.cpp index f878ce80eb..9bab734630 100644 --- a/src/s4u/s4u_host.cpp +++ b/src/s4u/s4u_host.cpp @@ -4,69 +4,86 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include +#include +#include + +#include + +#include + #include "xbt/log.h" #include "src/msg/msg_private.h" #include "src/simix/smx_process_private.h" +#include "src/simix/smx_private.hpp" +#include "src/surf/cpu_interface.hpp" +#include "src/surf/host_interface.hpp" #include "simgrid/s4u/host.hpp" #include "simgrid/s4u/storage.hpp" +int MSG_HOST_LEVEL; +int SD_HOST_LEVEL; +int SIMIX_HOST_LEVEL; +int ROUTING_HOST_LEVEL; +int USER_HOST_LEVEL; + namespace simgrid { namespace s4u { boost::unordered_map *Host::hosts = new boost::unordered_map(); -Host::Host(const char*name) +simgrid::xbt::signal Host::onCreation; +simgrid::xbt::signal Host::onDestruction; +simgrid::xbt::signal Host::onStateChange; + +Host::Host(const char* name) + : name_(name) { - p_inferior = sg_host_by_name(name); - if (p_inferior==NULL) - xbt_die("No such host: %s",name); //FIXME: raise an exception } + Host::~Host() { if (mounts != NULL) delete mounts; } Host *Host::byName(std::string name) { - Host * res = NULL; - try { - res = hosts->at(name); - } catch (std::out_of_range& e) {} - - if (res==NULL) { - res = new Host(name.c_str()); - hosts->insert({name,res}); - } - return res; + Host* host = Host::by_name_or_null(name.c_str()); + // TODO, raise an exception instead? + if (host == nullptr) + xbt_die("No such host: %s", name.c_str()); + return host; } + Host *Host::current(){ smx_process_t smx_proc = SIMIX_process_self(); if (smx_proc == NULL) xbt_die("Cannot call Host::current() from the maestro context"); - - return Host::byName(sg_host_get_name(SIMIX_process_get_host(smx_proc))); -} - -const char* Host::name() { - return sg_host_get_name(p_inferior); + return SIMIX_process_get_host(smx_proc); } void Host::turnOn() { - p_inferior->turnOn(); + simgrid::simix::kernel(std::bind(SIMIX_host_on, this)); } + void Host::turnOff() { - p_inferior->turnOff(); + simgrid::simix::simcall(SIMCALL_HOST_OFF, this); } + bool Host::isOn() { - return sg_host_is_on(p_inferior); + return this->pimpl_cpu->isOn(); +} + +int Host::getNbPStates() const { + return this->pimpl_cpu->getNbPStates(); } boost::unordered_map &Host::mountedStorages() { if (mounts == NULL) { mounts = new boost::unordered_map (); - xbt_dict_t dict = p_inferior->getMountedStorageList(); + xbt_dict_t dict = this->getMountedStorageList(); xbt_dict_cursor_t cursor; char *mountname; @@ -80,6 +97,112 @@ boost::unordered_map &Host::mountedStorages() { return *mounts; } +/** Get the properties assigned to a host */ +xbt_dict_t Host::getProperties() { + return simgrid::simix::kernel([&] { + simgrid::surf::Host* surf_host = this->extension(); + return surf_host->getProperties(); + }); +} + +/** Get the processes attached to the host */ +xbt_swag_t Host::getProcessList() +{ + return simgrid::simix::kernel([&]() { + return ((smx_host_priv_t)this->extension(SIMIX_HOST_LEVEL))->process_list; + }); +} + +/** Get the peak power of a host */ +double Host::getCurrentPowerPeak() +{ + return simgrid::simix::kernel([&] { + return this->pimpl_cpu->getCurrentPowerPeak(); + }); +} + +/** Get one power peak (in flops/s) of a host at a given pstate */ +double Host::getPowerPeakAt(int pstate_index) +{ + return simgrid::simix::kernel([&] { + return this->pimpl_cpu->getPowerPeakAt(pstate_index); + }); +} + +/** @brief Get the speed of the cpu associated to a host */ +double Host::getSpeed() { + return pimpl_cpu->getSpeed(1.0); +} +/** @brief Returns the number of core of the processor. */ +int Host::getCoreAmount() { + return pimpl_cpu->getCore(); +} + +Host* Host::by_name_or_null(const char* name) +{ + return (Host*) xbt_dict_get_or_null(host_list, name); +} + +Host* Host::by_name_or_create(const char* name) +{ + Host* host = by_name_or_null(name); + if (host == nullptr) { + host = new Host(name); + xbt_dict_set(host_list, name, host, NULL); + } + return host; +} + +/** @brief Set the pstate at which the host should run */ +void Host::setPState(int pstate_index) +{ + simgrid::simix::kernel(std::bind( + &simgrid::surf::Cpu::setPState, pimpl_cpu, pstate_index + )); +} +/** @brief Retrieve the pstate at which the host is currently running */ +int Host::getPState() +{ + return pimpl_cpu->getPState(); +} + +void Host::getParams(vm_params_t params) +{ + simgrid::simix::kernel([&]() { + this->extension()->getParams(params); + }); +} + +void Host::setParams(vm_params_t params) +{ + simgrid::simix::kernel([&]() { + this->extension()->setParams(params); + }); +} + +/** + * \ingroup simix_storage_management + * \brief Returns the list of storages mounted on an host. + * \return a dict containing all storages mounted on the host + */ +xbt_dict_t Host::getMountedStorageList() +{ + return simgrid::simix::kernel([&] { + return this->extension()->getMountedStorageList(); + }); +} + +/** + * \ingroup simix_storage_management + * \brief Returns the list of storages attached to an host. + * \return a dict containing all storages attached to the host + */ +xbt_dynar_t Host::getAttachedStorageList() +{ + return simgrid::simix::kernel([&] { + return this->extension()->getAttachedStorageList(); + }); +} } // namespace simgrid } // namespace s4u diff --git a/src/simdag/sd_workstation.cpp b/src/simdag/sd_workstation.cpp index afbb21014b..68bb80e4f6 100644 --- a/src/simdag/sd_workstation.cpp +++ b/src/simdag/sd_workstation.cpp @@ -7,7 +7,7 @@ #include "src/surf/host_interface.hpp" #include "src/simdag/simdag_private.h" #include "simgrid/simdag.h" -#include "simgrid/Host.hpp" +#include #include "xbt/dict.h" #include "xbt/lib.h" #include "xbt/sysdep.h" diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index 711c740666..dcde167a03 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -4,11 +4,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include - #include "xbt/dict.h" #include "simgrid/host.h" -#include "simgrid/Host.hpp" +#include +#include #include "surf/surf.h" // routing_get_network_element_type FIXME:killme #include "src/simix/smx_private.hpp" @@ -21,7 +20,7 @@ size_t sg_host_count() const char *sg_host_get_name(sg_host_t host) { - return host->getName().c_str(); + return host->name().c_str(); } void* sg_host_extension_get(sg_host_t host, size_t ext) @@ -31,17 +30,17 @@ void* sg_host_extension_get(sg_host_t host, size_t ext) size_t sg_host_extension_create(void(*deleter)(void*)) { - return simgrid::Host::extension_create(deleter); + return simgrid::s4u::Host::extension_create(deleter); } sg_host_t sg_host_by_name(const char *name) { - return simgrid::Host::by_name_or_null(name); + return simgrid::s4u::Host::by_name_or_null(name); } sg_host_t sg_host_by_name_or_create(const char *name) { - return simgrid::Host::by_name_or_create(name); + return simgrid::s4u::Host::by_name_or_create(name); } xbt_dynar_t sg_hosts_as_dynar(void) @@ -50,20 +49,14 @@ xbt_dynar_t sg_hosts_as_dynar(void) xbt_dict_cursor_t cursor = nullptr; const char* name = nullptr; - simgrid::Host* host = nullptr; + simgrid::s4u::Host* host = nullptr; xbt_dict_foreach(host_list, cursor, name, host) if(routing_get_network_element_type(name) == SURF_NETWORK_ELEMENT_HOST) xbt_dynar_push(res, &host); return res; } -// ========= Layering madness ============== - -int MSG_HOST_LEVEL; -int SD_HOST_LEVEL; -int SIMIX_HOST_LEVEL; -int ROUTING_HOST_LEVEL; -int USER_HOST_LEVEL; +// ========= Layering madness ==============* #include "src/msg/msg_private.h" // MSG_host_priv_free. FIXME: killme by initializing that level in msg when used #include "src/simdag/simdag_private.h" // __SD_workstation_destroy. FIXME: killme by initializing that level in simdag when used @@ -73,17 +66,17 @@ int USER_HOST_LEVEL; void sg_host_init() { - MSG_HOST_LEVEL = simgrid::Host::extension_create([](void *p) { + MSG_HOST_LEVEL = simgrid::s4u::Host::extension_create([](void *p) { __MSG_host_priv_free((msg_host_priv_t) p); }); - ROUTING_HOST_LEVEL = simgrid::Host::extension_create([](void *p) { + ROUTING_HOST_LEVEL = simgrid::s4u::Host::extension_create([](void *p) { delete static_cast(p); }); - SD_HOST_LEVEL = simgrid::Host::extension_create(__SD_workstation_destroy); - SIMIX_HOST_LEVEL = simgrid::Host::extension_create(SIMIX_host_destroy); - USER_HOST_LEVEL = simgrid::Host::extension_create(NULL); + SD_HOST_LEVEL = simgrid::s4u::Host::extension_create(__SD_workstation_destroy); + SIMIX_HOST_LEVEL = simgrid::s4u::Host::extension_create(SIMIX_host_destroy); + USER_HOST_LEVEL = simgrid::s4u::Host::extension_create(NULL); } // ========== User data Layer ========== @@ -136,7 +129,7 @@ double sg_host_get_available_speed(sg_host_t host){ * @return 1 if the host is active or 0 if it has crashed. */ int sg_host_is_on(sg_host_t host) { - return host->pimpl_cpu->isOn(); + return host->isOn(); } /** @brief Returns the number of power states for a host. @@ -144,7 +137,7 @@ int sg_host_is_on(sg_host_t host) { * See also @ref SURF_plugin_energy. */ int sg_host_get_nb_pstates(sg_host_t host) { - return host->pimpl_cpu->getNbPStates(); + return host->getNbPStates(); } /** @brief Gets the pstate at which that host currently runs. @@ -167,145 +160,3 @@ xbt_dict_t sg_host_get_properties(sg_host_t host) { return host->getProperties(); } - -namespace simgrid { - -simgrid::xbt::signal Host::onCreation; -simgrid::xbt::signal Host::onDestruction; -simgrid::xbt::signal Host::onStateChange; - -Host::Host(std::string const& id) - : name_(id) -{ -} - -Host::~Host() -{ -} - -/** Start the host if it is off */ -void Host::turnOn() -{ - simgrid::simix::kernel(std::bind(SIMIX_host_on, this)); -} - -/** Stop the host if it is on */ -void Host::turnOff() -{ - simgrid::simix::simcall(SIMCALL_HOST_OFF, this); -} - -bool Host::isOn() { - return pimpl_cpu->isOn(); -} -bool Host::isOff() { - return ! pimpl_cpu->isOn(); -} - - -/** Get the properties assigned to a host */ -xbt_dict_t Host::getProperties() -{ - return simgrid::simix::kernel(std::bind(&simgrid::surf::Host::getProperties, this->extension(simgrid::surf::Host::EXTENSION_ID))); -} - -/** Get the processes attached to the host */ -xbt_swag_t Host::getProcessList() -{ - return simgrid::simix::kernel([&]() { - return ((smx_host_priv_t)this->extension(SIMIX_HOST_LEVEL))->process_list; - }); -} - -/** Get the peak power of a host */ -double Host::getCurrentPowerPeak() -{ - return simgrid::simix::kernel([&] { - return this->pimpl_cpu->getCurrentPowerPeak(); - }); -} - -/** Get one power peak (in flops/s) of a host at a given pstate */ -double Host::getPowerPeakAt(int pstate_index) -{ - return simgrid::simix::kernel([&] { - return this->pimpl_cpu->getPowerPeakAt(pstate_index); - }); -} - -/** @brief Get the speed of the cpu associated to a host */ -double Host::getSpeed() { - return pimpl_cpu->getSpeed(1.0); -} -/** @brief Returns the number of core of the processor. */ -int Host::getCoreAmount() { - return pimpl_cpu->getCore(); -} - -Host* Host::by_name_or_null(const char* name) -{ - return (Host*) xbt_dict_get_or_null(host_list, name); -} - -Host* Host::by_name_or_create(const char* name) -{ - Host* host = by_name_or_null(name); - if (host == nullptr) { - host = new Host(name); - xbt_dict_set(host_list, name, host, NULL); - } - return host; -} - -/** @brief Set the pstate at which the host should run */ -void Host::setPState(int pstate_index) -{ - simgrid::simix::kernel(std::bind( - &simgrid::surf::Cpu::setPState, pimpl_cpu, pstate_index - )); -} -/** @brief Retrieve the pstate at which the host is currently running */ -int Host::getPState() -{ - return pimpl_cpu->getPState(); -} - -void Host::getParams(vm_params_t params) -{ - simgrid::simix::kernel([&]() { - this->extension()->getParams(params); - }); -} - -void Host::setParams(vm_params_t params) -{ - simgrid::simix::kernel([&]() { - this->extension()->setParams(params); - }); -} - -/** - * \ingroup simix_storage_management - * \brief Returns the list of storages mounted on an host. - * \return a dict containing all storages mounted on the host - */ -xbt_dict_t Host::getMountedStorageList() -{ - return simgrid::simix::kernel([&] { - return this->extension()->getMountedStorageList(); - }); -} - -/** - * \ingroup simix_storage_management - * \brief Returns the list of storages attached to an host. - * \return a dict containing all storages attached to the host - */ -xbt_dynar_t Host::getAttachedStorageList() -{ - return simgrid::simix::kernel([&] { - return this->extension()->getAttachedStorageList(); - }); -} - -} diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index bc428ed8cd..6acc54cd18 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -231,7 +231,7 @@ void SIMIX_global_init(int *argc, char **argv) /* register a function to be called by SURF after the environment creation */ sg_platf_init(); sg_platf_postparse_add_cb(SIMIX_post_create_environment); - simgrid::Host::onCreation.connect([](simgrid::Host& host) { + simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) { SIMIX_host_create(&host); }); surf_on_storage_created(SIMIX_storage_create_); diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 6cb3ff1fc8..111f9b3534 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -111,7 +111,7 @@ void SIMIX_host_off(sg_host_t h, smx_process_t issuer) } } } else { - XBT_INFO("Host %s is already off",h->getName().c_str()); + XBT_INFO("Host %s is already off",h->name().c_str()); } } diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 9893b57cf8..6050f16a4c 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -84,7 +84,7 @@ CpuCas01Model::~CpuCas01Model() delete p_cpuRunningActionSetThatDoesNotNeedBeingChecked; } -Cpu *CpuCas01Model::createCpu(simgrid::Host *host, xbt_dynar_t speedPeak, +Cpu *CpuCas01Model::createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, int initiallyOn, @@ -137,7 +137,7 @@ void CpuCas01Model::addTraces() /************ * Resource * ************/ -CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::Host *host, xbt_dynar_t speedPeak, +CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, int initiallyOn, tmgr_trace_t stateTrace) : Cpu(model, host, diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index 30b2beaa47..b7564d7883 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -27,7 +27,7 @@ public: CpuCas01Model(); ~CpuCas01Model(); - Cpu *createCpu(simgrid::Host *host, xbt_dynar_t speedPeak, int pstate, + Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, int initiallyOn, @@ -43,7 +43,7 @@ public: class CpuCas01 : public Cpu { public: - CpuCas01(CpuCas01Model *model, simgrid::Host *host, xbt_dynar_t speedPeak, + CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, int initiallyOn, tmgr_trace_t stateTrace) ; ~CpuCas01(); diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index d8fd429171..c98acca14e 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -131,7 +131,7 @@ void CpuModel::updateActionsStateFull(double now, double delta) /************ * Resource * ************/ -Cpu::Cpu(Model *model, simgrid::Host *host, +Cpu::Cpu(Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate, int core, double speedPeak, double speedScale, int initiallyOn) @@ -139,11 +139,11 @@ Cpu::Cpu(Model *model, simgrid::Host *host, { } -Cpu::Cpu(Model *model, simgrid::Host *host, lmm_constraint_t constraint, +Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint, xbt_dynar_t speedPeakList, int pstate, int core, double speedPeak, double speedScale, int initiallyOn) - : Resource(model, host->getName().c_str(), constraint, initiallyOn) + : Resource(model, host->name().c_str(), constraint, initiallyOn) , m_core(core) , m_speedPeak(speedPeak) , m_speedScale(speedScale) @@ -173,7 +173,7 @@ Cpu::Cpu(Model *model, simgrid::Host *host, lmm_constraint_t constraint, int i; for (i = 0; i < core; i++) { /* just for a unique id, never used as a string. */ - p_constraintCoreId[i] = bprintf("%s:%i", host->getName().c_str(), i); + p_constraintCoreId[i] = bprintf("%s:%i", host->name().c_str(), i); p_constraintCore[i] = lmm_constraint_new(model->getMaxminSystem(), p_constraintCoreId[i], m_speedScale * m_speedPeak); } } diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 38c6c70929..090d41a5e4 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -53,8 +53,8 @@ public: * @param state_initial [TODO] * @param state_trace [TODO] */ - virtual Cpu *createCpu(simgrid::Host *host, xbt_dynar_t speedPeak, - int pstate, double speedScale, + virtual Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeak, + int pstate, double speedScale, tmgr_trace_t speedTrace, int core, int initiallyOn, tmgr_trace_t state_trace)=0; @@ -85,7 +85,8 @@ public: * @param speedScale The speed scale of this Cpu in [0;1] (available amount) * @param stateInitial whether it is created running or crashed */ - Cpu(simgrid::surf::Model *model, simgrid::Host *host, lmm_constraint_t constraint, + Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, + lmm_constraint_t constraint, xbt_dynar_t speedPeakList, int pstate, int core, double speedPeak, double speedScale, int initiallyOn); @@ -100,7 +101,7 @@ public: * @param speedScale The speed scale of this Cpu in [0;1] (available amount) * @param stateInitial whether it is created running or crashed */ - Cpu(simgrid::surf::Model *model, simgrid::Host *host, + Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate, int core, double speedPeak, double speedScale, int initiallyOn); @@ -147,13 +148,13 @@ public: virtual int getPState(); void addTraces(void); - simgrid::Host* getHost() { return m_host; } + simgrid::s4u::Host* getHost() { return m_host; } public: int m_core = 1; /* Amount of cores */ double m_speedPeak; /*< CPU speed peak, ie max value */ double m_speedScale; /*< Percentage of CPU available according to the trace, in [O,1] */ - simgrid::Host* m_host; + simgrid::s4u::Host* m_host; xbt_dynar_t p_speedPeakList = NULL; /*< List of supported CPU capacities (pstate related) */ int m_pstate = 0; /*< Current pstate (index in the speedPeakList)*/ diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index f3feb36580..306312d1b2 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -434,7 +434,7 @@ CpuTiModel::~CpuTiModel() xbt_heap_free(p_tiActionHeap); } -Cpu *CpuTiModel::createCpu(simgrid::Host *host, +Cpu *CpuTiModel::createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeak, int pstate, double speedScale, @@ -547,7 +547,7 @@ void CpuTiModel::addTraces() /************ * Resource * ************/ -CpuTi::CpuTi(CpuTiModel *model, simgrid::Host *host, xbt_dynar_t speedPeak, +CpuTi::CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, int initiallyOn, tmgr_trace_t stateTrace) : Cpu(model, host, NULL, pstate, core, 0, speedScale, initiallyOn) diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index d8df612164..be3b5617b3 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -113,7 +113,7 @@ typedef boost::intrusive::list< ************/ class CpuTi : public Cpu { public: - CpuTi(CpuTiModel *model, simgrid::Host *host, xbt_dynar_t speedPeak, + CpuTi(CpuTiModel *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, int initiallyOn, tmgr_trace_t stateTrace) ; ~CpuTi(); @@ -152,7 +152,7 @@ class CpuTiModel : public CpuModel { public: CpuTiModel(); ~CpuTiModel(); - Cpu *createCpu(simgrid::Host *host, xbt_dynar_t speedPeak, + Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, int initiallyOn, diff --git a/src/surf/host_interface.cpp b/src/surf/host_interface.cpp index 1696064e88..dcacf5221a 100644 --- a/src/surf/host_interface.cpp +++ b/src/surf/host_interface.cpp @@ -6,7 +6,7 @@ #include "host_interface.hpp" -#include +#include #include "src/simix/smx_private.h" #include "cpu_cas01.hpp" @@ -31,7 +31,7 @@ void host_add_traces(){ namespace simgrid { namespace surf { -simgrid::xbt::Extension Host::EXTENSION_ID; +simgrid::xbt::Extension Host::EXTENSION_ID; /********* * Model * @@ -87,7 +87,7 @@ void HostModel::adjustWeightOfDummyCpuActions() void Host::classInit() { if (!EXTENSION_ID.valid()) { - EXTENSION_ID = simgrid::Host::extension_create(); + EXTENSION_ID = simgrid::s4u::Host::extension_create(); } } @@ -114,10 +114,10 @@ Host::~Host() { } -void Host::attach(simgrid::Host* host) +void Host::attach(simgrid::s4u::Host* host) { if (p_host != nullptr) - xbt_die("Already attached to host %s", host->getName().c_str()); + xbt_die("Already attached to host %s", host->name().c_str()); host->extension_set(this); p_host = host; } @@ -131,13 +131,13 @@ bool Host::isOff() { void Host::turnOn(){ if (isOff()) { p_cpu->turnOn(); - simgrid::Host::onStateChange(*this->p_host); + simgrid::s4u::Host::onStateChange(*this->p_host); } } void Host::turnOff(){ if (isOn()) { p_cpu->turnOff(); - simgrid::Host::onStateChange(*this->p_host); + simgrid::s4u::Host::onStateChange(*this->p_host); } } diff --git a/src/surf/host_interface.hpp b/src/surf/host_interface.hpp index 0676724ed7..ef36245de9 100644 --- a/src/surf/host_interface.hpp +++ b/src/surf/host_interface.hpp @@ -77,7 +77,7 @@ class Host : public simgrid::surf::Resource, public simgrid::surf::PropertyHolder { public: - static simgrid::xbt::Extension EXTENSION_ID; + static simgrid::xbt::Extension EXTENSION_ID; public: static void classInit(); // must be called before the first use of that class @@ -115,7 +115,7 @@ public: { return static_cast(Resource::getModel()); } - void attach(simgrid::Host* host); + void attach(simgrid::s4u::Host* host); bool isOn() override; bool isOff() override; @@ -236,7 +236,7 @@ public: public: xbt_dynar_t p_storage; Cpu *p_cpu; - simgrid::Host* p_host = nullptr; + simgrid::s4u::Host* p_host = nullptr; /** @brief Get the list of virtual machines on the current Host */ xbt_dynar_t getVms(); @@ -247,7 +247,7 @@ public: void getParams(vm_params_t params); /** @brief Sets the params of that VM/PM */ void setParams(vm_params_t params); - simgrid::Host* getHost() { return p_host; } + simgrid::s4u::Host* getHost() { return p_host; } private: s_vm_params_t p_params; }; diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index 72a1aef240..255bfb310a 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -297,7 +297,7 @@ Action *NetworkL07Model::communicate(NetCard *src, NetCard *dst, return res; } -Cpu *CpuL07Model::createCpu(simgrid::Host *host, xbt_dynar_t powerPeakList, +Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host, xbt_dynar_t powerPeakList, int pstate, double power_scale, tmgr_trace_t power_trace, int core, int initiallyOn, @@ -395,7 +395,7 @@ void HostL07Model::addTraces() * Resource * ************/ -CpuL07::CpuL07(CpuL07Model *model, simgrid::Host *host, +CpuL07::CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, int initiallyOn, tmgr_trace_t state_trace) diff --git a/src/surf/host_ptask_L07.hpp b/src/surf/host_ptask_L07.hpp index 1de3995d89..0e69ef8a63 100644 --- a/src/surf/host_ptask_L07.hpp +++ b/src/surf/host_ptask_L07.hpp @@ -57,7 +57,7 @@ public: CpuL07Model(HostL07Model *hmodel,lmm_system_t sys); ~CpuL07Model(); - Cpu *createCpu(simgrid::Host *host, xbt_dynar_t speedPeakList, + Cpu *createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, int initiallyOn, @@ -97,7 +97,7 @@ class CpuL07 : public Cpu { tmgr_trace_event_t p_stateEvent; tmgr_trace_event_t p_speedEvent; public: - CpuL07(CpuL07Model *model, simgrid::Host *host, xbt_dynar_t speedPeakList, int pstate, + CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate, double power_scale, tmgr_trace_t power_trace, int core, int initiallyOn, tmgr_trace_t state_trace); ~CpuL07(); diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index dfbba3b74f..e7a4195f2f 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -27,7 +27,7 @@ void surf_network_model_init_Constant() routing_model_create(NULL); - simgrid::Host::onCreation.connect([](simgrid::Host&) { + simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host&) { host_number_int++; }); sg_platf_link_add_cb(netcste_parse_nolink); diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index cbeb8ae054..8771a39a89 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -14,7 +14,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network); -static void IB_create_host_callback(simgrid::Host& host){ +static void IB_create_host_callback(simgrid::s4u::Host& host){ using namespace simgrid::surf; static int id=0; @@ -26,7 +26,7 @@ static void IB_create_host_callback(simgrid::Host& host){ id++; xbt_dict_set(((NetworkIBModel*)surf_network_model)->active_nodes, - host.getName().c_str(), act, NULL); + host.name().c_str(), act, NULL); } @@ -99,7 +99,7 @@ void surf_network_model_init_IB(void) xbt_dynar_push(all_existing_models, &surf_network_model); networkActionStateChangedCallbacks.connect(IB_action_state_changed_callback); networkCommunicateCallbacks.connect(IB_action_init_callback); - simgrid::Host::onCreation.connect(IB_create_host_callback); + simgrid::s4u::Host::onCreation.connect(IB_create_host_callback); xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775); } diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index f637494675..28d43b1257 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -110,7 +110,7 @@ static void parse_ns3_add_cluster(sg_platf_cluster_cbarg_t cluster) start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *)); xbt_dynar_push_as(tab_elements_num, int, start); router_id = bprintf("ns3_%s%d%s", cluster_prefix, start, cluster_suffix); - simgrid::Host::by_name_or_create(router_id) + simgrid::s4u::Host::by_name_or_create(router_id) ->extension_set(NS3_EXTENSION_ID, ns3_add_host_cluster(router_id)); XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id); free(router_id); @@ -122,7 +122,7 @@ static void parse_ns3_add_cluster(sg_platf_cluster_cbarg_t cluster) for (i = start; i <= end; i++){ xbt_dynar_push_as(tab_elements_num, int, i); router_id = bprintf("ns3_%s%d%s", cluster_prefix, i, cluster_suffix); - simgrid::Host::by_name_or_create(router_id) + simgrid::s4u::Host::by_name_or_create(router_id) ->extension_set(NS3_EXTENSION_ID, ns3_add_host_cluster(router_id)); XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id); free(router_id); @@ -273,7 +273,7 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel() { routing_model_create(NULL); define_callbacks_ns3(); - NS3_EXTENSION_ID = simgrid::Host::extension_create(free_ns3_host); + NS3_EXTENSION_ID = simgrid::s4u::Host::extension_create(free_ns3_host); NS3_ASR_LEVEL = xbt_lib_add_level(as_router_lib, free_ns3_host); } diff --git a/src/surf/ns3/ns3_interface.h b/src/surf/ns3/ns3_interface.h index 480947eb76..d5c3a87a8e 100644 --- a/src/surf/ns3/ns3_interface.h +++ b/src/surf/ns3/ns3_interface.h @@ -13,7 +13,7 @@ #include "xbt/sysdep.h" #include -#include +#include #include typedef enum { diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index 058ae234f9..079b244636 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -60,7 +60,7 @@ using simgrid::energy::HostEnergy; namespace simgrid { namespace energy { -simgrid::xbt::Extension HostEnergy::EXTENSION_ID; +simgrid::xbt::Extension HostEnergy::EXTENSION_ID; /* Computes the consumption so far. Called lazily on need. */ void HostEnergy::update() @@ -97,7 +97,7 @@ void HostEnergy::update() surf_host->getName(), start_time, finish_time, surf_host->p_cpu->m_speedPeak, previous_energy, energy_this_step); } -HostEnergy::HostEnergy(simgrid::Host *ptr) : +HostEnergy::HostEnergy(simgrid::s4u::Host *ptr) : host(ptr), last_updated(surf_get_clock()) { initWattsRangeList(); @@ -119,14 +119,14 @@ HostEnergy::~HostEnergy() double HostEnergy::getWattMinAt(int pstate) { xbt_assert(!power_range_watts_list.empty(), - "No power range properties specified for host %s", host->getName().c_str()); + "No power range properties specified for host %s", host->name().c_str()); return power_range_watts_list[pstate].first; } double HostEnergy::getWattMaxAt(int pstate) { xbt_assert(!power_range_watts_list.empty(), - "No power range properties specified for host %s", host->getName().c_str()); + "No power range properties specified for host %s", host->name().c_str()); return power_range_watts_list[pstate].second; } @@ -134,7 +134,7 @@ double HostEnergy::getWattMaxAt(int pstate) double HostEnergy::getCurrentWattsValue(double cpu_load) { xbt_assert(!power_range_watts_list.empty(), - "No power range properties specified for host %s", host->getName().c_str()); + "No power range properties specified for host %s", host->name().c_str()); /* min_power corresponds to the idle power (cpu load = 0) */ /* max_power is the power consumed at 100% cpu load */ @@ -177,7 +177,7 @@ void HostEnergy::initWattsRangeList() xbt_assert(xbt_dynar_length(current_power_values) > 1, "Power properties incorrectly defined - " "could not retrieve min and max power values for host %s", - host->getName().c_str()); + host->name().c_str()); /* min_power corresponds to the idle power (cpu load = 0) */ /* max_power is the power consumed at 100% cpu load */ @@ -193,7 +193,7 @@ void HostEnergy::initWattsRangeList() } /* **************************** events callback *************************** */ -static void onCreation(simgrid::Host& host) { +static void onCreation(simgrid::s4u::Host& host) { simgrid::surf::Host* surf_host = host.extension(); if (dynamic_cast(surf_host)) // Ignore virtual machines return; @@ -214,7 +214,7 @@ static void onActionStateChange(simgrid::surf::CpuAction *action, host_energy->update(); } -static void onHostStateChange(simgrid::Host &host) { +static void onHostStateChange(simgrid::s4u::Host &host) { simgrid::surf::Host* surf_host = host.extension(); if (dynamic_cast(surf_host)) // Ignore virtual machines return; @@ -225,7 +225,7 @@ static void onHostStateChange(simgrid::Host &host) { host_energy->update(); } -static void onHostDestruction(simgrid::Host& host) { +static void onHostDestruction(simgrid::s4u::Host& host) { // Ignore virtual machines simgrid::surf::Host* surf_host = host.extension(); if (dynamic_cast(surf_host)) @@ -233,7 +233,7 @@ static void onHostDestruction(simgrid::Host& host) { HostEnergy *host_energy = host.extension(); host_energy->update(); XBT_INFO("Total energy of host %s: %f Joules", - host.getName().c_str(), host_energy->getConsumedEnergy()); + host.name().c_str(), host_energy->getConsumedEnergy()); } /* **************************** Public interface *************************** */ @@ -246,11 +246,11 @@ void sg_energy_plugin_init(void) if (HostEnergy::EXTENSION_ID.valid()) return; - HostEnergy::EXTENSION_ID = simgrid::Host::extension_create(); + HostEnergy::EXTENSION_ID = simgrid::s4u::Host::extension_create(); - simgrid::Host::onCreation.connect(&onCreation); - simgrid::Host::onStateChange.connect(&onHostStateChange); - simgrid::Host::onDestruction.connect(&onHostDestruction); + simgrid::s4u::Host::onCreation.connect(&onCreation); + simgrid::s4u::Host::onStateChange.connect(&onHostStateChange); + simgrid::s4u::Host::onDestruction.connect(&onHostDestruction); simgrid::surf::CpuAction::onStateChange.connect(&onActionStateChange); } diff --git a/src/surf/plugins/energy.hpp b/src/surf/plugins/energy.hpp index 1ac1444f56..e2610ac157 100644 --- a/src/surf/plugins/energy.hpp +++ b/src/surf/plugins/energy.hpp @@ -21,10 +21,10 @@ class XBT_PRIVATE HostEnergy; class HostEnergy { public: - static simgrid::xbt::Extension EXTENSION_ID; + static simgrid::xbt::Extension EXTENSION_ID; typedef std::pair power_range; - HostEnergy(simgrid::Host *ptr); + HostEnergy(simgrid::s4u::Host *ptr); ~HostEnergy(); double getCurrentWattsValue(double cpu_load); @@ -35,7 +35,7 @@ public: private: void initWattsRangeList(); - simgrid::Host *host = nullptr; + simgrid::s4u::Host *host = nullptr; std::vector power_range_watts_list; /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */ public: double watts_off = 0.0; /*< Consumption when the machine is turned off (shutdown) */ diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 1fb5d32668..09f9f453c3 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -60,7 +60,7 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host) if (current_routing) net = routing_add_host(current_routing, host); - sg_host_t h = simgrid::Host::by_name_or_create(host->id); + sg_host_t h = simgrid::s4u::Host::by_name_or_create(host->id); simgrid::surf::Cpu *cpu = surf_cpu_model_pm->createCpu( h, host->speed_peak, @@ -71,7 +71,7 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host) host->initiallyOn, host->state_trace); surf_host_model->createHost(host->id, net, cpu, host->properties)->attach(h); - simgrid::Host::onCreation(*h); + simgrid::s4u::Host::onCreation(*h); if (TRACE_is_enabled() && TRACE_needs_platform()) sg_instr_new_host(host); diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 47970ddc4c..8b71301867 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -284,7 +284,7 @@ xbt_dynar_t surf_host_get_vms(sg_host_t host){ unsigned int cpt; simgrid::surf::VirtualMachine *vm; xbt_dynar_foreach(vms, cpt, vm) { - // TODO, use a backlink from simgrid::surf::Host to simgrid::Host + // TODO, use a backlink from simgrid::surf::Host to simgrid::s4u::Host sg_host_t vm_ = (sg_host_t) xbt_dict_get_elm_or_null(host_list, vm->getName()); xbt_dynar_push(vms_, &vm_); } diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 5245a67d72..6497396107 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -304,8 +304,8 @@ void surf_init(int *argc, char **argv) { XBT_DEBUG("Create all Libs"); host_list = xbt_dict_new_homogeneous([](void*p) { - simgrid::Host* host = static_cast(p); - simgrid::Host::onDestruction(*host); + simgrid::s4u::Host* host = static_cast(p); + simgrid::s4u::Host::onDestruction(*host); delete host; }); as_router_lib = xbt_lib_new(); diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index af1ceee345..71d2e463ca 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -1326,7 +1326,7 @@ xbt_dynar_t surf_AS_get_hosts(simgrid::surf::As *as) for (int index = 0; index < count; index++) { sg_netcard_t relm = xbt_dynar_get_as(elms, index, simgrid::surf::NetCard*); - sg_host_t delm = simgrid::Host::by_name_or_null(relm->getName()); + sg_host_t delm = simgrid::s4u::Host::by_name_or_null(relm->getName()); if (delm!=NULL) { xbt_dynar_push(res, &delm); } diff --git a/src/surf/surf_routing_vivaldi.cpp b/src/surf/surf_routing_vivaldi.cpp index 1601e9e8f9..f5ae8aaba9 100644 --- a/src/surf/surf_routing_vivaldi.cpp +++ b/src/surf/surf_routing_vivaldi.cpp @@ -57,9 +57,9 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb *lat += static_cast(info.link_up)->getLatency(); } } - src_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(tmp_src_name)->extension(COORD_HOST_LEVEL); + src_ctn = (xbt_dynar_t) simgrid::s4u::Host::by_name_or_create(tmp_src_name)->extension(COORD_HOST_LEVEL); if (src_ctn == nullptr) - src_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(src->getName())->extension(COORD_HOST_LEVEL); + src_ctn = (xbt_dynar_t) simgrid::s4u::Host::by_name_or_create(src->getName())->extension(COORD_HOST_LEVEL); } else if(src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_AS){ tmp_src_name = ROUTER_PEER(src->getName()); @@ -80,10 +80,10 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb *lat += static_cast(info.link_down)->getLatency(); } } - dst_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(tmp_dst_name) + dst_ctn = (xbt_dynar_t) simgrid::s4u::Host::by_name_or_create(tmp_dst_name) ->extension(COORD_HOST_LEVEL); if (dst_ctn == nullptr) - dst_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(dst->getName()) + dst_ctn = (xbt_dynar_t) simgrid::s4u::Host::by_name_or_create(dst->getName()) ->extension(COORD_HOST_LEVEL); } else if(dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || dst->getRcType() == SURF_NETWORK_ELEMENT_AS){ diff --git a/src/surf/virtual_machine.cpp b/src/surf/virtual_machine.cpp index 4c25e536a3..96b5ecb9e6 100644 --- a/src/surf/virtual_machine.cpp +++ b/src/surf/virtual_machine.cpp @@ -33,12 +33,12 @@ VMModel::vm_list_t VMModel::ws_vms; * Resource * ************/ -VirtualMachine::VirtualMachine(HostModel *model, const char *name, xbt_dict_t props, simgrid::Host *hostPM) +VirtualMachine::VirtualMachine(HostModel *model, const char *name, xbt_dict_t props, simgrid::s4u::Host *hostPM) : Host(model, name, props, NULL, NULL, NULL) , p_hostPM(hostPM) { VMModel::ws_vms.push_back(*this); - simgrid::Host::by_name_or_create(name)->extension_set(this); + simgrid::s4u::Host::by_name_or_create(name)->extension_set(this); } /* diff --git a/src/surf/virtual_machine.hpp b/src/surf/virtual_machine.hpp index 99f1e39675..30e4938bbb 100644 --- a/src/surf/virtual_machine.hpp +++ b/src/surf/virtual_machine.hpp @@ -63,7 +63,7 @@ public: * @param cpu The Cpu associated to this VM */ VirtualMachine(simgrid::surf::HostModel *model, const char *name, xbt_dict_t props, - simgrid::Host *host); + simgrid::s4u::Host *host); /** @brief Destructor */ ~VirtualMachine(); @@ -91,7 +91,7 @@ public: /* The vm object of the lower layer */ CpuAction *p_action; - simgrid::Host *p_hostPM; + simgrid::s4u::Host *p_hostPM; void turnOn() override; void turnOff() override; diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index b982795595..2c25d80a71 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -93,7 +93,7 @@ double VMHL13Model::shareResources(double now) double solved_value = get_solved_value(ws_vm->p_action); XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, - ws_vm->getName(), ws_vm->p_hostPM->getName().c_str()); + ws_vm->getName(), ws_vm->p_hostPM->name().c_str()); // TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution. // cpu_cas01->constraint->bound = solved_value; @@ -199,7 +199,8 @@ VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t hos // vm_ws->cpu_action = surf_cpu_model_pm->extension.cpu.execute(host_PM, GUESTOS_NOISE); p_action = sub_cpu->execute(0); - XBT_INFO("Create VM(%s)@PM(%s) with %ld mounted disks", name, p_hostPM->getName().c_str(), xbt_dynar_length(p_storage)); + XBT_INFO("Create VM(%s)@PM(%s) with %ld mounted disks", + name, p_hostPM->name().c_str(), xbt_dynar_length(p_storage)); } void VMHL13::suspend() @@ -239,7 +240,7 @@ void VMHL13::migrate(sg_host_t host_dest) { Host *surfHost_dst = host_dest->extension(); const char *vm_name = getName(); - const char *pm_name_src = p_hostPM->getName().c_str(); + const char *pm_name_src = p_hostPM->name().c_str(); const char *pm_name_dst = surfHost_dst->getName(); /* update net_elm with that of the destination physical host */ diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 6035d65915..6f1feb437f 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -684,7 +684,6 @@ set(headers_to_install include/simgrid/s4u/storage.hpp include/simgrid/s4u.h include/simgrid/plugins/energy.h - include/simgrid/Host.hpp include/smpi/mpi.h include/smpi/smpi.h include/smpi/smpi_cocci.h -- 2.20.1