Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Objectif the disk model
[simgrid.git] / src / kernel / routing / NetZoneImpl.cpp
index fe2c721691327aec93a9822d971064f0dae9880c..b255d1feef12650633a2acea45101e67b2f301a8 100644 (file)
@@ -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. */
@@ -20,7 +20,7 @@
 #include "src/kernel/resource/VirtualMachineImpl.hpp"
 #include "src/surf/HostImpl.hpp"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing, kernel, "Kernel routing-related information");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_platform, kernel, "Kernel platform-related information");
 
 namespace simgrid::kernel::routing {
 
@@ -33,38 +33,26 @@ static void surf_config_models_setup()
   std::string disk_model_name    = simgrid::config::get_value<std::string>("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")) &&
-      simgrid::config::is_default("host/model")) {
+  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 network_model_name.empty(), "Set a network model to use with the 'compound' host model");
-
-    const auto* cpu_model = find_model_description(surf_cpu_model_description, cpu_model_name);
-    cpu_model->model_init_preparse();
-
-    const auto* network_model = find_model_description(surf_network_model_description, network_model_name);
-    network_model->model_init_preparse();
+    simgrid_cpu_models().by_name(cpu_model_name).init();
+    simgrid_disk_models().by_name(disk_model_name).init();
+    simgrid_network_models().by_name(network_model_name).init();
   }
 
-  XBT_DEBUG("Call host_model_init");
-  const auto* host_model = find_model_description(surf_host_model_description, host_model_name);
-  host_model->model_init_preparse();
+  simgrid_host_models().by_name(host_model_name).init();
 
   XBT_DEBUG("Call vm_model_init");
-  /* ideally we should get back the pointer to CpuModel from model_init_preparse(), but this
-   * requires changing the declaration of surf_cpu_model_description.
-   * To be reviewed in the future */
+  /* 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_DEBUG("Call disk_model_init");
-  const auto* disk_model = find_model_description(surf_disk_model_description, disk_model_name);
-  disk_model->model_init_preparse();
 }
 
 xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
@@ -343,13 +331,11 @@ resource::SplitDuplexLinkImpl* NetZoneImpl::get_split_duplex_link_by_name_or_nul
 
 resource::HostImpl* NetZoneImpl::get_host_by_name_or_null(const std::string& name) const
 {
-  auto host_it = hosts_.find(name);
-  if (host_it != hosts_.end())
+  if (auto host_it = hosts_.find(name); host_it != hosts_.end())
     return host_it->second;
 
   for (const auto* child : children_) {
-    auto* host = child->get_host_by_name_or_null(name);
-    if (host)
+    if (auto* host = child->get_host_by_name_or_null(name))
       return host;
   }