Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
have a on_completion per activity type to save users some dynamic_cast-based filtering
[simgrid.git] / examples / cpp / clusters-multicpu / s4u-clusters-multicpu.cpp
index 18c1184fe4a492d2cbc6d3cbc2c0a2f9cb22e32c..f0c2b7eddfc8d53e1c14103a81341c50fec5a643 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -30,8 +30,7 @@ public:
     std::vector<sg4::Mailbox*> mboxes;
 
     /* Start dispatching 1 message to all receivers */
-    std::string msg_content =
-        std::string("Hello, I'm alive and running on ") + std::string(sg4::this_actor::get_host()->get_name());
+    std::string msg_content = "Hello, I'm alive and running on " + sg4::this_actor::get_host()->get_name();
     for (const auto* host : hosts_) {
       /* Copy the data we send: the 'msg_content' variable is not a stable storage location.
        * It will be destroyed when this actor leaves the loop, ie before the receiver gets it */
@@ -102,14 +101,14 @@ create_hostzone(const sg4::NetZone* zone, const std::vector<unsigned long>& /*co
   /* setting my Torus parent zone */
   host_zone->set_parent(zone);
 
-  const sg4::Host* gateway = nullptr;
+  simgrid::kernel::routing::NetPoint* gateway = nullptr;
   /* 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();
     /* the first CPU is the gateway */
     if (i == 0)
-      gateway = host;
+      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();
@@ -119,7 +118,7 @@ create_hostzone(const sg4::NetZone* zone, const std::vector<unsigned long>& /*co
   }
   /* seal newly created netzone */
   host_zone->seal();
-  return std::make_pair(host_zone->get_netpoint(), gateway->get_netpoint());
+  return std::make_pair(host_zone->get_netpoint(), gateway);
 }
 
 /*************************************************************************************************/
@@ -293,10 +292,9 @@ static void create_dragonfly_cluster()
 int main(int argc, char* argv[])
 {
   sg4::Engine e(&argc, argv);
-  std::string platform = argv[1];
 
   /* create platform */
-  if (platform == "torus")
+  if (std::string platform(argv[1]); platform == "torus")
     create_torus_cluster();
   else if (platform == "fatTree")
     create_fatTree_cluster();
@@ -308,7 +306,7 @@ int main(int argc, char* argv[])
   sg4::Actor::create("sender", host_list[0], Sender(host_list));
   /* create receiver in every host */
   for (auto* host : host_list) {
-    sg4::Actor::create(std::string("receiver-") + std::string(host->get_name()), host, Receiver());
+    sg4::Actor::create("receiver-" + host->get_name(), host, Receiver());
   }
 
   /* runs the simulation */