Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d10b4154dbe3c7f23dbf635b270351a71662af2a
[simgrid.git] / examples / s4u / routing-get-clusters / s4u-routing-get-clusters.cpp
1 /* Copyright (c) 2009-2018. 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
12 int main(int argc, char* argv[])
13 {
14   simgrid::s4u::Engine e(&argc, argv);
15   e.load_platform(argv[1]);
16
17   std::vector<simgrid::kernel::routing::ClusterZone*>* clusters =
18       new std::vector<simgrid::kernel::routing::ClusterZone*>;
19
20   e.getNetzoneByType<simgrid::kernel::routing::ClusterZone>(clusters);
21
22   for (auto c : *clusters) {
23     XBT_INFO("%s", c->get_cname());
24     std::vector<simgrid::s4u::Host*>* hosts = new std::vector<simgrid::s4u::Host*>;
25     c->getHosts(hosts);
26     for (auto h : *hosts)
27       XBT_INFO("   %s", h->get_cname());
28     delete hosts;
29   }
30
31   delete clusters;
32
33   std::vector<simgrid::kernel::routing::DragonflyZone*>* dragonfly_clusters =
34       new std::vector<simgrid::kernel::routing::DragonflyZone*>;
35
36   e.getNetzoneByType<simgrid::kernel::routing::DragonflyZone>(dragonfly_clusters);
37
38   if (not dragonfly_clusters->empty()) {
39     for (auto d : *dragonfly_clusters) {
40       XBT_INFO("%s' dragonfly topology:", d->get_cname());
41       for (int i = 0; i < d->getHostCount(); i++) {
42         unsigned int coords[4];
43         d->rankId_to_coords(i, coords);
44         XBT_INFO("   %d: (%u, %u, %u, %u)", i, coords[0], coords[1], coords[2], coords[3]);
45       }
46     }
47   }
48   delete dragonfly_clusters;
49
50   return 0;
51 }