Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use 'console' syntax highlighting for shell typescripts.
[simgrid.git] / docs / source / Platform_examples.rst
1 .. raw:: html
2
3    <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
4    <script>
5    window.onload=function() { // Wait for the SVG to be loaded before changing it
6      var elem=document.querySelector("#TOC").contentDocument.getElementById("ExamplesBox")
7      elem.style="opacity:0.93999999;fill:#ff0000;fill-opacity:0.1;stroke:#000000;stroke-width:0.35277778;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1";
8    }
9    </script>
10    <br/>
11    <br/>
12
13 .. _platform_examples:
14    
15 Platform Examples
16 =================
17
18 Simple Example with 3 hosts
19 ---------------------------
20
21 Imagine you want to describe a little platform with three hosts,
22 interconnected as follows:
23
24 .. image:: /tuto_smpi/3hosts.png
25    :align: center
26
27 This can be done with the following platform file, that considers the
28 simulated platform as a graph of hosts and network links.
29
30 .. literalinclude:: /tuto_smpi/3hosts.xml
31    :language: xml
32
33 The elements basic elements (with :ref:`pf_tag_host` and
34 :ref:`pf_tag_link`) are described first, and then the routes between
35 any pair of hosts are explicitly given with :ref:`pf_tag_route`. 
36
37 Any host must be given a computational speed in flops while links must
38 be given a latency and a bandwidth. You can write 1Gf for
39 1,000,000,000 flops (full list of units in the reference guide of 
40 :ref:`pf_tag_host` and :ref:`pf_tag_link`). 
41
42 Routes defined with :ref:`pf_tag_route` are symmetrical by default,
43 meaning that the list of traversed links from A to B is the same as
44 from B to A. Explicitly define non-symmetrical routes if you prefer.
45
46 The last thing you must know on SimGrid platform files is that the
47 root tag must be :ref:`pf_tag_platform`. If the ``version`` attribute
48 does not match what SimGrid expects, you will be hinted to use to the
49 ``simgrid_update_xml`` utility to update your file.
50
51 Cluster with a Crossbar
52 -----------------------
53
54 A very common parallel computing platform is a homogeneous cluster in
55 which hosts are interconnected via a crossbar switch with as many
56 ports as hosts, so that any disjoint pairs of hosts can communicate
57 concurrently at full speed. For instance:
58
59 .. literalinclude:: ../../examples/platforms/cluster_crossbar.xml
60    :language: xml
61    :lines: 1-3,18-
62
63 One specifies a name prefix and suffix for each host, and then give an
64 integer range. In the example the cluster contains 65535 hosts (!),
65 named ``node-0.simgrid.org`` to ``node-65534.simgrid.org``. All hosts
66 have the same power (1 Gflop/sec) and are connected to the switch via
67 links with same bandwidth (125 MBytes/sec) and latency (50
68 microseconds).
69
70 .. todo::
71
72    Add the picture.
73
74 Cluster with a Shared Backbone
75 ------------------------------
76
77 Another popular model for a parallel platform is that of a set of
78 homogeneous hosts connected to a shared communication medium, a
79 backbone, with some finite bandwidth capacity and on which
80 communicating host pairs can experience contention. For instance:
81
82
83 .. literalinclude:: ../../examples/platforms/cluster_backbone.xml
84    :language: xml
85    :lines: 1-3,18-
86
87 The only differences with the crossbar cluster above are the ``bb_bw``
88 and ``bb_lat`` attributes that specify the backbone characteristics
89 (here, a 500 microseconds latency and a 2.25 GByte/sec
90 bandwidth). This link is used for every communication within the
91 cluster. The route from ``node-0.simgrid.org`` to ``node-1.simgrid.org``
92 counts 3 links: the private link of ``node-0.simgrid.org``, the backbone
93 and the private link of ``node-1.simgrid.org``.
94
95 .. todo::
96
97    Add the picture.
98
99 Torus Cluster
100 -------------
101
102 Many HPC facilities use torus clusters to reduce sharing and
103 performance loss on concurrent internal communications. Modeling this
104 in SimGrid is very easy. Simply add a ``topology="TORUS"`` attribute
105 to your cluster. Configure it with the ``topo_parameters="X,Y,Z"``
106 attribute, where ``X``, ``Y`` and ``Z`` are the dimension of your
107 torus.
108
109 .. image:: ../../examples/platforms/cluster_torus.svg
110    :align: center
111
112 .. literalinclude:: ../../examples/platforms/cluster_torus.xml
113    :language: xml
114
115 Note that in this example, we used ``loopback_bw`` and
116 ``loopback_lat`` to specify the characteristics of the loopback link
117 of each node (i.e., the link allowing each node to communicate with
118 itself). We could have done so in previous example too. When no
119 loopback is given, the communication from a node to itself is handled
120 as if it were two distinct nodes: it goes twice through the private
121 link and through the backbone (if any).
122
123 .. _platform_examples_fattree:
124
125 Fat-Tree Cluster
126 ----------------
127
128 This topology was introduced to reduce the amount of links in the
129 cluster (and thus reduce its price) while maintaining a high bisection
130 bandwidth and a relatively low diameter. To model this in SimGrid,
131 pass a ``topology="FAT_TREE"`` attribute to your cluster. The
132 ``topo_parameters=#levels;#downlinks;#uplinks;link count`` follows the
133 semantic introduced in the `Figure 1B of this article
134 <http://webee.eedev.technion.ac.il/wp-content/uploads/2014/08/publication_574.pdf>`_.
135
136 Here is the meaning of this example: ``2 ; 4,4 ; 1,2 ; 1,2``
137
138 - That's a two-level cluster (thus the initial ``2``).
139 - Routers are connected to 4 elements below them, regardless of its
140   level. Thus the ``4,4`` component that is used as
141   ``#downlinks``. This means that the hosts are grouped by 4 on a
142   given router, and that there is 4 level-1 routers (in the middle of
143   the figure).
144 - Hosts are connected to only 1 router above them, while these routers
145   are connected to 2 routers above them (thus the ``1,2`` used as
146   ``#uplink``).
147 - Hosts have only one link to their router while every path between a
148   level-1 routers and level-2 routers use 2 parallel links. Thus the
149   ``1,2`` that is used as ``link count``.
150
151 .. image:: ../../examples/platforms/cluster_fat_tree.svg
152    :align: center
153
154 .. literalinclude:: ../../examples/platforms/cluster_fat_tree.xml
155    :language: xml
156    :lines: 1-3,10-
157
158 .. todo:
159
160    Model some other platforms, for example from https://link.springer.com/article/10.1007/s11227-019-03142-8
161
162 Dragonfly Cluster
163 -----------------
164
165 This topology was introduced to further reduce the amount of links
166 while maintaining a high bandwidth for local communications. To model
167 this in SimGrid, pass a ``topology="DRAGONFLY"`` attribute to your
168 cluster. It's based on the implementation of the topology used on
169 Cray XC systems, described in paper
170 `Cray Cascade: A scalable HPC system based on a Dragonfly network <https://dl.acm.org/citation.cfm?id=2389136>`_.
171
172 System description follows the format ``topo_parameters=#groups;#chassis;#routers;#nodes``
173 For example, ``3,4 ; 3,2 ; 3,1 ; 2``:
174
175 - ``3,4``: There are 3 groups with 4 links between each (blue level).
176   Links to nth group are attached to the nth router of the group
177   on our implementation.
178 - ``3,2``: In each group, there are 3 chassis with 2 links between each nth router
179   of each group (black level)
180 - ``3,1``: In each chassis, 3 routers are connected together with a single link
181   (green level)
182 - ``2``: Each router has two nodes attached (single link)
183
184 .. image:: ../../examples/platforms/cluster_dragonfly.svg
185    :align: center
186
187 .. literalinclude:: ../../examples/platforms/cluster_dragonfly.xml
188    :language: xml
189
190
191 Star Zone
192 ---------
193
194 In a Star topology, as the name says, nodes are organized following a star.
195 It's similar to a cluster topology but you have the flexibility to set
196 different route for every component in the star.
197 Unfortunately, it's only available in the C++ interface.
198
199 .. image:: img/starzone.svg
200     :scale: 80%
201     :align: center
202
203 The particularity of this zone is how routes are declared. Instead of declaring the
204 source and destination, routes are described from a node to everybody else or from
205 everybody else to the node. In the example, the node *A* uses the *Link1* and *Backbone*
206 to communicate with other nodes (note that this is valid for both nodes inside or outside
207 the zone). More precisely, a communication from node *A* to *B* would use links: *Link1, Backbone,
208 Link3_down*. Note that duplicated links are removed from the route, i.e. in this example we'll use *Backbone*
209 only once.
210
211 Also, note that the nodes (A, B and C) can be either hosts or other zones. In case of using zones,
212 set the gateway parameter properly when adding the route.
213
214 The following code illustrates how to create this Star Zone and add the appropriates routes.
215
216 .. code-block:: cpp
217
218     auto* zone = sg4::create_star_zone("star");
219     /* create hosts */
220     const sg4::Host* hostA = zone->create_host("A", 1e9)->seal();
221     const sg4::Host* hostB = zone->create_host("B", 1e9)->seal();
222
223     /* create links */
224     sg4::Link* link1      = zone->create_link("link1", 1e6)->seal();
225     sg4::Link* link3_up   = zone->create_link("link3_up", 1e6)->seal();
226     sg4::Link* link3_down = zone->create_link("link3_down", 1e6)->seal();
227     sg4::Link* backbone   = zone->create_link("backbone", 1e9)->seal();
228
229     /* symmetric route route: A->ALL and ALL->A, shared link1 */
230     zone->add_route(hostA->get_netpoint(), nullptr, nullptr, nullptr,
231                     std::vector<sg4::Link*>{link1, backbone}, true);
232     /* route host B -> ALL, split-duplex link3, direction UP */
233     zone->add_route(hostB->get_netpoint(), nullptr, nullptr, nullptr,
234                     std::vector<sg4::Link*>{link3_up, backbone}, false);
235     /* route host ALL -> B, split-duplex link3, direction DOWN */
236     zone->add_route(nullptr, hostB->get_netpoint(), nullptr, nullptr,
237                     std::vector<sg4::Link*>{backbone, link3_down}, false);
238
239 .. todo:: Complete this page of the manual.
240
241    SimGrid comes with an extensive set of platforms in the
242    `examples/platforms <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms>`_
243    directory that should be described here.
244