Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix weird bug on pstate changes with VM
[simgrid.git] / src / surf / sg_platf.cpp
index d716fb8723bdde7f8fff80ac4dec28a0a944209c..251c3ce2df72b1337daaf79edff804c7d9edfd49 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2022. 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. */
@@ -23,8 +23,8 @@
 #include "src/kernel/resource/DiskImpl.hpp"
 #include "src/kernel/resource/profile/Profile.hpp"
 #include "src/surf/HostImpl.hpp"
+#include "src/surf/xml/platf.hpp"
 #include "src/surf/xml/platf_private.hpp"
-#include "surf/surf.hpp"
 
 #include <algorithm>
 #include <string>
@@ -56,7 +56,6 @@ void sg_platf_init()
 void sg_platf_exit()
 {
   simgrid::kernel::routing::on_cluster_creation.disconnect_slots();
-  simgrid::s4u::Engine::on_platform_created.disconnect_slots();
 
   surf_parse_lex_destroy();
 }
@@ -114,16 +113,6 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name,
   return netpoint;
 }
 
-static void sg_platf_set_link_properties(simgrid::s4u::Link* link,
-                                         const simgrid::kernel::routing::LinkCreationArgs* args)
-{
-  link->set_properties(args->properties)
-      ->set_state_profile(args->state_trace)
-      ->set_latency_profile(args->latency_trace)
-      ->set_bandwidth_profile(args->bandwidth_trace)
-      ->set_latency(args->latency);
-}
-
 void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* args)
 {
   simgrid::s4u::Link* link;
@@ -133,7 +122,13 @@ void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* args)
     link = current_routing->create_link(args->id, args->bandwidths);
     link->get_impl()->set_sharing_policy(args->policy, {});
   }
-  sg_platf_set_link_properties(link, args);
+
+  link->set_properties(args->properties)
+      ->set_state_profile(args->state_trace)
+      ->set_latency_profile(args->latency_trace)
+      ->set_bandwidth_profile(args->bandwidth_trace)
+      ->set_latency(args->latency);
+
   link->seal();
 }
 
@@ -223,27 +218,25 @@ static void sg_platf_new_cluster_hierarchical(const simgrid::kernel::routing::Cl
   }
 
   simgrid::s4u::NetZone const* parent = current_routing ? current_routing->get_iface() : nullptr;
-  simgrid::s4u::NetZone* zone;
   switch (cluster->topology) {
     case simgrid::kernel::routing::ClusterTopology::TORUS:
-      zone = simgrid::s4u::create_torus_zone(
-          cluster->id, parent, TorusZone::parse_topo_parameters(cluster->topo_parameters),
-          {set_host, set_loopback, set_limiter}, cluster->bw, cluster->lat, cluster->sharing_policy);
+      simgrid::s4u::create_torus_zone(cluster->id, parent, TorusZone::parse_topo_parameters(cluster->topo_parameters),
+                                      {set_host, set_loopback, set_limiter}, cluster->bw, cluster->lat,
+                                      cluster->sharing_policy);
       break;
     case simgrid::kernel::routing::ClusterTopology::DRAGONFLY:
-      zone = simgrid::s4u::create_dragonfly_zone(
+      simgrid::s4u::create_dragonfly_zone(
           cluster->id, parent, DragonflyZone::parse_topo_parameters(cluster->topo_parameters),
           {set_host, set_loopback, set_limiter}, cluster->bw, cluster->lat, cluster->sharing_policy);
       break;
     case simgrid::kernel::routing::ClusterTopology::FAT_TREE:
-      zone = simgrid::s4u::create_fatTree_zone(
+      simgrid::s4u::create_fatTree_zone(
           cluster->id, parent, FatTreeZone::parse_topo_parameters(cluster->topo_parameters),
           {set_host, set_loopback, set_limiter}, cluster->bw, cluster->lat, cluster->sharing_policy);
       break;
     default:
       THROW_IMPOSSIBLE;
   }
-  zone->seal();
 }
 
 /*************************************************************************************************/
@@ -336,7 +329,6 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA
   auto* router = zone->create_router(cluster->router_id);
   zone->add_route(router, nullptr, nullptr, nullptr, {});
 
-  zone->seal();
   simgrid::kernel::routing::on_cluster_creation(*cluster);
 }
 
@@ -602,7 +594,6 @@ void sg_platf_new_zone_seal()
     zone_cluster.cabinets.clear();
     zone_cluster.backbone.reset();
   }
-  current_routing->seal();
   current_routing = current_routing->get_parent();
 }