Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Split-Duplex: new management
[simgrid.git] / examples / cpp / clusters-multicpu / s4u-clusters-multicpu.cpp
index 0cf10c4..9feae83 100644 (file)
@@ -20,7 +20,7 @@ class Sender {
   std::vector<sg4::Host*> hosts_;
 
 public:
-  explicit Sender(const std::vector<sg4::Host*> hosts) : hosts_{hosts} {}
+  explicit Sender(const std::vector<sg4::Host*>& hosts) : hosts_{hosts} {}
   void operator()() const
   {
     /* Vector in which we store all ongoing communications */
@@ -47,7 +47,7 @@ public:
     XBT_INFO("Done dispatching all messages");
 
     /* Now that all message exchanges were initiated, wait for their completion in one single call */
-    sg4::Comm::wait_all(&pending_comms);
+    sg4::Comm::wait_all(pending_comms);
 
     XBT_INFO("Goodbye now!");
   }
@@ -110,14 +110,15 @@ create_hostzone(const sg4::NetZone* zone, const std::vector<unsigned int>& /*coo
     /* the first CPU is the gateway */
     if (i == 0)
       gateway = host;
-    /* create 2 links for a full-duplex communication */
-    sg4::Link* link_up   = host_zone->create_link("link-up-" + cpu_name, link_bw)->set_latency(link_lat)->seal();
-    sg4::Link* link_down = host_zone->create_link("link-down-" + cpu_name, link_bw)->set_latency(link_lat)->seal();
-    /* link UP, connection from CPU to outer world */
-    host_zone->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, std::vector<sg4::Link*>{link_up}, false);
-    /* link DOWN, connection from outer to CPU */
-    host_zone->add_route(nullptr, host->get_netpoint(), nullptr, nullptr, std::vector<sg4::Link*>{link_down}, false);
+    /* create split-duplex link */
+    sg4::SplitDuplexLink* link = host_zone->create_split_duplex_link("link-" + cpu_name, link_bw);
+    link->set_latency(link_lat)->seal();
+    /* connecting CPU to outer world */
+    host_zone->add_route(host->get_netpoint(), nullptr, nullptr, nullptr,
+                         std::vector<sg4::LinkInRoute>{{link, sg4::LinkInRoute::Direction::UP}}, true);
   }
+  /* seal newly created netzone */
+  host_zone->seal();
   return std::make_pair(host_zone->get_netpoint(), gateway->get_netpoint());
 }