Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add what's missing to obey the deprecation warning on add_route with 4 parameters...
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 19 Nov 2023 20:28:08 +0000 (21:28 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 19 Nov 2023 20:28:18 +0000 (21:28 +0100)
include/simgrid/s4u/NetZone.hpp
src/bindings/python/simgrid_python.cpp
teshsuite/python/platform-mix/platform-mix.py

index afe33bd..76125f3 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef SIMGRID_S4U_NETZONE_HPP
 #define SIMGRID_S4U_NETZONE_HPP
 
+#include "simgrid/s4u/Host.hpp"
 #include <simgrid/forward.h>
 #include <simgrid/s4u/Link.hpp>
 #include <xbt/graph.h>
@@ -61,6 +62,7 @@ public:
   /** @brief Get the gateway associated to this netzone */
   kernel::routing::NetPoint* get_gateway() const;
   kernel::routing::NetPoint* get_gateway(const std::string& name) const;
+  void set_gateway(s4u::Host* router) { set_gateway(router->get_netpoint()); }
   void set_gateway(kernel::routing::NetPoint* router);
   void set_gateway(const std::string& name, kernel::routing::NetPoint* router);
 
index 97fa4d3..7cac37d 100644 (file)
@@ -250,11 +250,19 @@ PYBIND11_MODULE(simgrid, m)
       .def("add_route",
            py::overload_cast<const simgrid::s4u::Host*, const simgrid::s4u::Host*,
                              const std::vector<simgrid::s4u::LinkInRoute>&, bool>(&simgrid::s4u::NetZone::add_route),
-           "Add a route between 2 netpoints")
+           "Add a route between 2 hosts")
       .def("add_route",
            py::overload_cast<const simgrid::s4u::Host*, const simgrid::s4u::Host*,
                              const std::vector<const simgrid::s4u::Link*>&>(&simgrid::s4u::NetZone::add_route),
-           "Add a route between 2 netpoints")
+           "Add a route between 2 hosts")
+      .def("add_route",
+           py::overload_cast<const simgrid::s4u::NetZone*, const simgrid::s4u::NetZone*,
+                             const std::vector<simgrid::s4u::LinkInRoute>&, bool>(&simgrid::s4u::NetZone::add_route),
+           "Add a route between 2 netzones. The gateway of each zone gets used.")
+      .def("add_route",
+           py::overload_cast<const simgrid::s4u::NetZone*, const simgrid::s4u::NetZone*,
+                             const std::vector<const simgrid::s4u::Link*>&>(&simgrid::s4u::NetZone::add_route),
+           "Add a route between 2 netzones. The gateway of each zone gets used.")
       .def("create_host", py::overload_cast<const std::string&, double>(&simgrid::s4u::NetZone::create_host),
            "Creates a host")
       .def("create_host",
@@ -286,6 +294,10 @@ PYBIND11_MODULE(simgrid, m)
       .def("create_router", &simgrid::s4u::NetZone::create_router, "Create a router")
       .def("set_parent", &simgrid::s4u::NetZone::set_parent, "Set the parent of this zone")
       .def("set_property", &simgrid::s4u::NetZone::set_property, "Add a property to this zone")
+      .def("set_gateway", py::overload_cast<simgrid::s4u::Host*>(&simgrid::s4u::NetZone::set_gateway),
+           "Specify the gateway of this zone, to be used for inter-zone routes")
+      .def("set_gateway", py::overload_cast<simgrid::kernel::routing::NetPoint*>(&simgrid::s4u::NetZone::set_gateway),
+           "Specify the gateway of this zone, to be used for inter-zone routes")
       .def_property_readonly("netpoint", &simgrid::s4u::NetZone::get_netpoint,
                              "Retrieve the netpoint associated to this zone")
       .def("seal", &simgrid::s4u::NetZone::seal, "Seal this NetZone")
index 5bab3cb..9859b54 100644 (file)
@@ -59,6 +59,7 @@ def load_platform():
     host1.create_disk("disk1", 1e5, 1e4).seal()
     host1.create_disk("disk2", "1MBps", "1Mbps").seal()
     host1.seal()
+    dijkstra.set_gateway(host1)
     host2 = dijkstra.create_host("host2", ["1Gf", "1Mf"]).seal()
     hosts.append(host2)
     link1 = dijkstra.create_link("link1_up", [1e9]).set_latency(1e-3).set_concurrency_limit(10).seal()
@@ -72,6 +73,7 @@ def load_platform():
     this_actor.info(msg_base + vivaldi.name)
     vivaldi.set_parent(root)
     host3 = vivaldi.create_host("host3", 1e9).set_coordinates("1 1 1").seal()
+    vivaldi.set_gateway(host3)
     host4 = vivaldi.create_host("host4", "1Gf").set_coordinates("2 2 2").seal()
     hosts.append(host3)
     hosts.append(host4)
@@ -81,6 +83,7 @@ def load_platform():
     this_actor.info(msg_base + empty.name)
     empty.set_parent(root)
     host5 = empty.create_host("host5", 1e9)
+    empty.set_gateway(host5)
     hosts.append(host5)
     empty.seal()
 
@@ -89,6 +92,7 @@ def load_platform():
     this_actor.info(msg_base + wifi.name)
     wifi.set_parent(root)
     router = wifi.create_router("wifi_router")
+    wifi.set_gateway(router)
     wifi.set_property("access_point", "wifi_router")
     host6 = wifi.create_host(
         "host6", ["100.0Mf", "50.0Mf", "20.0Mf"]).seal()
@@ -101,9 +105,9 @@ def load_platform():
     link_a = vivaldi.create_link("linkA", 1e9).seal()
     link_b = vivaldi.create_link("linkB", "1GBps").seal()
     link_c = vivaldi.create_link("linkC", "1GBps").seal()
-    root.add_route(dijkstra.netpoint, vivaldi.netpoint, host1.netpoint, host3.netpoint, [LinkInRoute(link_a)], True)
-    root.add_route(vivaldi.netpoint, empty.netpoint, host3.netpoint, host5.netpoint, [LinkInRoute(link_b)], True)
-    root.add_route(empty.netpoint, wifi.netpoint, host5.netpoint, router, [LinkInRoute(link_c)], True)
+    root.add_route(dijkstra, vivaldi, [link_a])
+    root.add_route(vivaldi, empty, [link_b])
+    root.add_route(empty, wifi, [link_c])
 
     # create actors Sender/Receiver
     Actor.create("sender", hosts[0], Sender(hosts))