Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : ignore variable about time used with tracing
[simgrid.git] / doc / doxygen / module-smpi.doc
1 /** @addtogroup SMPI_API
2
3 This programming environment enables the study of MPI application by
4 emulating them on top of the SimGrid simulator. This is particularly
5 interesting to study existing MPI applications within the comfort of
6 the simulator. The motivation for this work is detailed in the
7 reference article (available at http://hal.inria.fr/inria-00527150).
8
9 Our goal is to enable the study of *unmodified* MPI applications,
10 although we are not quite there yet (see @ref SMPI_what). In
11 addition, you can modify your code to speed up your studies or
12 otherwise increase their scalability (see @ref SMPI_adapting).
13
14 \section SMPI_who Who should use SMPI (and who shouldn't)
15
16 SMPI is now considered as stable and you can use it in production. You
17 may probably want to read the scientific publications that detail the
18 models used and their limits, but this should not be absolutely
19 necessary. If you already fluently write and use MPI applications,
20 SMPI should sound very familiar to you. Use smpicc instead of mpicc,
21 and smpirun instead of mpirun (see below for more details).
22
23 Of course, if you don't know what MPI is, the documentation of SMPI
24 will seem a bit terse to you. You should pick up a good MPI tutorial
25 on the Internet (or a course in your favorite university) and come
26 back to SMPI once you know a bit more about MPI. Alternatively, you
27 may want to turn to the other SimGrid interfaces such as the 
28 \ref MSG_API environment, or the \ref SD_API one.
29
30 \section SMPI_what What can run within SMPI?
31
32 You can run unmodified MPI applications (both C and Fortran) within
33 SMPI, provided that (1) you only use MPI calls that we implemented in
34 MPI and (2) you don't use any globals in your application.
35
36 \subsection SMPI_what_coverage MPI coverage of SMPI
37
38 Our coverage of the interface is very decent, but still incomplete;
39 Given the size of the MPI standard, it may well be that we never
40 implement absolutely all existing primitives. One sided communications
41 and I/O primitives are not targeted for now. Our current state is
42 still very decent: we pass most of the MPICH coverage tests.
43
44 The full list of not yet implemented functions is documented in the
45 file <tt>include/smpi/smpi.h</tt> of the archive, between two lines
46 containing the <tt>FIXME</tt> marker. If you really need a missing
47 feature, please get in touch with us: we can guide you though the
48 SimGrid code to help you implementing it, and we'd glad to integrate
49 it in the main project afterward if you contribute them back.
50
51 \subsection SMPI_what_globals Issues with the globals
52
53 Concerning the globals, the problem comes from the fact that usually,
54 MPI processes run as real UNIX processes while they are all folded
55 into threads of a unique system process in SMPI. Global variables are
56 usually private to each MPI process while they become shared between
57 the processes in SMPI. This point is rather problematic, and currently
58 forces to modify your application to privatize the global variables.
59
60 We tried several techniques to work this around. We used to have a
61 script that privatized automatically the globals through static
62 analysis of the source code, but it was not robust enough to be used
63 in production. This issue, as well as several potential solutions, is
64 discussed in this article: "Automatic Handling of Global Variables for
65 Multi-threaded MPI Programs",
66 available at http://charm.cs.illinois.edu/newPapers/11-23/paper.pdf
67 (note that this article does not deal with SMPI but with a concurrent
68 solution called AMPI that suffers of the same issue). 
69
70 Currently, we have no solution to offer you, because all proposed solutions will
71 modify the performance of your application (in the computational
72 sections). Sacrificing realism for usability is not very satisfying, so we did
73 not implement them yet. You will thus have to modify your application if it uses
74 global variables. We are working on another solution, leveraging distributed
75 simulation to keep each MPI process within a separate system process, but this
76 is far from being ready at the moment.
77
78 \section SMPI_compiling Compiling your code
79
80 This is very simply done with the <tt>smpicc</tt> script. If you
81 already compiled any MPI code before, you already know how to use it.
82 If not, you should try to get your MPI code running on top of MPI
83 before giving SMPI a spin. Actually, that's very simple even if it's
84 the first time you use MPI code: just use smpicc as a compiler (in
85 replacement of gcc or your usual compiler), and you're set.
86
87 \section SMPI_executing Executing your code on top of the simulator
88
89 This is done though the <tt>smpirun</tt> script as follows.
90 <tt>my_hostfile.txt</tt> is a classical MPI hostfile (that is, this
91 file lists the machines on which the processes must be dispatched, one
92 per line)  <tt>my_platform.xml</tt> is a classical SimGrid platform
93 file. Of course, the hosts of the hostfile must exist in the provided
94 platform. <tt>./program</tt> is the MPI program that you want to
95 simulate (must be compiled by <tt>smpicc</tt>) while <tt>-arg</tt> is
96 a command-line parameter passed to this program.
97
98 \verbatim
99 smpirun -hostfile my_hostfile.txt -platform my_platform.xml ./program -arg
100 \endverbatim
101
102 smpirun accepts other parameters, such as <tt>-np</tt> if you don't
103 want to use all the hosts defined in the hostfile, <tt>-map</tt> to
104 display on which host each rank gets mapped of <tt>-trace</tt> to
105 activate the tracing during the simulation. You can get the full list
106 by running
107 \verbatim
108 smpirun -help
109 \endverbatim
110
111 \section SMPI_adapting Adapting your MPI code to the use of SMPI
112
113 As detailed in the reference article (available at
114 http://hal.inria.fr/inria-00527150), you may want to adapt your code
115 to improve the simulation performance. But these tricks may seriously
116 hinder the result quality (or even prevent the app to run) if used
117 wrongly. We assume that if you want to simulate an HPC application,
118 you know what you are doing. Don't prove us wrong!
119
120 \section SMPI_adapting_size Reducing your memory footprint
121
122 If you get short on memory (the whole app is executed on a single node when
123 simulated), you should have a look at the SMPI_SHARED_MALLOC and
124 SMPI_SHARED_FREE macros. It allows to share memory areas between processes: The
125 purpose of these macro is that the same line malloc on each process will point
126 to the exact same memory area. So if you have a malloc of 2M and you have 16
127 processes, this macro will change your memory consumption from 2M*16 to 2M
128 only. Only one block for all processes.
129
130 If your program is ok with a block containing garbage value because all
131 processes write and read to the same place without any kind of coordination,
132 then this macro can dramatically shrink your memory consumption. For example,
133 that will be very beneficial to a matrix multiplication code, as all blocks will
134 be stored on the same area. Of course, the resulting computations will useless,
135 but you can still study the application behavior this way. 
136
137 Naturally, this won't work if your code is data-dependent. For example, a Jacobi
138 iterative computation depends on the result computed by the code to detect
139 convergence conditions, so turning them into garbage by sharing the same memory
140 area between processes does not seem very wise. You cannot use the
141 SMPI_SHARED_MALLOC macro in this case, sorry.
142
143 This feature is demoed by the example file
144 <tt>examples/smpi/NAS/DT-folding/dt.c</tt>
145
146 \section SMPI_adapting_speed Toward faster simulations
147
148 If your application is too slow, try using SMPI_SAMPLE_LOCAL,
149 SMPI_SAMPLE_GLOBAL and friends to indicate which computation loops can
150 be sampled. Some of the loop iterations will be executed to measure
151 their duration, and this duration will be used for the subsequent
152 iterations. These samples are done per processor with
153 SMPI_SAMPLE_LOCAL, and shared between all processors with
154 SMPI_SAMPLE_GLOBAL. Of course, none of this will work if the execution
155 time of your loop iteration are not stable.
156
157 This feature is demoed by the example file 
158 <tt>examples/smpi/NAS/EP-sampling/ep.c</tt>
159
160
161 */