Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
18b5d9adb72278127005f99e470634aa5103e99d
[simgrid.git] / docs / source / tuto_smpi.rst
1 .. _usecase_smpi:
2
3 Simulating MPI Applications
4 ===========================
5
6 Discover SMPI
7 -------------
8
9 SimGrid can not only :ref:`simulate algorithms <usecase_simalgo>`, but
10 it can also be used to execute real MPI applications on top of
11 virtual, simulated platforms with the SMPI module. Even complex
12 C/C++/F77/F90 applications should run out of the box in this
13 environment. In fact, almost all proxy apps provided by the `ExaScale
14 Project <https://proxyapps.exascaleproject.org/>`_ only require minor
15 modifications to `run on top of SMPI
16 <https://github.com/simgrid/SMPI-proxy-apps/>`_.
17
18 This setting permits to debug your MPI applications in a perfectly
19 reproducible setup, with no Heisenbugs. Enjoy the full Clairevoyance
20 provided by the simulator while running what-if analysis on platforms
21 that are still to be built! Several `production-grade MPI applications
22 <https://framagit.org/simgrid/SMPI-proxy-apps#full-scale-applications>`_
23 use SimGrid for their integration and performance testing.
24
25 MPI 2.2 is already partially covered: over 160 primitives are
26 supported. Some parts of the standard are still missing: MPI-IO, MPI3
27 collectives, spawning ranks, and some others. If one of the functions
28 you use is still missing, please drop us an email. We may find the
29 time to implement it for you.
30
31 Multi-threading support is very limited in SMPI. Only funneled
32 applications are supported: at most one thread per rank can issue any
33 MPI calls. For better timing predictions, your application should even
34 be completely mono-threaded. Using OpenMP (or pthreads directly) may
35 greatly decrease SimGrid predictive power. That may still be OK if you
36 only plan to debug your application in a reproducible setup, without
37 any performance-related analysis.
38
39 How does it work?
40 ^^^^^^^^^^^^^^^^^
41
42 In SMPI, communications are simulated while computations are
43 emulated. This means that while computations occur as they would in
44 the real systems, communication calls are intercepted and achived by
45 the simulator.
46
47 To start using SMPI, you just need to compile your application with
48 ``smpicc`` instead of ``mpicc``, or with ``smpiff`` instead of
49 ``mpiff``, or with ``smpicxx`` instead of ``mpicxx``. Then, the only
50 difference between the classical ``mpirun`` and the new ``smpirun`` is
51 that it requires a new parameter ``-platform`` with a file describing
52 the virtual platform on which your application shall run.
53
54 Internally, all ranks of your application are executed as threads of a
55 single unix process. That's not a problem if your application has
56 global variables, because ``smpirun`` loads one application instance
57 per MPI rank as if it was another dynamic library. Then, MPI
58 communication calls are implemented using SimGrid: data is exchanged
59 through memory copy, while the simulator's performance models are used
60 to predict the time taken by each communications. Any computations
61 occuring between two MPI calls are benchmarked, and the corresponding
62 time is reported into the simulator.
63
64 .. image:: /tuto_smpi/img/big-picture.svg
65    :align: center          
66
67 Describing Your Platform
68 ------------------------
69
70 As a SMPI user, you are supposed to provide a description of your
71 virtual platform, that is mostly a set of simulated hosts and network
72 links with some performance characteristics. SimGrid provides a plenty
73 of :ref:`documentation <platform>`_ and examples (in the
74 `examples/platforms <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms>`_
75 source directory), and this section only shows a small set of introductory
76 examples.
77
78 Simple Example with 3 hosts
79 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
80
81 At the most basic level, you can describe your simulated platform as a
82 graph of hosts and network links. For instance:
83
84 .. image:: /tuto_smpi/img/3hosts.png
85    :align: center
86
87 .. literalinclude:: /tuto_smpi/3hosts.xml
88    :language: xml
89
90 Note the way in which hosts, links, and routes are defined in
91 this XML. All hosts are defined with a speed (in Gflops), and links
92 with a latency (in us) and bandwidth (in MBytes per second). Other
93 units are possible and written as expected. Routes specify the list of
94 links encountered from one route to another. Routes are symmetrical by
95 default.
96
97 Cluster with a Crossbar
98 ^^^^^^^^^^^^^^^^^^^^^^^
99
100 A very common parallel computing platform is a homogeneous cluster in
101 which hosts are interconnected via a crossbar switch with as many
102 ports as hosts, so that any disjoint pairs of hosts can communicate
103 concurrently at full speed. For instance:
104
105 Cluster with a Shared Backbone
106 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107
108 Another popular model for a parallel platform is that of a set of
109 homogeneous hosts connected to a shared communication medium, a
110 backbone, with some finite bandwidth capacity and on which
111 communicating host pairs can experience contention. For instance:
112        
113 ..  LocalWords:  SimGrid