Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update python/clusters-multicpu to the new API.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 21 Nov 2023 13:17:27 +0000 (14:17 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 21 Nov 2023 14:40:42 +0000 (15:40 +0100)
examples/python/clusters-multicpu/clusters-multicpu.py
src/bindings/python/simgrid_python.cpp

index 0d6ff44..6a4d783 100644 (file)
@@ -58,8 +58,7 @@ class Receiver:
 #####################################################################################################
 
 
-def create_hostzone(zone: simgrid.NetZone, coord: typing.List[int], ident: int) -> typing.Tuple[simgrid.NetPoint,
-                                                                                                simgrid.NetPoint]:
+def create_hostzone(zone: simgrid.NetZone, coord: typing.List[int], ident: int) -> simgrid.NetZone:
     r"""
     Callback to set a cluster leaf/element
 
@@ -94,14 +93,13 @@ def create_hostzone(zone: simgrid.NetZone, coord: typing.List[int], ident: int)
     # setting my Torus parent zone
     host_zone.set_parent(zone)
 
-    gateway = None
     # create CPUs
     for i in range(num_cpus):
         cpu_name = hostname + "-cpu" + str(i)
         host = host_zone.create_host(cpu_name, speed).seal()
         # the first CPU is the gateway
         if i == 0:
-            gateway = host.netpoint
+            host_zone.set_gateway(host.netpoint)
         # create split-duplex link
         link = host_zone.create_split_duplex_link("link-" + cpu_name, link_bw)
         link.set_latency(link_lat).seal()
@@ -110,7 +108,7 @@ def create_hostzone(zone: simgrid.NetZone, coord: typing.List[int], ident: int)
 
     # seal newly created netzone
     host_zone.seal()
-    return host_zone.netpoint, gateway
+    return host_zone
 
 #####################################################################################################
 
index 6d6f5c1..c06da84 100644 (file)
@@ -309,7 +309,7 @@ PYBIND11_MODULE(simgrid, m)
 
   /* Class ClusterCallbacks */
   py::class_<simgrid::s4u::ClusterCallbacks>(m, "ClusterCallbacks", "Callbacks used to create cluster zones")
-      .def(py::init<const std::function<simgrid::s4u::ClusterCallbacks::ClusterNetPointCb>&,
+      .def(py::init<const std::function<simgrid::s4u::ClusterCallbacks::ClusterNetZoneCb>&,
                     const std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb>&,
                     const std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb>&>());