Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
modernize cabinet creation
[simgrid.git] / src / surf / sg_platf.cpp
index b3e76c3a00f46b9339cddcd3f4189a619d43a38c..1e41058fec2ea83d67d2f33537efd3644499c6f9 100644 (file)
@@ -63,10 +63,8 @@ void sg_platf_exit()
 /** @brief Add a host to the current NetZone */
 void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
 {
-  simgrid::s4u::Host* host = routing_get_current()->create_host(args->id, args->speed_per_pstate);
-
-  if (not args->coord.empty())
-    new simgrid::kernel::routing::vivaldi::Coords(host->get_netpoint(), args->coord);
+  simgrid::s4u::Host* host =
+      routing_get_current()->create_host(args->id, args->speed_per_pstate)->set_coordinates(args->coord);
 
   if (args->properties) {
     host->set_properties(*args->properties);
@@ -87,7 +85,7 @@ void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
 }
 
 /** @brief Add a "router" to the network element list */
-simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, const char* coords)
+simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, const std::string& coords)
 {
   xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name),
              "Refusing to create a router named '%s': this name already describes a node.", name.c_str());
@@ -96,8 +94,8 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name,
   netpoint->set_englobing_zone(current_routing);
   XBT_DEBUG("Router '%s' has the id %u", netpoint->get_cname(), netpoint->id());
 
-  if (coords && strcmp(coords, ""))
-    new simgrid::kernel::routing::vivaldi::Coords(netpoint, coords);
+  if (not coords.empty())
+    netpoint->set_coordinates(coords);
 
   return netpoint;
 }
@@ -231,7 +229,7 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster
   XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id.c_str());
   if (cluster->router_id.empty())
     cluster->router_id = std::string(cluster->prefix) + cluster->id + "_router" + cluster->suffix;
-  current_zone->set_router(sg_platf_new_router(cluster->router_id, nullptr));
+  current_zone->set_router(sg_platf_new_router(cluster->router_id, ""));
 
   // Make the backbone
   if ((cluster->bb_bw > 0) || (cluster->bb_lat > 0)) {
@@ -267,27 +265,17 @@ void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb)
 
 void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet)
 {
+  auto* zone = static_cast<simgrid::kernel::routing::ClusterZone*>(routing_get_current());
   for (int const& radical : *cabinet->radicals) {
-    std::string hostname = cabinet->prefix + std::to_string(radical) + cabinet->suffix;
-    simgrid::kernel::routing::HostCreationArgs host;
-    host.pstate      = 0;
-    host.core_amount = 1;
-    host.id          = hostname;
-    host.speed_per_pstate.push_back(cabinet->speed);
-    sg_platf_new_host(&host);
-
-    simgrid::kernel::routing::LinkCreationArgs link;
-    link.policy  = simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX;
-    link.latency = cabinet->lat;
-    link.bandwidths.push_back(cabinet->bw);
-    link.id = "link_" + hostname;
-    sg_platf_new_link(&link);
-
-    simgrid::kernel::routing::HostLinkCreationArgs host_link;
-    host_link.id        = hostname;
-    host_link.link_up   = std::string("link_") + hostname + "_UP";
-    host_link.link_down = std::string("link_") + hostname + "_DOWN";
-    sg_platf_new_hostlink(&host_link);
+    std::string id           = cabinet->prefix + std::to_string(radical) + cabinet->suffix;
+    simgrid::s4u::Host* host = zone->create_host(id, std::vector<double>{cabinet->speed})->seal();
+
+    simgrid::s4u::Link* link_up =
+        zone->create_link("link_" + id + "_UP", std::vector<double>{cabinet->bw})->set_latency(cabinet->lat)->seal();
+    simgrid::s4u::Link* link_down =
+        zone->create_link("link_" + id + "_DOWN", std::vector<double>{cabinet->bw})->set_latency(cabinet->lat)->seal();
+
+    zone->add_private_link_at(host->get_netpoint()->id(), {link_up->get_impl(), link_down->get_impl()});
   }
   delete cabinet->radicals;
 }
@@ -395,13 +383,12 @@ void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer)
 
   simgrid::s4u::Host* host = zone->create_host(peer->id, std::vector<double>{peer->speed})
                                  ->set_state_profile(peer->state_trace)
-                                 ->set_speed_profile(peer->speed_trace);
+                                 ->set_speed_profile(peer->speed_trace)
+                                 ->set_coordinates(peer->coord)
+                                 ->seal();
 
-  zone->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out, peer->coord);
-
-  host->seal();
+  zone->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out);
 }
-
 /**
  * @brief Auxiliary function to build the object NetZoneImpl
  *