Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dfa6a93a9d68639fe767b4277c74c4e0c92c09b0
[simgrid.git] / examples / cpp / routing-get-clusters / s4u-routing-get-clusters.cpp
1 /* Copyright (c) 2009-2022. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "simgrid/kernel/routing/ClusterZone.hpp"
7 #include "simgrid/kernel/routing/DragonflyZone.hpp"
8 #include "simgrid/s4u.hpp"
9
10 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
11 namespace sg4 = simgrid::s4u;
12
13 int main(int argc, char* argv[])
14 {
15   sg4::Engine e(&argc, argv);
16   e.load_platform(argv[1]);
17
18   std::vector<simgrid::kernel::routing::ClusterZone*> clusters =
19       e.get_filtered_netzones<simgrid::kernel::routing::ClusterZone>();
20
21   for (auto c : clusters) {
22     XBT_INFO("%s", c->get_cname());
23     std::vector<sg4::Host*> hosts = c->get_all_hosts();
24     for (auto h : hosts)
25       XBT_INFO("   %s", h->get_cname());
26   }
27
28   std::vector<simgrid::kernel::routing::DragonflyZone*> dragonfly_clusters =
29       e.get_filtered_netzones<simgrid::kernel::routing::DragonflyZone>();
30
31   for (auto d : dragonfly_clusters) {
32     XBT_INFO("%s' dragonfly topology:", d->get_cname());
33     for (size_t i = 0; i < d->get_host_count(); i++) {
34       const simgrid::kernel::routing::DragonflyZone::Coords coords = d->rankId_to_coords(i);
35       XBT_INFO("   %zu: (%lu, %lu, %lu, %lu)", i, coords.group, coords.chassis, coords.blade, coords.node);
36     }
37   }
38
39   return 0;
40 }