Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / examples / platforms / griffon.cpp
1 /* Copyright (c) 2006-2023. 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 <numeric>
7 #include <simgrid/s4u.hpp>
8 namespace sg4 = simgrid::s4u;
9
10 /**
11  * @brief Create a new cabinet
12  *
13  * This function creates the cabinet, adding the hosts and links properly.
14  * See figure below for more details of each cabinet
15  *
16  * @param root Root netzone
17  * @param name Cabinet name
18  * @param radicals IDs of nodes inside the cabinet
19  * @return netzone the created netzone
20  */
21 static sg4::NetZone*
22 create_cabinet(const sg4::NetZone* root, const std::string& name, const std::vector<int>& radicals)
23 {
24   auto* cluster      = sg4::create_star_zone(name)->set_parent(root);
25   std::string prefix = "griffon-";
26   std::string suffix = ".nancy.grid5000.fr";
27
28   /* create the backbone link */
29   const sg4::Link* l_bb = cluster->create_link("backbone-" + name, "1.25GBps");
30   sg4::LinkInRoute backbone(l_bb);
31
32   /* create all hosts and connect them to outside world */
33   for (const auto& id : radicals) {
34     std::string hostname = prefix + std::to_string(id) + suffix;
35     /* create host */
36     const sg4::Host* host = cluster->create_host(hostname, "286.087kf");
37     /* create UP/DOWN link */
38     const sg4::Link* link = cluster->create_split_duplex_link(hostname, "125MBps")->set_latency("24us");
39
40     /* add link and backbone for communications from the host */
41     cluster->add_route(host, nullptr, {{link, sg4::LinkInRoute::Direction::UP}, backbone}, true);
42   }
43
44   /* create gateway */
45   cluster->set_gateway(cluster->create_router(prefix + name + "-router" + suffix));
46
47   cluster->seal();
48   return cluster;
49 }
50
51 /** @brief Programmatic version of griffon.xml */
52 extern "C" void load_platform(const sg4::Engine& e);
53 void load_platform(const sg4::Engine& /*e*/)
54 {
55   /**
56    * C++ version of griffon.xml
57    * Old Grid5000 cluster (not available anymore): 3 cabinets containing homogeneous nodes connected through a backbone
58    *                                  1.25GBps shared link
59    *                          ___________________________________
60    *          1              /                |                  \
61    *                        /                 |                   \
62    *                       /                  |                    \
63    *     ________________ /             ______|__________           \_________________
64    *     |               |              |               |            |               |
65    *     | cab1 router   |              | cab2 router   |            | cab3 router   |
66    *     |_______________|              |_______________|            |_______________|
67    *     ++++++++++++++++               ++++++++++++++++             ++++++++++++++++++  <-- 1.25 backbone
68    *     / /   | |    \ \              / /    | |    \ \             / /     | |     \ \
69    *    / /    | |     \ \            / /     | |     \ \           / /      | |      \ \ <-- 125Mbps links
70    *   / /     | |      \ \          / /      | |      \ \         / /       | |       \ \
71    * host1     ...      hostN      host1      ...      hostM      host1      ...       hostQ
72    */
73
74   auto* root = sg4::create_star_zone("AS_griffon");
75   sg4::NetZone* cab_zone;
76
77   /* create top link */
78   const sg4::Link* l_bb = root->create_link("backbone", "1.25GBps")->set_latency("24us")->seal();
79   sg4::LinkInRoute backbone{l_bb};
80
81   /* create cabinet1 */
82   std::vector<int> rad(32);
83   std::iota(rad.begin(), rad.end(), 1); // 1-29,58,59,60
84   rad[rad.size() - 1]  = 60;
85   rad[rad.size() - 2]  = 59;
86   rad[rad.size() - 3]  = 58;
87   cab_zone             = create_cabinet(root, "cabinet1", rad);
88   root->add_route(cab_zone, nullptr, {backbone});
89
90   /* create cabinet2 */
91   rad.resize(28);
92   std::iota(rad.begin(), rad.end(), 30); // 30-57
93   cab_zone = create_cabinet(root, "cabinet2", rad);
94   root->add_route(cab_zone, nullptr, {backbone});
95
96   /* create cabinet3 */
97   rad.resize(32);
98   std::iota(rad.begin(), rad.end(), 61); // 61-92
99   cab_zone = create_cabinet(root, "cabinet3", rad);
100   root->add_route(cab_zone, nullptr, {backbone});
101
102   root->seal();
103 }