From: SUTER Frederic Date: Mon, 8 Nov 2021 08:47:34 +0000 (+0100) Subject: say bye to simgrid::surf namespace X-Git-Tag: v3.30~276 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d9275f747ba3c37e33a3f301dc70dbbb7e9bae38 say bye to simgrid::surf namespace --- diff --git a/doc/doxygen/inside_extending.doc b/doc/doxygen/inside_extending.doc index 8dc029baa2..7668d2658e 100644 --- a/doc/doxygen/inside_extending.doc +++ b/doc/doxygen/inside_extending.doc @@ -44,7 +44,7 @@ void surf_cpu_model_init_plop() surf_cpu_model_pm = new CpuPlopModel(); - simgrid::surf::on_postparse.connect(cpu_add_traces); + simgrid::kernel::resource::on_postparse.connect(cpu_add_traces); xbt_dynar_push(model_list, &surf_cpu_model_pm); } @@ -191,8 +191,9 @@ simulation. This call is particularly useful for implementing mutable calls: ~~~ void Host::setProperty(const char*key, const char *value){ simgrid::simix::kernelImmediate([&] { - simgrid::surf::HostImpl* surf_host = this->extension(); - surf_host->setProperty(key,value); + simgrid::kernel::resource::HostImpl* host = + this->extension(); + host->setProperty(key,value); }); } ~~~ diff --git a/doc/doxygen/uhood_switch.doc b/doc/doxygen/uhood_switch.doc index 7cd30d079f..40c7b46f43 100644 --- a/doc/doxygen/uhood_switch.doc +++ b/doc/doxygen/uhood_switch.doc @@ -439,9 +439,9 @@ Example of usage: @code{cpp} xbt_dict_t Host::properties() { return simgrid::simix::kernelImmediate([&] { - simgrid::surf::HostImpl* surf_host = - this->extension(); - return surf_host->getProperties(); + simgrid::kernel::resource::HostImpl* host = + this->extension(); + return host->getProperties(); }); } @endcode diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 64f9183454..f5f5c6a664 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -168,6 +168,8 @@ class CpuImpl; class Model; class Resource; class CpuModel; +class HostImpl; +class HostModel; class NetworkModel; class NetworkModelIntf; class LinkImpl; @@ -192,10 +194,6 @@ class FutureEvtSet; class Profile; } // namespace profile } // namespace kernel -namespace surf { - class HostImpl; - class HostModel; -} namespace mc { class CommunicationDeterminismChecker; } diff --git a/include/simgrid/kernel/routing/NetZoneImpl.hpp b/include/simgrid/kernel/routing/NetZoneImpl.hpp index 6acc05b29d..4ca03861e5 100644 --- a/include/simgrid/kernel/routing/NetZoneImpl.hpp +++ b/include/simgrid/kernel/routing/NetZoneImpl.hpp @@ -129,7 +129,7 @@ public: /** @brief Retrieves the disk model associated to this NetZone */ const std::shared_ptr& get_disk_model() const { return disk_model_; } /** @brief Retrieves the host model associated to this NetZone */ - const std::shared_ptr& get_host_model() const { return host_model_; } + const std::shared_ptr& get_host_model() const { return host_model_; } const s4u::NetZone* get_iface() const { return &piface_; } s4u::NetZone* get_iface() { return &piface_; } @@ -181,7 +181,7 @@ public: void set_cpu_vm_model(std::shared_ptr cpu_model); void set_cpu_pm_model(std::shared_ptr cpu_model); void set_disk_model(std::shared_ptr disk_model); - void set_host_model(std::shared_ptr host_model); + void set_host_model(std::shared_ptr host_model); /** @brief get the route between two nodes in the full platform * @@ -213,7 +213,7 @@ private: std::shared_ptr cpu_model_vm_; std::shared_ptr cpu_model_pm_; std::shared_ptr disk_model_; - std::shared_ptr host_model_; + std::shared_ptr host_model_; /** @brief Perform sealing procedure for derived classes, if necessary */ virtual void do_seal() { /* obviously nothing to do by default */ diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index 7856a1f48e..2a88c385a9 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -84,12 +84,12 @@ public: protected: #ifndef DOXYGEN - friend surf::HostImpl; friend Host; friend Link; friend Disk; friend kernel::routing::NetPoint; friend kernel::routing::NetZoneImpl; + friend kernel::resource::HostImpl; friend kernel::resource::LinkImpl; void host_register(const std::string& name, Host* host); void host_unregister(const std::string& name); diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index 7be79dc3d5..e745232277 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -40,16 +40,16 @@ class XBT_PUBLIC Host : public xbt::Extendable { friend kernel::resource::VMModel; // Use the pimpl_cpu to compute the VM sharing friend kernel::resource::VirtualMachineImpl; // creates the the pimpl_cpu friend kernel::routing::NetZoneImpl; - friend surf::HostImpl; // call destructor from private implementation + friend kernel::resource::HostImpl; // call destructor from private implementation // The private implementation, that never changes - surf::HostImpl* const pimpl_; + kernel::resource::HostImpl* const pimpl_; kernel::resource::CpuImpl* pimpl_cpu_ = nullptr; kernel::routing::NetPoint* pimpl_netpoint_ = nullptr; public: - explicit Host(surf::HostImpl* pimpl) : pimpl_(pimpl) {} + explicit Host(kernel::resource::HostImpl* pimpl) : pimpl_(pimpl) {} protected: virtual ~Host(); // Call destroy() instead of manually deleting it. @@ -243,7 +243,7 @@ public: /** Block the calling actor on an execution located on the called host (with explicit priority) */ void execute(double flops, double priority) const; - surf::HostImpl* get_impl() const { return pimpl_; } + kernel::resource::HostImpl* get_impl() const { return pimpl_; } }; } // namespace s4u } // namespace simgrid diff --git a/src/kernel/actor/ActorImpl.hpp b/src/kernel/actor/ActorImpl.hpp index e9c6e4bbe8..b5ae3c0556 100644 --- a/src/kernel/actor/ActorImpl.hpp +++ b/src/kernel/actor/ActorImpl.hpp @@ -41,7 +41,7 @@ public: static ActorImpl* self(); double get_kill_time() const; void set_kill_time(double kill_time); - boost::intrusive::list_member_hook<> host_actor_list_hook; /* simgrid::surf::HostImpl::actor_list_ */ + boost::intrusive::list_member_hook<> host_actor_list_hook; /* resource::HostImpl::actor_list_ */ boost::intrusive::list_member_hook<> kernel_destroy_list_hook; /* EngineImpl actors_to_destroy */ boost::intrusive::list_member_hook<> smx_synchro_hook; /* {mutex,cond,sem}->sleeping */ diff --git a/src/kernel/resource/VirtualMachineImpl.hpp b/src/kernel/resource/VirtualMachineImpl.hpp index 6ab458f0d7..3e2fc06a2f 100644 --- a/src/kernel/resource/VirtualMachineImpl.hpp +++ b/src/kernel/resource/VirtualMachineImpl.hpp @@ -21,7 +21,7 @@ namespace resource { * Resource * ************/ -class XBT_PUBLIC VirtualMachineImpl : public surf::HostImpl, public xbt::Extendable { +class XBT_PUBLIC VirtualMachineImpl : public HostImpl, public xbt::Extendable { #ifndef DOXYGEN friend s4u::VirtualMachine; #endif @@ -84,7 +84,7 @@ private: * @brief SURF VM model interface class * @details A model is an object which handle the interactions between its Resources and its Actions */ -class XBT_PRIVATE VMModel : public surf::HostModel { +class XBT_PRIVATE VMModel : public HostModel { public: explicit VMModel(const std::string& name); diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index ccaeb57e2c..7f8f8eec84 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -151,7 +151,7 @@ s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vectorget_iface(); + auto* res = (new resource::HostImpl(name))->get_iface(); res->set_netpoint((new NetPoint(name, NetPoint::Type::Host))->set_englobing_zone(this)); cpu_model_pm_->create_cpu(res, speed_per_pstate); @@ -581,7 +581,7 @@ void NetZoneImpl::set_disk_model(std::shared_ptr disk_model disk_model_ = std::move(disk_model); } -void NetZoneImpl::set_host_model(std::shared_ptr host_model) +void NetZoneImpl::set_host_model(std::shared_ptr host_model) { xbt_assert(not sealed_, "Impossible to set host model to an already sealed NetZone(%s)", this->get_cname()); host_model_ = std::move(host_model); diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index cb429d08a8..f105aa5b1c 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -19,7 +19,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_host, ker_resource, "Host resources agregate *************/ namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { /********* * Model * @@ -47,7 +48,7 @@ HostImpl::~HostImpl() for (auto const& actor : actor_list_) msg += "\n\t" + std::string(actor.get_name()); - kernel::EngineImpl::get_instance()->display_all_actor_status(); + EngineImpl::get_instance()->display_all_actor_status(); xbt_die("%s", msg.c_str()); } for (auto const& arg : actors_at_boot_) @@ -77,8 +78,7 @@ void HostImpl::turn_on() const { for (auto const& arg : actors_at_boot_) { XBT_DEBUG("Booting Actor %s(%s) right now", arg->name.c_str(), arg->host->get_cname()); - simgrid::kernel::actor::ActorImplPtr actor = - simgrid::kernel::actor::ActorImpl::create(arg->name, arg->code, nullptr, arg->host, nullptr); + actor::ActorImplPtr actor = actor::ActorImpl::create(arg->name, arg->code, nullptr, arg->host, nullptr); actor->set_properties(arg->properties); if (arg->on_exit) *actor->on_exit = *arg->on_exit; @@ -92,7 +92,7 @@ void HostImpl::turn_on() const } /** Kill all actors hosted here */ -void HostImpl::turn_off(const kernel::actor::ActorImpl* issuer) +void HostImpl::turn_off(const actor::ActorImpl* issuer) { for (auto& actor : actor_list_) { XBT_DEBUG("Killing Actor %s@%s on behalf of %s which turned off that host.", actor.get_cname(), @@ -101,7 +101,7 @@ void HostImpl::turn_off(const kernel::actor::ActorImpl* issuer) } // When a host is turned off, we want to keep only the actors that should restart for when it will boot again. // Then get rid of the others. - auto elm = remove_if(begin(actors_at_boot_), end(actors_at_boot_), [](const kernel::actor::ProcessArg* arg) { + auto elm = remove_if(begin(actors_at_boot_), end(actors_at_boot_), [](const actor::ProcessArg* arg) { if (arg->auto_restart) return false; delete arg; @@ -160,5 +160,6 @@ void HostImpl::seal() for (auto const& disk : disks_) disk.second->seal(); } -} // namespace surf +} // namespace resource +} // namespace kernel } // namespace simgrid diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 2b1cfeb673..0dcc24d81f 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -15,8 +15,8 @@ #include namespace simgrid { -namespace surf { - +namespace kernel { +namespace resource { /********* * Model * *********/ @@ -25,12 +25,11 @@ namespace surf { * @brief SURF Host model interface class * @details A model is an object which handle the interactions between its Resources and its Actions */ -class XBT_PRIVATE HostModel : public kernel::resource::Model { +class XBT_PRIVATE HostModel : public Model { public: using Model::Model; - virtual kernel::resource::Action* execute_parallel(const std::vector& host_list, - const double* flops_amount, const double* bytes_amount, - double rate) = 0; + virtual Action* execute_parallel(const std::vector& host_list, const double* flops_amount, + const double* bytes_amount, double rate) = 0; }; /************ @@ -41,15 +40,15 @@ public: * @details A host represents a machine with an aggregation of a Cpu, a RoutingEdge and Disk(s) */ class XBT_PRIVATE HostImpl : public xbt::PropertyHolder { - using ActorList = boost::intrusive::list< - kernel::actor::ActorImpl, - boost::intrusive::member_hook, - &kernel::actor::ActorImpl::host_actor_list_hook>>; + using ActorList = + boost::intrusive::list, + &actor::ActorImpl::host_actor_list_hook>>; ActorList actor_list_; - std::vector actors_at_boot_; + std::vector actors_at_boot_; s4u::Host piface_; - std::map> disks_; + std::map> disks_; xbt::string name_{"noname"}; bool sealed_ = false; @@ -58,7 +57,7 @@ protected: HostImpl(const std::string& name, s4u::Host* piface); public: - friend kernel::resource::VirtualMachineImpl; + friend VirtualMachineImpl; explicit HostImpl(const std::string& name); void destroy(); // Must be called instead of the destructor @@ -77,12 +76,12 @@ public: const char* get_cname() const { return name_.c_str(); } void turn_on() const; - void turn_off(const kernel::actor::ActorImpl* issuer); + void turn_off(const actor::ActorImpl* issuer); std::vector get_all_actors(); size_t get_actor_count() const; - void add_actor(kernel::actor::ActorImpl* actor) { actor_list_.push_back(*actor); } - void remove_actor(kernel::actor::ActorImpl* actor) { xbt::intrusive_erase(actor_list_, *actor); } - void add_actor_at_boot(kernel::actor::ProcessArg* arg) { actors_at_boot_.emplace_back(arg); } + void add_actor(actor::ActorImpl* actor) { actor_list_.push_back(*actor); } + void remove_actor(actor::ActorImpl* actor) { xbt::intrusive_erase(actor_list_, *actor); } + void add_actor_at_boot(actor::ProcessArg* arg) { actors_at_boot_.emplace_back(arg); } void seal(); @@ -92,7 +91,8 @@ public: function(actor); } }; -} // namespace surf +} // namespace resource +} // namespace kernel } // namespace simgrid -#endif /* SURF_HOST_INTERFACE_HPP */ +#endif /* HOST_INTERFACE_HPP */ diff --git a/src/surf/LinkImpl.hpp b/src/surf/LinkImpl.hpp index 5148d54e49..e49c884d50 100644 --- a/src/surf/LinkImpl.hpp +++ b/src/surf/LinkImpl.hpp @@ -20,7 +20,7 @@ namespace resource { ************/ /** @ingroup SURF_network_interface * @brief SURF network link interface class - * @details A Link represents the link between two [hosts](@ref simgrid::surf::HostImpl) + * @details A Link represents the link between two [hosts](@ref simgrid::kernel::resource::HostImpl) */ class LinkImpl : public LinkImplIntf { s4u::Link piface_; diff --git a/src/surf/LinkImplIntf.hpp b/src/surf/LinkImplIntf.hpp index 0f10e42a44..6845de041b 100644 --- a/src/surf/LinkImplIntf.hpp +++ b/src/surf/LinkImplIntf.hpp @@ -22,7 +22,7 @@ namespace resource { ************/ /** @ingroup SURF_interface * @brief SURF network link interface class - * @details A Link represents the link between two [hosts](@ref simgrid::surf::HostImpl) + * @details A Link represents the link between two [hosts](@ref HostImpl) */ class LinkImplIntf : public Resource_T, public xbt::PropertyHolder { public: diff --git a/src/surf/SplitDuplexLinkImpl.hpp b/src/surf/SplitDuplexLinkImpl.hpp index 4842f08ba8..231e130028 100644 --- a/src/surf/SplitDuplexLinkImpl.hpp +++ b/src/surf/SplitDuplexLinkImpl.hpp @@ -21,7 +21,7 @@ namespace resource { ************/ /** @ingroup SURF_network_interface * @brief SURF network link interface class - * @details A Link represents the link between two [hosts](@ref simgrid::surf::HostImpl) + * @details A Link represents the link between two [hosts](@ref HostImpl) */ class SplitDuplexLinkImpl : public LinkImplIntf { s4u::SplitDuplexLink piface_; diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index 21c9623761..3a7b01299a 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -16,7 +16,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_host); void surf_host_model_init_current_default() { simgrid::config::set_default("network/crosstraffic", true); - auto host_model = std::make_shared("Host_CLM03"); + auto host_model = std::make_shared("Host_CLM03"); auto* engine = simgrid::kernel::EngineImpl::get_instance(); engine->add_model(host_model); engine->get_netzone_root()->set_host_model(host_model); @@ -26,15 +26,17 @@ void surf_host_model_init_current_default() void surf_host_model_init_compound() { - auto host_model = std::make_shared("Host_CLM03"); + auto host_model = std::make_shared("Host_CLM03"); auto* engine = simgrid::kernel::EngineImpl::get_instance(); engine->add_model(host_model); engine->get_netzone_root()->set_host_model(host_model); } namespace simgrid { -namespace surf { -double HostCLM03Model::next_occurring_event(double now) +namespace kernel { +namespace resource { + +double HostCLM03Model::next_occurring_event(double /*now*/) { /* nothing specific to be done here * surf_solve already calls all the models next_occurring_event properly */ @@ -54,11 +56,10 @@ static inline double has_cost(const double* array, size_t pos) return -1.0; } -kernel::resource::Action* HostCLM03Model::execute_parallel(const std::vector& host_list, - const double* flops_amount, const double* bytes_amount, - double rate) +Action* HostCLM03Model::execute_parallel(const std::vector& host_list, const double* flops_amount, + const double* bytes_amount, double rate) { - kernel::resource::Action* action = nullptr; + Action* action = nullptr; auto net_model = host_list[0]->get_netpoint()->get_englobing_zone()->get_network_model(); if ((host_list.size() == 1) && (has_cost(bytes_amount, 0) <= 0) && (has_cost(flops_amount, 0) > 0)) { action = host_list[0]->get_cpu()->execution_start(flops_amount[0], rate); @@ -93,5 +94,6 @@ kernel::resource::Action* HostCLM03Model::execute_parallel(const std::vector& host_list, const double* flops_amount, - const double* bytes_amount, double rate) override; + Action* execute_parallel(const std::vector& host_list, const double* flops_amount, + const double* bytes_amount, double rate) override; }; -} -} +} // namespace resource +} // namespace kernel +} // namespace simgrid -#endif /* SURF_HOST_CLM03_HPP_ */ +#endif /* HOST_CLM03_HPP_ */ diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 0f775b6b22..039af7fbd5 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -99,7 +99,7 @@ public: **********/ /** @ingroup SURF_network_interface * @brief SURF network action interface class - * @details A NetworkAction represents a communication between two [hosts](@ref simgrid::surf::HostImpl) + * @details A NetworkAction represents a communication between two [hosts](@ref HostImpl) */ class NetworkAction : public Action { s4u::Host& src_; diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 351bca884a..bd0f778b49 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -23,22 +23,23 @@ void surf_host_model_init_ptask_L07() { XBT_CINFO(xbt_cfg, "Switching to the L07 model to handle parallel tasks."); - auto host_model = std::make_shared("Host_Ptask"); + auto host_model = std::make_shared("Host_Ptask"); auto* engine = simgrid::kernel::EngineImpl::get_instance(); engine->add_model(host_model); engine->get_netzone_root()->set_host_model(host_model); } namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { HostL07Model::HostL07Model(const std::string& name) : HostModel(name) { - auto* maxmin_system = new simgrid::kernel::lmm::FairBottleneck(true /* selective update */); + auto* maxmin_system = new lmm::FairBottleneck(true /* selective update */); set_maxmin_system(maxmin_system); auto net_model = std::make_shared("Network_Ptask", this, maxmin_system); - auto engine = simgrid::kernel::EngineImpl::get_instance(); + auto engine = EngineImpl::get_instance(); engine->add_model(net_model); engine->get_netzone_root()->set_network_model(net_model); @@ -47,7 +48,7 @@ HostL07Model::HostL07Model(const std::string& name) : HostModel(name) engine->get_netzone_root()->set_cpu_pm_model(cpu_model); } -CpuL07Model::CpuL07Model(const std::string& name, HostL07Model* hmodel, kernel::lmm::System* sys) +CpuL07Model::CpuL07Model(const std::string& name, HostL07Model* hmodel, lmm::System* sys) : CpuModel(name), hostModel_(hmodel) { set_maxmin_system(sys); @@ -58,7 +59,7 @@ CpuL07Model::~CpuL07Model() set_maxmin_system(nullptr); } -NetworkL07Model::NetworkL07Model(const std::string& name, HostL07Model* hmodel, kernel::lmm::System* sys) +NetworkL07Model::NetworkL07Model(const std::string& name, HostL07Model* hmodel, lmm::System* sys) : NetworkModel(name), hostModel_(hmodel) { set_maxmin_system(sys); @@ -76,7 +77,7 @@ NetworkL07Model::~NetworkL07Model() double HostL07Model::next_occurring_event(double now) { double min = HostModel::next_occurring_event_full(now); - for (kernel::resource::Action const& action : *get_started_action_set()) { + for (Action const& action : *get_started_action_set()) { const auto& net_action = static_cast(action); if (net_action.get_latency() > 0 && (min < 0 || net_action.get_latency() < min)) { min = net_action.get_latency(); @@ -119,19 +120,19 @@ void HostL07Model::update_actions_state(double /*now*/, double delta) if (((action.get_remains() <= 0) && (action.get_variable()->get_penalty() > 0)) || ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { - action.finish(kernel::resource::Action::State::FINISHED); + action.finish(Action::State::FINISHED); continue; } /* Need to check that none of the model has failed */ int i = 0; - const kernel::lmm::Constraint* cnst = action.get_variable()->get_constraint(i); + const lmm::Constraint* cnst = action.get_variable()->get_constraint(i); while (cnst != nullptr) { i++; - const kernel::resource::Resource* constraint_id = cnst->get_id(); + const Resource* constraint_id = cnst->get_id(); if (not constraint_id->is_on()) { XBT_DEBUG("Action (%p) Failed!!", &action); - action.finish(kernel::resource::Action::State::FAILED); + action.finish(Action::State::FAILED); break; } cnst = action.get_variable()->get_constraint(i); @@ -139,15 +140,14 @@ void HostL07Model::update_actions_state(double /*now*/, double delta) } } -kernel::resource::CpuAction* HostL07Model::execute_parallel(const std::vector& host_list, - const double* flops_amount, const double* bytes_amount, - double rate) +CpuAction* HostL07Model::execute_parallel(const std::vector& host_list, const double* flops_amount, + const double* bytes_amount, double rate) { return new L07Action(this, host_list, flops_amount, bytes_amount, rate); } -L07Action::L07Action(kernel::resource::Model* model, const std::vector& host_list, - const double* flops_amount, const double* bytes_amount, double rate) +L07Action::L07Action(Model* model, const std::vector& host_list, const double* flops_amount, + const double* bytes_amount, double rate) : CpuAction(model, 1.0, false), computationAmount_(flops_amount), communicationAmount_(bytes_amount), rate_(rate) { size_t link_nb = 0; @@ -169,7 +169,7 @@ L07Action::L07Action(kernel::resource::Model* model, const std::vector route; + std::vector route; hostList_[k / host_list.size()]->route_to(hostList_[k % host_list.size()], route, &lat); latency = std::max(latency, lat); @@ -206,7 +206,7 @@ L07Action::L07Action(kernel::resource::Model* model, const std::vector route; + std::vector route; hostList_[k / host_list.size()]->route_to(hostList_[k % host_list.size()], route, nullptr); for (auto const& link : route) @@ -220,7 +220,7 @@ L07Action::L07Action(kernel::resource::Model* model, const std::vector host_list = {src, dst}; const auto* flops_amount = new double[2](); @@ -228,17 +228,17 @@ kernel::resource::Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host bytes_amount[1] = size; - kernel::resource::Action* res = hostModel_->execute_parallel(host_list, flops_amount, bytes_amount, rate); + Action* res = hostModel_->execute_parallel(host_list, flops_amount, bytes_amount, rate); static_cast(res)->free_arrays_ = true; return res; } -kernel::resource::CpuImpl* CpuL07Model::create_cpu(s4u::Host* host, const std::vector& speed_per_pstate) +CpuImpl* CpuL07Model::create_cpu(s4u::Host* host, const std::vector& speed_per_pstate) { return (new CpuL07(host, speed_per_pstate))->set_model(this); } -kernel::resource::LinkImpl* NetworkL07Model::create_link(const std::string& name, const std::vector& bandwidths) +LinkImpl* NetworkL07Model::create_link(const std::string& name, const std::vector& bandwidths) { xbt_assert(bandwidths.size() == 1, "Non WIFI link must have only 1 bandwidth."); auto link = new LinkL07(name, bandwidths[0], get_maxmin_system()); @@ -246,8 +246,7 @@ kernel::resource::LinkImpl* NetworkL07Model::create_link(const std::string& name return link; } -kernel::resource::LinkImpl* NetworkL07Model::create_wifi_link(const std::string& name, - const std::vector& bandwidths) +LinkImpl* NetworkL07Model::create_wifi_link(const std::string& name, const std::vector& bandwidths) { THROW_UNIMPLEMENTED; } @@ -256,7 +255,7 @@ kernel::resource::LinkImpl* NetworkL07Model::create_wifi_link(const std::string& * Resource * ************/ -kernel::resource::CpuAction* CpuL07::execution_start(double size, double user_bound) +CpuAction* CpuL07::execution_start(double size, double user_bound) { std::vector host_list = {get_iface()}; xbt_assert(user_bound <= 0, "User bound not supported by ptask model"); @@ -264,17 +263,17 @@ kernel::resource::CpuAction* CpuL07::execution_start(double size, double user_bo auto* flops_amount = new double[host_list.size()](); flops_amount[0] = size; - kernel::resource::CpuAction* res = + CpuAction* res = static_cast(get_model())->hostModel_->execute_parallel(host_list, flops_amount, nullptr, -1); static_cast(res)->free_arrays_ = true; return res; } -kernel::resource::CpuAction* CpuL07::sleep(double duration) +CpuAction* CpuL07::sleep(double duration) { auto* action = static_cast(execution_start(1.0, -1)); action->set_max_duration(duration); - action->set_suspend_state(kernel::resource::Action::SuspendStates::SLEEPING); + action->set_suspend_state(Action::SuspendStates::SLEEPING); get_model()->get_maxmin_system()->update_variable_penalty(action->get_variable(), 0.0); return action; @@ -283,11 +282,11 @@ kernel::resource::CpuAction* CpuL07::sleep(double duration) /** @brief take into account changes of speed (either load or max) */ void CpuL07::on_speed_change() { - const kernel::lmm::Element* elem = nullptr; + const lmm::Element* elem = nullptr; get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), speed_.peak * speed_.scale); while (const auto* var = get_constraint()->get_variable(&elem)) { - const kernel::resource::Action* action = var->get_id(); + const Action* action = var->get_id(); get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), speed_.scale * speed_.peak); } @@ -295,13 +294,13 @@ void CpuL07::on_speed_change() CpuImpl::on_speed_change(); } -LinkL07::LinkL07(const std::string& name, double bandwidth, kernel::lmm::System* system) : LinkImpl(name) +LinkL07::LinkL07(const std::string& name, double bandwidth, lmm::System* system) : LinkImpl(name) { this->set_constraint(system->constraint_new(this, bandwidth)); bandwidth_.peak = bandwidth; } -void CpuL07::apply_event(kernel::profile::Event* triggered, double value) +void CpuL07::apply_event(profile::Event* triggered, double value) { XBT_DEBUG("Updating cpu %s (%p) with value %g", get_cname(), this, value); if (triggered == speed_.event) { @@ -324,7 +323,7 @@ void CpuL07::apply_event(kernel::profile::Event* triggered, double value) } } -void LinkL07::apply_event(kernel::profile::Event* triggered, double value) +void LinkL07::apply_event(profile::Event* triggered, double value) { XBT_DEBUG("Updating link %s (%p) with value=%f", get_cname(), this, value); if (triggered == bandwidth_.event) { @@ -357,7 +356,7 @@ void LinkL07::set_bandwidth(double value) void LinkL07::set_latency(double value) { latency_check(value); - const kernel::lmm::Element* elem = nullptr; + const lmm::Element* elem = nullptr; latency_.peak = value; while (const auto* var = get_constraint()->get_variable(&elem)) { @@ -390,7 +389,7 @@ void L07Action::updateBound() for (size_t j = 0; j < host_count; j++) { if (communicationAmount_[i * host_count + j] > 0) { double lat = 0.0; - std::vector route; + std::vector route; hostList_.at(i)->route_to(hostList_.at(j), route, &lat); lat_current = std::max(lat_current, lat * communicationAmount_[i * host_count + j]); @@ -398,7 +397,7 @@ void L07Action::updateBound() } } } - double lat_bound = kernel::resource::NetworkModel::cfg_tcp_gamma / (2.0 * lat_current); + double lat_bound = NetworkModel::cfg_tcp_gamma / (2.0 * lat_current); XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound); if ((latency_ <= 0.0) && is_running()) { if (rate_ < 0) @@ -408,5 +407,6 @@ void L07Action::updateBound() } } -} // namespace surf +} // namespace resource +} // namespace kernel } // namespace simgrid diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index 9b52893b41..78dfe83776 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -12,7 +12,8 @@ #define HOST_L07_HPP_ namespace simgrid { -namespace surf { +namespace kernel { +namespace resource { /*********** * Classes * @@ -26,9 +27,6 @@ class XBT_PRIVATE CpuL07; class XBT_PRIVATE LinkL07; class XBT_PRIVATE L07Action; -/********* - * Tools * - *********/ /********* * Model * @@ -41,13 +39,13 @@ public: double next_occurring_event(double now) override; void update_actions_state(double now, double delta) override; - kernel::resource::CpuAction* execute_parallel(const std::vector& host_list, const double* flops_amount, - const double* bytes_amount, double rate) override; + CpuAction* execute_parallel(const std::vector& host_list, const double* flops_amount, + const double* bytes_amount, double rate) override; }; -class CpuL07Model : public kernel::resource::CpuModel { +class CpuL07Model : public CpuModel { public: - CpuL07Model(const std::string& name, HostL07Model* hmodel, kernel::lmm::System* sys); + CpuL07Model(const std::string& name, HostL07Model* hmodel, lmm::System* sys); CpuL07Model(const CpuL07Model&) = delete; CpuL07Model& operator=(const CpuL07Model&) = delete; ~CpuL07Model() override; @@ -57,20 +55,20 @@ public: * method in surf_presolve */ }; - kernel::resource::CpuImpl* create_cpu(s4u::Host* host, const std::vector& speed_per_pstate) override; + CpuImpl* create_cpu(s4u::Host* host, const std::vector& speed_per_pstate) override; HostL07Model* hostModel_; }; -class NetworkL07Model : public kernel::resource::NetworkModel { +class NetworkL07Model : public NetworkModel { public: - NetworkL07Model(const std::string& name, HostL07Model* hmodel, kernel::lmm::System* sys); + NetworkL07Model(const std::string& name, HostL07Model* hmodel, lmm::System* sys); NetworkL07Model(const NetworkL07Model&) = delete; NetworkL07Model& operator=(const NetworkL07Model&) = delete; ~NetworkL07Model() override; - kernel::resource::LinkImpl* create_link(const std::string& name, const std::vector& bandwidths) final; - kernel::resource::LinkImpl* create_wifi_link(const std::string& name, const std::vector& bandwidths) override; + LinkImpl* create_link(const std::string& name, const std::vector& bandwidths) final; + LinkImpl* create_wifi_link(const std::string& name, const std::vector& bandwidths) override; - kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; + Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; void update_actions_state(double /*now*/, double /*delta*/) override{ /* this action is done by HostL07Model which shares the LMM system with the CPU model * Overriding to an empty function here allows us to handle the Cpu07Model as a regular @@ -84,32 +82,32 @@ public: * Resource * ************/ -class CpuL07 : public kernel::resource::CpuImpl { +class CpuL07 : public CpuImpl { public: - using kernel::resource::CpuImpl::CpuImpl; + using CpuImpl::CpuImpl; CpuL07(const CpuL07&) = delete; CpuL07& operator=(const CpuL07&) = delete; - void apply_event(kernel::profile::Event* event, double value) override; - kernel::resource::CpuAction* execution_start(double size, double user_bound) override; - kernel::resource::CpuAction* execution_start(double, int, double) override + void apply_event(profile::Event* event, double value) override; + CpuAction* execution_start(double size, double user_bound) override; + CpuAction* execution_start(double, int, double) override { THROW_UNIMPLEMENTED; return nullptr; } - kernel::resource::CpuAction* sleep(double duration) override; + CpuAction* sleep(double duration) override; protected: void on_speed_change() override; }; -class LinkL07 : public kernel::resource::LinkImpl { +class LinkL07 : public LinkImpl { public: - LinkL07(const std::string& name, double bandwidth, kernel::lmm::System* system); + LinkL07(const std::string& name, double bandwidth, lmm::System* system); LinkL07(const LinkL07&) = delete; LinkL07& operator=(const LinkL07&) = delete; ~LinkL07() override; - void apply_event(kernel::profile::Event* event, double value) override; + void apply_event(profile::Event* event, double value) override; void set_bandwidth(double value) override; void set_latency(double value) override; }; @@ -117,7 +115,7 @@ public: /********** * Action * **********/ -class L07Action : public kernel::resource::CpuAction { +class L07Action : public CpuAction { std::vector hostList_; bool free_arrays_ = false; // By default, computationAmount_ and friends are freed by caller. But not for sequential // exec and regular comms @@ -136,7 +134,7 @@ class L07Action : public kernel::resource::CpuAction { public: L07Action() = delete; - L07Action(kernel::resource::Model* model, const std::vector& host_list, const double* flops_amount, + L07Action(Model* model, const std::vector& host_list, const double* flops_amount, const double* bytes_amount, double rate); L07Action(const L07Action&) = delete; L07Action& operator=(const L07Action&) = delete; @@ -148,7 +146,8 @@ public: void update_latency(double delta, double precision) { double_update(&latency_, delta, precision); } }; -} // namespace surf +} // namespace resource +} // namespace kernel } // namespace simgrid #endif /* HOST_L07_HPP_ */