Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics on the graphical TOC
[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.png
65    :align: center
66
67
68 Describing Your Platform
69 ------------------------
70
71 As a SMPI user, you are supposed to provide a description of your
72 virtual platform, that is mostly a set of simulated hosts and network
73 links with some performance characteristics. SimGrid provides a plenty
74 of :ref:`documentation <platform>`_ and examples (in the
75 `examples/platforms <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms>`_
76 source directory), and this section only shows a small set of introductory
77 examples.
78
79 Simple Example with 3 hosts
80 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
81
82 At the most basic level, you can describe your simulated platform as a
83 graph of hosts and network links. For instance:
84
85 .. image:: /tuto_smpi/img/3hosts.png
86    :align: center
87
88 .. hidden-code-block:: xml
89     :starthidden: True
90     :label: See the XML platform description file...
91
92     <?xml version='1.0'?>
93     <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
94     <platform version="4.1">
95       <zone id="AS0" routing="Full">
96         <host id="host0" speed="1Gf"/>
97         <host id="host1" speed="2Gf"/>
98         <host id="host2" speed="40Gf"/>
99         <link id="link0" bandwidth="125MBps" latency="100us"/>
100         <link id="link1" bandwidth="50MBps" latency="150us"/>
101         <link id="link2" bandwidth="250MBps" latency="50us"/>
102         <route src="host0" dst="host1"><link_ctn id="link0"/><link_ctn id="link1"/></route>
103         <route src="host1" dst="host2"><link_ctn id="link1"/><link_ctn id="link2"/></route>
104         <route src="host0" dst="host2"><link_ctn id="link0"/><link_ctn id="link2"/></route>
105       </zone>
106     </platform>
107
108 In this XML, note the way in which hosts, links, and routes are
109 defined. All hosts are defined with a power (i.e., compute speed in
110 Gflops), and links with a latency (in us) and bandwidth (in MBytes per
111 second). Other units are possible and written as expected. By default,
112 routes are symmetrical.
113        
114 ..  LocalWords:  SimGrid