1 /* Copyright (c) 2006-2021. The SimGrid Team. All rights reserved. */
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. */
6 #include <simgrid/s4u.hpp>
7 namespace sg4 = simgrid::s4u;
10 * @brief Create the hosts in the platform
12 * @param zone Zone to insert the hosts
14 static void create_sp_hosts(sg4::NetZone* zone)
16 zone->create_host("Tremblay", {"98.095Mf"})->seal();
17 zone->create_host("Jupiter", {"76.296Mf"})->seal();
18 zone->create_host("Fafard", {"76.296Mf"})->seal();
19 zone->create_host("Ginette", {"48.492Mf"})->seal();
20 zone->create_host("Bourassa", {"48.492Mf"})->seal();
21 zone->create_host("Jacquelin", {"137.333Mf"})->seal();
22 zone->create_host("Boivin", {"98.095Mf"})->seal();
26 * @brief Create the links in the platform
28 * They'll be used later in the routes.
32 static void create_sp_links(sg4::NetZone* zone)
34 zone->create_link("6", {"41.279125MBps"})->set_latency("59.904us")->seal();
35 zone->create_link("3", {"34.285625MBps"})->set_latency("514.433us")->seal();
36 zone->create_link("7", {"11.618875MBps"})->set_latency("189.98us")->seal();
37 zone->create_link("9", {"7.20975MBps"})->set_latency("1.461517ms")->seal();
38 zone->create_link("2", {"118.6825MBps"})->set_latency("136.931us")->seal();
39 zone->create_link("8", {"8.158MBps"})->set_latency("270.544us")->seal();
40 zone->create_link("1", {"34.285625MBps"})->set_latency("514.433us")->seal();
41 zone->create_link("4", {"10.099625MBps"})->set_latency("479.78us")->seal();
42 zone->create_link("0", {"41.279125MBps"})->set_latency("59.904us")->seal();
43 zone->create_link("5", {"27.94625MBps"})->set_latency("278.066us")->seal();
44 zone->create_link("145", {"2.583375MBps"})->set_latency("410.463us")->seal();
45 zone->create_link("10", {"34.285625MBps"})->set_latency("514.433us")->seal();
46 zone->create_link("11", {"118.6825MBps"})->set_latency("136.931us")->seal();
47 zone->create_link("16", {"34.285625MBps"})->set_latency("514.433us")->seal();
48 zone->create_link("17", {"118.6825MBps"})->set_latency("136.931us")->seal();
49 zone->create_link("44", {"10.314625MBps"})->set_latency("6.932556ms")->seal();
50 zone->create_link("47", {"10.314625MBps"})->set_latency("6.932556ms")->seal();
51 zone->create_link("54", {"15.376875MBps"})->set_latency("35.083019ms")->seal();
52 zone->create_link("56", {"21.41475MBps"})->set_latency("29.5890617ms")->seal();
53 zone->create_link("59", {"11.845375MBps"})->set_latency("370.788us")->seal();
54 zone->create_link("78", {"27.94625MBps"})->set_latency("278.066us")->seal();
55 zone->create_link("79", {"8.42725MBps"})->set_latency("156.056us")->seal();
56 zone->create_link("80", {"15.376875MBps"})->set_latency("35.083019ms")->seal();
58 /* single FATPIPE links for loopback */
59 zone->create_link("loopback", {"498MBps"})
61 ->set_sharing_policy(sg4::Link::SharingPolicy::FATPIPE)
66 * @brief Auxiliary function to create a single route
68 * It translates the parameters from string to proper API
70 * @param src Source hostname
71 * @param dst Destination hostname
72 * @param links List of links to use in this route
74 static void create_single_route(const sg4::Engine& e, std::string const& src, std::string const& dst,
75 std::vector<std::string> const& links)
77 std::vector<sg4::Link*> link_list;
78 for (auto& link : links) {
79 link_list.push_back(e.link_by_name(link));
81 sg4::NetZone* zone = e.get_netzone_root();
82 zone->add_route(e.netpoint_by_name(src), e.netpoint_by_name(dst), nullptr, nullptr, link_list);
85 /** @brief Creates the routes in the platform */
86 static void create_sp_routes(const sg4::Engine& e)
88 auto nodes = std::vector<std::string>{"Tremblay", "Jupiter", "Fafard", "Ginette", "Bourassa"};
89 for (const auto& name : nodes) {
90 create_single_route(e, name, name, {"loopback"});
92 create_single_route(e, "Tremblay", "Jupiter", {"9"});
93 create_single_route(e, "Tremblay", "Fafard", {"4", "3", "2", "0", "1", "8"});
94 create_single_route(e, "Tremblay", "Ginette", {"4", "3", "5"});
95 create_single_route(e, "Tremblay", "Bourassa", {"4", "3", "2", "0", "1", "6", "7"});
96 create_single_route(e, "Jupiter", "Fafard", {"9", "4", "3", "2", "0", "1", "8"});
97 create_single_route(e, "Jupiter", "Bourassa", {"9", "4", "3", "2", "0", "1", "6", "7"});
98 create_single_route(e, "Fafard", "Ginette", {"8", "1", "0", "2", "5"});
99 create_single_route(e, "Jupiter", "Jacquelin", {"145"});
100 create_single_route(e, "Jupiter", "Boivin", {"47"});
101 create_single_route(e, "Jupiter", "Ginette", {"9", "4", "3", "5"});
102 create_single_route(e, "Fafard", "Bourassa", {"8", "6", "7"});
103 create_single_route(e, "Ginette", "Bourassa", {"5", "2", "0", "1", "6", "7"});
104 create_single_route(e, "Ginette", "Jacquelin", {"145"});
105 create_single_route(e, "Ginette", "Boivin", {"47"});
106 create_single_route(e, "Bourassa", "Jacquelin", {"145"});
107 create_single_route(e, "Bourassa", "Boivin", {"47"});
108 create_single_route(e, "Jacquelin", "Boivin", {"145", "59", "56", "54", "17", "16", "10", "11", "44", "47"});
109 create_single_route(e, "Jacquelin", "Fafard", {"145", "59", "56", "54", "17", "16", "10", "6", "9", "79", "78"});
110 create_single_route(e, "Jacquelin", "Tremblay", {"145", "59", "56", "54", "2", "3"});
111 create_single_route(e, "Boivin", "Tremblay", {"47", "44", "11", "10", "16", "0", "3"});
112 create_single_route(e, "Boivin", "Fafard", {"47", "44", "11", "6", "9", "79", "78", "80"});
116 * @brief Programmatic version of small_platform.xml
118 * Possible not the best example since we need to describe each component manually,
119 * but it illustrates the new API
121 extern "C" void load_platform(const sg4::Engine& e);
122 void load_platform(const sg4::Engine& e)
124 auto* root_zone = sg4::create_full_zone("zone0");
127 create_sp_hosts(root_zone);
129 create_sp_links(root_zone);
132 /* finally seal the root zone */