Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further progress towards deprecation of complex add_route
authorFred Suter <suterf@ornl.gov>
Sun, 24 Sep 2023 19:23:51 +0000 (15:23 -0400)
committerFred Suter <suterf@ornl.gov>
Sun, 24 Sep 2023 21:38:52 +0000 (17:38 -0400)
16 files changed:
examples/cpp/clusters-multicpu/s4u-clusters-multicpu.cpp
examples/cpp/network-factors/s4u-network-factors.cpp
examples/cpp/plugin-jbod/s4u-plugin-jbod.cpp
examples/cpp/plugin-prodcons/s4u-plugin-prodcons.cpp
examples/platforms/griffon.cpp
examples/platforms/routing_cluster.cpp
include/simgrid/s4u/NetZone.hpp
src/kernel/routing/DijkstraZone_test.cpp
src/kernel/routing/FloydZone_test.cpp
src/kernel/routing/FullZone_test.cpp
src/kernel/routing/StarZone_test.cpp
src/kernel/xml/sg_platf.cpp
src/s4u/s4u_Netzone.cpp
teshsuite/s4u/io-stream/io-stream.cpp
teshsuite/s4u/seal-platform/seal-platform.cpp
teshsuite/s4u/seal-platform/seal-platform.tesh

index 2a98162..8ef6337 100644 (file)
@@ -105,16 +105,14 @@ create_hostzone(const sg4::NetZone* zone, const std::vector<unsigned long>& /*co
   /* create CPUs */
   for (int i = 0; i < num_cpus; i++) {
     std::string cpu_name  = hostname + "-cpu" + std::to_string(i);
-    const sg4::Host* host = host_zone->create_host(cpu_name, speed)->seal();
+    const sg4::Host* host = host_zone->create_host(cpu_name, speed);
     /* the first CPU is the gateway */
     if (i == 0)
       gateway = host->get_netpoint();
     /* create split-duplex link */
-    sg4::SplitDuplexLink* link = host_zone->create_split_duplex_link("link-" + cpu_name, link_bw);
-    link->set_latency(link_lat)->seal();
+    auto* link = host_zone->create_split_duplex_link("link-" + cpu_name, link_bw)->set_latency(link_lat);
     /* connecting CPU to outer world */
-    host_zone->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, {{link, sg4::LinkInRoute::Direction::UP}},
-                         true);
+    host_zone->add_route(host, nullptr, {{link, sg4::LinkInRoute::Direction::UP}}, true);
   }
   /* seal newly created netzone */
   host_zone->seal();
index 7cb9437..83b9cf2 100644 (file)
@@ -71,14 +71,14 @@ static void load_platform()
   for (int id = 0; id < 32; id++) {
     std::string hostname = prefix + std::to_string(id) + suffix;
     /* create host */
-    const sg4::Host* host = root->create_host(hostname, 1)->set_core_count(32)->seal();
+    const sg4::Host* host = root->create_host(hostname, 1)->set_core_count(32);
     /* create UP/DOWN link */
-    const sg4::Link* l = root->create_split_duplex_link(hostname, BW_REMOTE)->set_latency(LATENCY)->seal();
+    const sg4::Link* l = root->create_split_duplex_link(hostname, BW_REMOTE)->set_latency(LATENCY);
 
     /* add link UP/DOWN for communications from the host */
-    root->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, {{l, sg4::LinkInRoute::Direction::UP}}, true);
+    root->add_route(host, nullptr, {{l, sg4::LinkInRoute::Direction::UP}}, true);
 
-    sg4::Link* loopback = root->create_link(hostname + "_loopback", BW_LOCAL)->set_latency(LATENCY)->seal();
+    sg4::Link* loopback = root->create_link(hostname + "_loopback", BW_LOCAL)->set_latency(LATENCY);
     root->add_route(host, host, {loopback});
   }
 
index 67e0b5c..5f6b4ab 100644 (file)
@@ -41,23 +41,23 @@ int main(int argc, char** argv)
 
   auto* jbod_raid0 =
     simgrid::plugin::Jbod::create_jbod(zone, "jbod_raid0", 1e9, 4, simgrid::plugin::Jbod::RAID::RAID0, 1e7, 5e6);
-  zone->add_route(host->get_netpoint(), jbod_raid0->get_netpoint(), nullptr, nullptr, {sg4::LinkInRoute(link)});
+  zone->add_route(host, jbod_raid0, {link});
 
   auto* jbod_raid1 =
     simgrid::plugin::Jbod::create_jbod(zone, "jbod_raid1", 1e9, 4, simgrid::plugin::Jbod::RAID::RAID1, 1e7, 5e6);
-  zone->add_route(host->get_netpoint(), jbod_raid1->get_netpoint(), nullptr, nullptr, {sg4::LinkInRoute(link)});
+  zone->add_route(host, jbod_raid1, {link});
 
   auto* jbod_raid4 =
     simgrid::plugin::Jbod::create_jbod(zone, "jbod_raid4", 1e9, 4, simgrid::plugin::Jbod::RAID::RAID4, 1e7, 5e6);
-  zone->add_route(host->get_netpoint(), jbod_raid4->get_netpoint(), nullptr, nullptr, {sg4::LinkInRoute(link)});
+  zone->add_route(host, jbod_raid4, {link});
 
   auto* jbod_raid5 =
     simgrid::plugin::Jbod::create_jbod(zone, "jbod_raid5", 1e9, 4, simgrid::plugin::Jbod::RAID::RAID5, 1e7, 5e6);
-  zone->add_route(host->get_netpoint(), jbod_raid5->get_netpoint(), nullptr, nullptr, {sg4::LinkInRoute(link)});
+  zone->add_route(host, jbod_raid5, {link});
 
   auto* jbod_raid6 =
     simgrid::plugin::Jbod::create_jbod(zone, "jbod_raid6", 1e9, 4, simgrid::plugin::Jbod::RAID::RAID6, 1e7, 5e6);
-  zone->add_route(host->get_netpoint(), jbod_raid6->get_netpoint(), nullptr, nullptr, {sg4::LinkInRoute(link)});
+  zone->add_route(host, jbod_raid6, {link});
 
   zone->seal();
 
index ee7a3ce..8d1ceeb 100644 (file)
@@ -65,13 +65,8 @@ int main(int argc, char* argv[])
     std::string linkname = "cluster_link_" + std::to_string(i);
     const auto* link     = cluster->create_split_duplex_link(linkname, "1Gbps");
 
-    cluster->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, {{link, sg4::LinkInRoute::Direction::UP}},
-                       true);
+    cluster->add_route(host, nullptr,  {{link, sg4::LinkInRoute::Direction::UP}}, true);
   }
-
-  auto* router = cluster->create_router("cluster_router");
-  std::vector<sg4::LinkInRoute> links; // empty
-  cluster->add_route(router, nullptr, nullptr, nullptr, links);
   cluster->seal();
 
   simgrid::plugin::ProducerConsumerPtr<int> pc = simgrid::plugin::ProducerConsumer<int>::create(2);
index a66a8bb..04a83e6 100644 (file)
@@ -38,8 +38,7 @@ create_cabinet(const sg4::NetZone* root, const std::string& name, const std::vec
     const sg4::Link* link = cluster->create_split_duplex_link(hostname, "125MBps")->set_latency("24us");
 
     /* add link and backbone for communications from the host */
-    cluster->add_route(host->get_netpoint(), nullptr, nullptr, nullptr,
-                       {{link, sg4::LinkInRoute::Direction::UP}, backbone}, true);
+    cluster->add_route(host, nullptr, {{link, sg4::LinkInRoute::Direction::UP}, backbone}, true);
   }
 
   /* create gateway */
index 0f51172..b7b218f 100644 (file)
@@ -40,9 +40,9 @@ static sg4::NetZone* create_cluster(const sg4::NetZone* root, const std::string&
     sg4::LinkInRoute link_down{l_down};
 
     /* add link UP and backbone for communications from the host */
-    cluster->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, {link_up, backbone}, false);
+    cluster->add_route(host, nullptr, {link_up, backbone}, false);
     /* add backbone and link DOWN for communications to the host */
-    cluster->add_route(nullptr, host->get_netpoint(), nullptr, nullptr, {backbone, link_down}, false);
+    cluster->add_route(nullptr, host, {backbone, link_down}, false);
   }
 
   /* create gateway*/
index 00430d2..b272312 100644 (file)
@@ -77,7 +77,7 @@ public:
    * @param dst Destination netzone
    * @param link_list List of links
    */
-  void add_route(NetZone* src, NetZone* dst, const std::vector<const Link*>& links);
+  void add_route(const NetZone* src, const NetZone* dst, const std::vector<const Link*>& links);
 
 /**
    * @brief Add a route between 2 netzones, and same in other direction
@@ -86,7 +86,7 @@ public:
    * @param link_list List of links and their direction used in this communication
    * @param symmetrical Bi-directional communication
    */
-  void add_route(NetZone* src, NetZone* dst, const std::vector<LinkInRoute>& link_list, bool symmetrical = true);
+  void add_route(const NetZone* src, const NetZone* dst, const std::vector<LinkInRoute>& link_list, bool symmetrical = true);
 
   /**
    * @brief Add a route between 2 netpoints
@@ -102,6 +102,7 @@ public:
    * @param link_list List of links and their direction used in this communication
    * @param symmetrical Bi-directional communication
    */
+  //XBT_ATTRIB_DEPRECATED_v339("Please call add_route either from Host to Host or NetZone to NetZone")
   void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src,
                  kernel::routing::NetPoint* gw_dst, const std::vector<LinkInRoute>& link_list, bool symmetrical = true);
   /**
@@ -117,7 +118,8 @@ public:
    * @param gw_dst Netpoint of the gateway in the destination netzone
    * @param link_list List of links
    */
-  void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src,
+ //XBT_ATTRIB_DEPRECATED_v339("Please call add_route either from Host to Host or NetZone to NetZone")
+ void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src,
                  kernel::routing::NetPoint* gw_dst, const std::vector<const Link*>& links);
 
   /**
index 379f431..9a1c89a 100644 (file)
@@ -30,7 +30,6 @@ TEST_CASE("kernel::routing::DijkstraZone: mix new routes and hosts", "")
   for (int i = 0; i < 10; i++) {
     std::string cpu_name          = "CPU" + std::to_string(i);
     const simgrid::s4u::Host* cpu = zone->create_host(cpu_name, 1e9)->seal();
-    REQUIRE_NOTHROW(zone->add_route(cpu->get_netpoint(), nic->get_netpoint(), nullptr, nullptr,
-                                    {simgrid::s4u::LinkInRoute(link)}, true));
+    REQUIRE_NOTHROW(zone->add_route(cpu, nic,{link}));
   }
 }
index e0c751b..f4fbe4a 100644 (file)
@@ -24,12 +24,11 @@ TEST_CASE("kernel::routing::FloydZone: mix new routes and hosts", "")
   simgrid::s4u::Engine e("test");
   auto* zone = simgrid::s4u::create_floyd_zone("test");
 
-  const simgrid::s4u::Host* nic  = zone->create_host("nic", 1e9)->seal();
-  const simgrid::s4u::Link* link = zone->create_link("my_link", 1e6)->seal();
+  const simgrid::s4u::Host* nic  = zone->create_host("nic", 1e9);
+  const simgrid::s4u::Link* link = zone->create_link("my_link", 1e6);
   for (int i = 0; i < 10; i++) {
     std::string cpu_name          = "CPU" + std::to_string(i);
-    const simgrid::s4u::Host* cpu = zone->create_host(cpu_name, 1e9)->seal();
-    REQUIRE_NOTHROW(zone->add_route(cpu->get_netpoint(), nic->get_netpoint(), nullptr, nullptr,
-                                    {simgrid::s4u::LinkInRoute(link)}, true));
+    const simgrid::s4u::Host* cpu = zone->create_host(cpu_name, 1e9);
+    REQUIRE_NOTHROW(zone->add_route(cpu, nic, {link}));
   }
 }
index 1be4da6..9ffcab7 100644 (file)
@@ -24,12 +24,11 @@ TEST_CASE("kernel::routing::FullZone: mix new routes and hosts", "[bug]")
   simgrid::s4u::Engine e("test");
   auto* zone = simgrid::s4u::create_full_zone("test");
 
-  const simgrid::s4u::Host* nic  = zone->create_host("nic", 1e9)->seal();
-  const simgrid::s4u::Link* link = zone->create_link("my_link", 1e6)->seal();
+  const simgrid::s4u::Host* nic  = zone->create_host("nic", 1e9);
+  const simgrid::s4u::Link* link = zone->create_link("my_link", 1e6);
   for (int i = 0; i < 10; i++) {
     std::string cpu_name          = "CPU" + std::to_string(i);
-    const simgrid::s4u::Host* cpu = zone->create_host(cpu_name, 1e9)->seal();
-    REQUIRE_NOTHROW(zone->add_route(cpu->get_netpoint(), nic->get_netpoint(), nullptr, nullptr,
-                                    {simgrid::s4u::LinkInRoute(link)}, true));
+    const simgrid::s4u::Host* cpu = zone->create_host(cpu_name, 1e9);
+    REQUIRE_NOTHROW(zone->add_route(cpu, nic, {link}));
   }
 }
index 66dac29..4c7ff4d 100644 (file)
@@ -287,7 +287,6 @@ TEST_CASE("kernel::routing::StarZone: mix new routes and hosts", "")
   for (int i = 0; i < 10; i++) {
     std::string cpu_name          = "CPU" + std::to_string(i);
     const simgrid::s4u::Host* cpu = zone->create_host(cpu_name, 1e9)->seal();
-    REQUIRE_NOTHROW(
-        zone->add_route(cpu->get_netpoint(), nullptr, nullptr, nullptr, {simgrid::s4u::LinkInRoute(link)}, true));
+    REQUIRE_NOTHROW(zone->add_route(cpu, nullptr, {link}));
   }
 }
index 3d85fe3..3dd5269 100644 (file)
@@ -293,8 +293,7 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA
                                  ->set_latency(cluster->loopback_lat)
                                  ->seal();
 
-      zone->add_route(host->get_netpoint(), host->get_netpoint(), nullptr, nullptr,
-                      {simgrid::s4u::LinkInRoute(loopback)});
+      zone->add_route(host, host, {simgrid::s4u::LinkInRoute(loopback)});
     }
 
     // add a limiter link (shared link to account for maximal bandwidth of the node)
@@ -322,7 +321,7 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA
     if (backbone)
       links.emplace_back(backbone);
 
-    zone->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, links, true);
+    zone->add_route(host, nullptr, links, true);
   }
 
   // Add a router.
@@ -330,9 +329,7 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA
   XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id.c_str());
   if (cluster->router_id.empty())
     cluster->router_id = cluster->prefix + cluster->id + "_router" + cluster->suffix;
-  auto* router = zone->create_router(cluster->router_id);
-  std::vector<simgrid::s4u::LinkInRoute> links;
-  zone->add_route(router, nullptr, nullptr, nullptr, links);
+  zone->create_router(cluster->router_id);
 
   simgrid::kernel::routing::on_cluster_creation(*cluster);
 }
index 2c335d0..48377bb 100644 (file)
@@ -85,7 +85,7 @@ unsigned long NetZone::add_component(kernel::routing::NetPoint* elm)
   return pimpl_->add_component(elm);
 }
 
-void NetZone::add_route(NetZone* src, NetZone* dst, const std::vector<const Link*>& links)
+void NetZone::add_route(const NetZone* src, const NetZone* dst, const std::vector<const Link*>& links)
 {
   std::vector<LinkInRoute> links_direct;
   std::vector<LinkInRoute> links_reverse;
@@ -101,7 +101,7 @@ void NetZone::add_route(NetZone* src, NetZone* dst, const std::vector<const Link
                     links_reverse, false);
 }
 
-void NetZone::add_route(NetZone* src, NetZone* dst, const std::vector<LinkInRoute>& link_list, bool symmetrical)
+void NetZone::add_route(const NetZone* src, const NetZone* dst, const std::vector<LinkInRoute>& link_list, bool symmetrical)
 {
   pimpl_->add_route(src ? src->get_netpoint() : nullptr, dst ? dst->get_netpoint(): nullptr,
                     src ? src->get_gateway() : nullptr, dst ? dst->get_gateway() : nullptr,
@@ -110,14 +110,14 @@ void NetZone::add_route(NetZone* src, NetZone* dst, const std::vector<LinkInRout
 
 void NetZone::add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
                         kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
-                        const std::vector<LinkInRoute>& link_list, bool symmetrical)
+                        const std::vector<LinkInRoute>& link_list, bool symmetrical) //XBT_ATTRIB_DEPRECATED_v339
 {
   pimpl_->add_route(src, dst, gw_src, gw_dst, link_list, symmetrical);
 }
 
 void NetZone::add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
                         kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
-                        const std::vector<const Link*>& links)
+                        const std::vector<const Link*>& links) //XBT_ATTRIB_DEPRECATED_v339
 {
   std::vector<LinkInRoute> links_direct;
   std::vector<LinkInRoute> links_reverse;
index e3eb658..6977fbc 100644 (file)
@@ -106,8 +106,8 @@ int main(int argc, char** argv)
   auto* bob  = zone->create_host("bob", 1e6);
   auto* alice  = zone->create_host("alice", 1e6);
 
-  sg4::LinkInRoute link(zone->create_link("link", "2MBps")->set_latency("50us")->seal());
-  zone->add_route(bob->get_netpoint(), alice->get_netpoint(), nullptr, nullptr, {link}, true);
+  auto* link = zone->create_link("link", "2MBps")->set_latency("50us");
+  zone->add_route(bob, alice, {link});
 
   bob->create_disk("bob_disk", "1MBps", "500kBps");
   alice->create_disk("alice_disk", "4MBps", "4MBps");
index 3b7d79a..d32d2d9 100644 (file)
@@ -6,7 +6,7 @@
 #include "simgrid/s4u.hpp"
 namespace sg4 = simgrid::s4u;
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_torus_multicpu, "Messages specific for this s4u example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(seal_platform, "Messages specific for this s4u example");
 
 class Sender {
   long msg_size = 1e6; /* message size in bytes */
@@ -58,17 +58,16 @@ public:
 /*************************************************************************************************/
 static sg4::NetZone* create_zone(const sg4::NetZone* root, const std::string& id)
 {
-  auto* zone = sg4::create_floyd_zone(id);
-  zone->set_parent(root);
+  auto* zone = sg4::create_star_zone(id)->set_parent(root);
   constexpr int n_host = 2;
 
-  auto* router = zone->create_router("router" + id);
+  zone->set_gateway(zone->create_router("router" + id));
   for (int i = 0; i < n_host; i++) {
     std::string hostname = id + "-cpu-" + std::to_string(i);
     auto* host           = zone->create_host(hostname, 1e9);
     host->create_disk("disk-" + hostname, 1e9, 1e6);
     const auto* link = zone->create_link("link-" + hostname, 1e9);
-    zone->add_route(host->get_netpoint(), router, nullptr, nullptr, {link});
+    zone->add_route(host, nullptr, {link});
   }
   return zone;
 }
@@ -84,8 +83,7 @@ int main(int argc, char* argv[])
   auto* zoneA = create_zone(root, "A");
   auto* zoneB = create_zone(root, "B");
   const auto* link = root->create_link("root-link", 1e10);
-  root->add_route(zoneA->get_netpoint(), zoneB->get_netpoint(), e.netpoint_by_name("routerA"),
-                  e.netpoint_by_name("routerB"), {sg4::LinkInRoute(link)});
+  root->add_route(zoneA, zoneB, {sg4::LinkInRoute(link)}, true);
 
   std::vector<sg4::Host*> host_list = e.get_all_hosts();
   /* create the sender actor running on first host */
index 11ea6df..187501c 100644 (file)
@@ -1,11 +1,11 @@
 $ ./seal-platform
-> [A-cpu-0:sender:(1) 0.000000] [s4u_torus_multicpu/INFO] Done dispatching all messages
-> [A-cpu-0:receiver-A-cpu-0:(2) 0.000103] [s4u_torus_multicpu/INFO] I got a 'Hello, I'm alive and running on A-cpu-0'.
-> [B-cpu-1:receiver-B-cpu-1:(5) 0.003247] [s4u_torus_multicpu/INFO] I got a 'Hello, I'm alive and running on A-cpu-0'.
-> [B-cpu-0:receiver-B-cpu-0:(4) 0.003247] [s4u_torus_multicpu/INFO] I got a 'Hello, I'm alive and running on A-cpu-0'.
-> [A-cpu-1:receiver-A-cpu-1:(3) 0.003247] [s4u_torus_multicpu/INFO] I got a 'Hello, I'm alive and running on A-cpu-0'.
-> [A-cpu-0:sender:(1) 0.003247] [s4u_torus_multicpu/INFO] Goodbye now!
-> [A-cpu-0:receiver-A-cpu-0:(2) 4.000103] [s4u_torus_multicpu/INFO] Wrote 4000000 bytes on 'disk-A-cpu-0'
-> [B-cpu-1:receiver-B-cpu-1:(5) 4.003247] [s4u_torus_multicpu/INFO] Wrote 4000000 bytes on 'disk-B-cpu-1'
-> [B-cpu-0:receiver-B-cpu-0:(4) 4.003247] [s4u_torus_multicpu/INFO] Wrote 4000000 bytes on 'disk-B-cpu-0'
-> [A-cpu-1:receiver-A-cpu-1:(3) 4.003247] [s4u_torus_multicpu/INFO] Wrote 4000000 bytes on 'disk-A-cpu-1'
+> [A-cpu-0:sender:(1) 0.000000] [seal_platform/INFO] Done dispatching all messages
+> [B-cpu-1:receiver-B-cpu-1:(5) 0.004330] [seal_platform/INFO] I got a 'Hello, I'm alive and running on A-cpu-0'.
+> [B-cpu-0:receiver-B-cpu-0:(4) 0.004330] [seal_platform/INFO] I got a 'Hello, I'm alive and running on A-cpu-0'.
+> [A-cpu-1:receiver-A-cpu-1:(3) 0.004330] [seal_platform/INFO] I got a 'Hello, I'm alive and running on A-cpu-0'.
+> [A-cpu-0:receiver-A-cpu-0:(2) 0.004330] [seal_platform/INFO] I got a 'Hello, I'm alive and running on A-cpu-0'.
+> [A-cpu-0:sender:(1) 0.004330] [seal_platform/INFO] Goodbye now!
+> [B-cpu-1:receiver-B-cpu-1:(5) 4.004330] [seal_platform/INFO] Wrote 4000000 bytes on 'disk-B-cpu-1'
+> [B-cpu-0:receiver-B-cpu-0:(4) 4.004330] [seal_platform/INFO] Wrote 4000000 bytes on 'disk-B-cpu-0'
+> [A-cpu-1:receiver-A-cpu-1:(3) 4.004330] [seal_platform/INFO] Wrote 4000000 bytes on 'disk-A-cpu-1'
+> [A-cpu-0:receiver-A-cpu-0:(2) 4.004330] [seal_platform/INFO] Wrote 4000000 bytes on 'disk-A-cpu-0'
\ No newline at end of file