Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove a useless pimple
[simgrid.git] / src / surf / sg_platf.cpp
index 90c16a2..8742488 100644 (file)
@@ -4,22 +4,11 @@
 /* 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. */
 
-#include "xbt/misc.h"
-#include "xbt/log.h"
-#include "xbt/str.h"
-#include "xbt/dict.h"
-#include "xbt/RngStream.h"
-#include <xbt/functional.hpp>
-#include <xbt/signal.hpp>
-#include "src/surf/HostImpl.hpp"
-#include "surf/surf.h"
-
 #include "simgrid/s4u/engine.hpp"
 #include "src/kernel/EngineImpl.hpp"
 #include "src/simix/smx_private.h"
 
 #include "src/include/simgrid/sg_config.h"
-#include "src/surf/xml/platf_private.hpp"
 
 #include "src/surf/HostImpl.hpp"
 #include "src/surf/cpu_interface.hpp"
@@ -44,7 +33,6 @@ XBT_PRIVATE xbt_dynar_t mount_list = nullptr;
 namespace simgrid {
 namespace surf {
 
-simgrid::xbt::signal<void(sg_platf_link_cbarg_t)> on_link;
 simgrid::xbt::signal<void(sg_platf_cluster_cbarg_t)> on_cluster;
 simgrid::xbt::signal<void(void)> on_postparse;
 
@@ -66,7 +54,6 @@ void sg_platf_init() {
 
 /** Module management function: frees all internal data structures */
 void sg_platf_exit() {
-  simgrid::surf::on_link.disconnect_all_slots();
   simgrid::surf::on_cluster.disconnect_all_slots();
   simgrid::surf::on_postparse.disconnect_all_slots();
 
@@ -115,21 +102,16 @@ void sg_platf_new_router(sg_platf_router_cbarg_t router)
 
   if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset)
     current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::base;
-  xbt_assert(nullptr == xbt_lib_get_or_null(as_router_lib, router->id, ROUTING_ASR_LEVEL),
+  xbt_assert(nullptr == simgrid::s4u::Engine::instance()->netcardByNameOrNull(router->id),
              "Refusing to create a router named '%s': this name already describes a node.", router->id);
 
   simgrid::kernel::routing::NetCard* netcard =
     new simgrid::kernel::routing::NetCard(router->id, simgrid::kernel::routing::NetCard::Type::Router, current_routing);
-  xbt_lib_set(as_router_lib, router->id, ROUTING_ASR_LEVEL, netcard);
   XBT_DEBUG("Router '%s' has the id %d", router->id, netcard->id());
 
   if (router->coord && strcmp(router->coord, ""))
     new simgrid::kernel::routing::vivaldi::Coords(netcard, router->coord);
 
-  auto cluster = dynamic_cast<simgrid::kernel::routing::ClusterZone*>(current_routing);
-  if(cluster != nullptr)
-    cluster->router_ = static_cast<simgrid::kernel::routing::NetCard*>(xbt_lib_get_or_null(as_router_lib, router->id, ROUTING_ASR_LEVEL));
-
   if (TRACE_is_enabled() && TRACE_needs_platform())
     sg_instr_new_router(router);
 }
@@ -163,8 +145,6 @@ void sg_platf_new_link(sg_platf_link_cbarg_t link){
 
     xbt_free(link_name);
   }
-
-  simgrid::surf::on_link(link);
 }
 
 void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
@@ -296,8 +276,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
     rankId++;
   }
 
-  // Add a router. It is magically used thanks to the way in which surf_routing_cluster is written,
-  // and it's very useful to connect clusters together
+  // Add a router.
   XBT_DEBUG(" ");
   XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id);
   char *newid = nullptr;
@@ -307,7 +286,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
   if (!router.id || !strcmp(router.id, ""))
     router.id = newid = bprintf("%s%s_router%s", cluster->prefix, cluster->id, cluster->suffix);
   sg_platf_new_router(&router);
-  current_as->router_ = (simgrid::kernel::routing::NetCard*) xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL);
+  current_as->router_ = simgrid::s4u::Engine::instance()->netcardByNameOrNull(router.id);
   free(newid);
 
   //Make the backbone
@@ -573,13 +552,13 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
 void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
 {
   simgrid::kernel::routing::VivaldiZone* as = dynamic_cast<simgrid::kernel::routing::VivaldiZone*>(current_routing);
-  xbt_assert(as, "<peer> tag can only be used in Vivaldi ASes");
+  xbt_assert(as, "<peer> tag can only be used in Vivaldi netzones.");
 
   std::vector<double> speedPerPstate;
   speedPerPstate.push_back(peer->speed);
   simgrid::s4u::Host* host = as->createHost(peer->id, &speedPerPstate, 1);
 
-  as->setPeerLink(host->pimpl_netcard, peer->bw_in, peer->bw_out, peer->lat, peer->coord);
+  as->setPeerLink(host->pimpl_netcard, peer->bw_in, peer->bw_out, peer->coord);
   simgrid::s4u::Host::onCreation(*host);
 
   /* Change from the defaults */
@@ -703,9 +682,9 @@ simgrid::s4u::NetZone* sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
   }
 
   if (current_routing == nullptr) { /* it is the first one */
-    xbt_assert(simgrid::s4u::Engine::instance()->pimpl->rootAs_ == nullptr,
+    xbt_assert(simgrid::s4u::Engine::instance()->pimpl->netRoot_ == nullptr,
                "All defined components must belong to a AS");
-    simgrid::s4u::Engine::instance()->pimpl->rootAs_ = new_as;
+    simgrid::s4u::Engine::instance()->pimpl->netRoot_ = new_as;
 
   } else {
     /* set the father behavior */