X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7672ae43c2b49a7dcdc0976cc89a05cc87ae534c..0711d069cdfa51d648da943d017ea36850aadfe0:/src/s4u/s4u_Host.cpp diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 6f80d6e1f1..91da3536e1 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2023. 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. */ @@ -14,14 +14,14 @@ #include #include "simgrid/simix.hpp" +#include "src/kernel/resource/HostImpl.hpp" #include "src/kernel/resource/StandardLinkImpl.hpp" #include "src/kernel/resource/VirtualMachineImpl.hpp" -#include "src/surf/HostImpl.hpp" #include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_host, s4u, "Logging specific to the S4U hosts"); -XBT_LOG_EXTERNAL_CATEGORY(ker_routing); +XBT_LOG_EXTERNAL_CATEGORY(ker_platform); namespace simgrid { @@ -32,8 +32,9 @@ namespace s4u { #ifndef DOXYGEN xbt::signal Host::on_creation; xbt::signal Host::on_destruction; -xbt::signal Host::on_state_change; +xbt::signal Host::on_onoff; xbt::signal Host::on_speed_change; +xbt::signal Host::on_exec_state_change; #endif Host* Host::set_cpu(kernel::resource::CpuImpl* cpu) @@ -101,7 +102,8 @@ void Host::turn_on() kernel::actor::simcall_answered([this] { this->pimpl_cpu_->turn_on(); this->pimpl_->turn_on(); - on_state_change(*this); + on_onoff(*this); + on_this_onoff(*this); }); } } @@ -115,7 +117,8 @@ void Host::turn_off() this->pimpl_cpu_->turn_off(); this->pimpl_->turn_off(self); - on_state_change(*this); + on_onoff(*this); + on_this_onoff(*this); }); } } @@ -164,16 +167,26 @@ void Host::route_to(const Host* dest, std::vector& links, double* latency for (auto* l : linkImpls) links.push_back(l->get_iface()); } +std::pair, double> Host::route_to(const Host* dest) const +{ + std::vector linkImpls; + std::vector links; + double latency = 0; + this->route_to(dest, linkImpls, &latency); + for (auto* l : linkImpls) + links.push_back(l->get_iface()); + return std::make_pair(links, latency); +} /** @brief Just like Host::routeTo, but filling an array of link implementations */ void Host::route_to(const Host* dest, std::vector& links, double* latency) const { kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint_, dest->get_netpoint(), links, latency); - if (XBT_LOG_ISENABLED(ker_routing, xbt_log_priority_debug)) { - XBT_CDEBUG(ker_routing, "Route from '%s' to '%s' (latency: %f):", get_cname(), dest->get_cname(), + if (XBT_LOG_ISENABLED(ker_platform, xbt_log_priority_debug)) { + XBT_CDEBUG(ker_platform, "Route from '%s' to '%s' (latency: %f):", get_cname(), dest->get_cname(), (latency == nullptr ? -1 : *latency)); for (auto const* link : links) - XBT_CDEBUG(ker_routing, " Link '%s'", link->get_cname()); + XBT_CDEBUG(ker_platform, " Link '%s'", link->get_cname()); } } @@ -207,6 +220,17 @@ Host* Host::set_properties(const std::unordered_map& p return this; } +int Host::get_concurrency_limit() const +{ + return pimpl_cpu_->get_concurrency_limit(); +} + +Host* Host::set_concurrency_limit(int limit) +{ + kernel::actor::simcall_object_access(pimpl_cpu_, [this, limit] { pimpl_cpu_->set_concurrency_limit(limit); }); + return this; +} + /** Specify a profile turning the host on and off according to an exhaustive list or a stochastic law. * The profile must contain boolean values. */ Host* Host::set_state_profile(kernel::profile::Profile* p) @@ -283,7 +307,7 @@ std::vector Host::convert_pstate_speed_vector(const std::vectorset_priority(1 / priority)->vetoable_start()->wait(); + this_actor::exec_init(flops)->set_priority(1 / priority)->start()->wait(); } Host* Host::seal() @@ -554,7 +576,7 @@ void sg_host_turn_on(sg_host_t host) * * @brief Stop the host if it is on * - * See also #MSG_host_is_on() to test the current state of the host and @ref plugin_host_energy + * See also #sg_host_is_on() to test the current state of the host and @ref plugin_host_energy * for more info on DVFS. */ void sg_host_turn_off(sg_host_t host)