X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dba14c50ee8b9a49c93d13606839fd3c1b611c1b..HEAD:/src/kernel/routing/NetZoneImpl.cpp diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index e2e606d1e2..08df429aca 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -9,56 +9,22 @@ #include #include -#include "xbt/asserts.hpp" -#include "src/include/simgrid/sg_config.hpp" #include "src/kernel/EngineImpl.hpp" #include "src/kernel/resource/CpuImpl.hpp" #include "src/kernel/resource/DiskImpl.hpp" +#include "src/kernel/resource/HostImpl.hpp" #include "src/kernel/resource/NetworkModel.hpp" #include "src/kernel/resource/SplitDuplexLinkImpl.hpp" #include "src/kernel/resource/StandardLinkImpl.hpp" #include "src/kernel/resource/VirtualMachineImpl.hpp" -#include "src/surf/HostImpl.hpp" +#include "src/simgrid/module.hpp" +#include "src/simgrid/sg_config.hpp" +#include "xbt/asserts.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_platform, kernel, "Kernel platform-related information"); namespace simgrid::kernel::routing { -/* Pick the right models for CPU, net and host, and call their model_init_preparse */ -static void surf_config_models_setup() -{ - std::string host_model_name = simgrid::config::get_value("host/model"); - std::string network_model_name = simgrid::config::get_value("network/model"); - std::string cpu_model_name = simgrid::config::get_value("cpu/model"); - std::string disk_model_name = simgrid::config::get_value("disk/model"); - - /* The compound host model is needed when using non-default net/cpu models */ - if ((not simgrid::config::is_default("network/model") || not simgrid::config::is_default("cpu/model") || - not simgrid::config::is_default("disk/model")) && simgrid::config::is_default("host/model")) { - host_model_name = "compound"; - simgrid::config::set_value("host/model", host_model_name); - } - - XBT_DEBUG("host model: %s", host_model_name.c_str()); - if (host_model_name == "compound") { - xbt_enforce(not cpu_model_name.empty(), "Set a cpu model to use with the 'compound' host model"); - xbt_enforce(not disk_model_name.empty(), "Set a disk model to use with the 'compound' host model"); - xbt_enforce(not network_model_name.empty(), "Set a network model to use with the 'compound' host model"); - - simgrid_cpu_models().by_name(cpu_model_name).init(); - surf_disk_model_description.by_name(disk_model_name).init(); - simgrid_network_models().by_name(network_model_name).init(); - } - - simgrid_host_models().by_name(host_model_name).init(); - - XBT_DEBUG("Call vm_model_init"); - /* TODO: ideally we should get back the pointer to CpuModel from init(), but this - * requires changing the declaration of the ModuleGroup returned by simgrid_cpu_models() */ - surf_vm_model_init_HL13( - simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->get_cpu_pm_model().get()); -} - xbt::signal const& link_list)> @@ -68,22 +34,23 @@ NetZoneImpl::NetZoneImpl(const std::string& name) : piface_(this), name_(name) { auto* engine = s4u::Engine::get_instance(); /* workaroud: first netzoneImpl will be the root netzone. - * Without globals and with current surf_*_model_description init functions, we need + * Without globals and with current model description init functions (see module.hpp), we need * the root netzone to exist when creating the models. - * This was usually done at sg_platf.cpp, during XML parsing */ + * This is usually done at sg_platf.cpp, during XML parsing */ if (not engine->get_netzone_root()) { engine->set_netzone_root(&piface_); /* root netzone set, initialize models */ simgrid::s4u::Engine::on_platform_creation(); - /* Initialize the surf models. That must be done after we got all config, and before we need the models. + /* Initialize the models. That must be done after we got all config, and before we need the models. * That is, after the last tag, if any, and before the first of cluster|peer|zone|trace|trace_cb * * I'm not sure for and , there may be a bug here * (FIXME: check it out by creating a file beginning with one of these tags) * but cluster and peer come down to zone creations, so putting this verification here is correct. */ - surf_config_models_setup(); + simgrid_host_models().init_from_flag_value(); + simgrid_vm_model_init_HL13(); } xbt_enforce(nullptr == engine->netpoint_by_name_or_null(get_name()), @@ -628,7 +595,7 @@ void NetZoneImpl::get_global_route_with_netzones(const NetPoint* src, const NetP return; /* If src and dst are in the same netzone, life is good */ - if (src_ancestor == dst_ancestor) { /* SURF_ROUTING_BASE */ + if (src_ancestor == dst_ancestor) { /* ROUTING_BASE */ route.link_list_ = std::move(links); common_ancestor->get_local_route(src, dst, &route, latency); links = std::move(route.link_list_); @@ -655,8 +622,8 @@ void NetZoneImpl::get_graph(const s_xbt_graph_t* graph, std::map vertices = get_vertices(); - for (auto const& my_src : vertices) { - for (auto const& my_dst : vertices) { + for (auto const* my_src : vertices) { + for (auto const* my_dst : vertices) { if (my_src == my_dst) continue; @@ -702,6 +669,24 @@ void NetZoneImpl::get_graph(const s_xbt_graph_t* graph, std::mapsecond; +} + void NetZoneImpl::seal() { /* already sealed netzone */ @@ -709,6 +694,10 @@ void NetZoneImpl::seal() return; do_seal(); // derived class' specific sealing procedure + // for zone with a single host, this host is its own default gateway + if (gateways_.empty() && hosts_.size() == 1) + gateways_["default"] = hosts_.begin()->second->get_iface()->get_netpoint(); + /* seals sub-netzones and hosts */ for (auto* host : get_all_hosts()) { host->seal();