Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
prepare the release of 3.22.4
[simgrid.git] / doc / doxygen / FAQ.doc
1 /*! @page FAQ MSG Frequently Asked Questions
2
3 @tableofcontents
4
5 This document is the FAQ of the MSG interface. Some entries are a bit aging and it should be refreshed at some point.
6
7 @section faq_simgrid I'm new to SimGrid. I have some questions. Where should I start?
8
9 You are at the right place... To understand what you can do or
10 cannot do with SimGrid, you should read the
11 <a href="https://simgrid.org/tutorials.html">tutorial
12 slides</a> from the SimGrid's website. You may find more uptodate
13 material on the
14 <a href="http://people.irisa.fr/Martin.Quinson/blog/SimGrid/">blog of
15 Martin Quinson</a>. 
16
17 Another great source of inspiration can be found in the @ref s4u_examples.
18
19 If you are stuck at any point and if this FAQ cannot help you, please drop us a
20 mail to the user mailing list: <simgrid-user@lists.gforge.inria.fr>.
21
22 @subsection faq_interfaces What is the difference between MSG and SimDag? Do they serve the same purpose?
23
24 It depend on how you define "purpose", I guess ;)
25
26 They all allow you to build a prototype of application which you can run
27 within the simulator afterward. They all share the same simulation kernel,
28 which is the core of the SimGrid project. They differ by the way you express
29 your application.
30
31 With SimDag, you express your code as a collection of interdependent
32 parallel tasks. So, in this model, applications can be seen as a DAG of
33 tasks. This is the interface of choice for people wanting to port old
34 code designed for SimGrid v1 or v2 to the framework current version.
35
36 With MSG, your application is seen as a set of communicating
37 processes, exchanging data by the way of messages and performing
38 computation on their own.
39
40 @subsection faq_visualization Visualizing and analyzing the results
41
42 It is sometime convenient to "see" how the agents are behaving. If you
43 like colors, you can use <tt>tools/MSG_visualization/colorize.pl </tt>
44 as a filter to your MSG outputs. It works directly with INFO. Beware,
45 INFO() prints on stderr. Do not forget to redirect if you want to
46 filter (e.g. with bash):
47 @verbatim
48 ./msg_test small_platform.xml small_deployment.xml 2>&1 | ../../tools/MSG_visualization/colorize.pl
49 @endverbatim
50
51 We also have a more graphical output. Have a look at section @ref options_tracing.
52
53 @subsection faq_C Argh! Do I really have to code in C?
54
55 We provide Java bindings of the MSG interface, which is the main
56 SimGrid user API.
57
58 Moreover If you use C++, you should be able to use the SimGrid library
59 as a standard C library and everything should work fine (simply
60 <i>link</i> against this library; recompiling SimGrid with a C++
61 compiler won't work and it wouldn't help if you could).
62
63 For now, we do not feel a real demand for any other language. But if
64 you think there is one, please speak up!
65
66 @section faq_howto Feature related questions
67
68 @subsection faq_MIA "Could you please add (your favorite feature here) to SimGrid?"
69
70 Here is the deal. The whole SimGrid project (MSG, SURF, ...) is
71 meant to be kept as simple and generic as possible. We cannot add
72 functions for everybody's needs when these functions can easily be
73 built from the ones already in the API. Most of the time, it is
74 possible and when it was not possible we always have upgraded the API
75 accordingly. When somebody asks us a question like "How to do that?
76 Is there a function in the API to simply do this?", we're always glad
77 to answer and help. However if we don't need this code for our own
78 need, there is no chance we're going to write it... it's your job! :)
79 The counterpart to our answers is that once you come up with a neat
80 implementation of this feature (task duplication, RPC, thread
81 synchronization, ...), you should send it to us and we will be glad to
82 add it to the distribution. Thus, other people will take advantage of
83 it (and we don't have to answer this question again and again ;).
84
85 You'll find in this section a few "Missing In Action" features. Many
86 people have asked about it and we have given hints on how to simply do
87 it with MSG. Feel free to contribute...
88
89 @subsection faq_MIA_MSG MSG features
90
91 @subsubsection faq_MIA_thread_synchronization How to synchronize my user processes?
92
93 It depends on why you want to synchronize them.  If you just want to
94 have a shared state between your processes, then you probably don't
95 need to do anything. User processes never get forcefully interrupted
96 in SimGrid (unless you explicitly request the parallel execution of
97 user processes -- see @ref options_virt_parallel).
98
99 Even if several processes are executed at the exact same time within
100 the simulation, they are linearized in reality by default: one process
101 always run in an exclusive manner, atomic, uninterrupted until it does
102 a simcall (until it ask a service from the simulation kernel). This is
103 surprising at first, but things are much easier this way, both for the
104 user (who don't have to protect her shared data) and for the kernel
105 (that avoid many synchronization issues too). Processes are executed
106 concurrently in the simulated realm, but you don't need to bother with
107 this in the real realm.
108
109 If you really need to synchronize your processes (because it's what
110 you are studying or to create an atomic section that spans over
111 several simcalls), you obviously cannot use regular synchronization
112 mechanisms (pthread_mutexes in C or the synchronized keyword in Java).
113 This is because the SimGrid kernel locks all processes and unlock them
114 one after the other when they are supposed to run, until they give the
115 control back in their simcall. If one of them gets locked by the OS 
116 before returning the control to the kernel, that's definitively a
117 deadlock.
118
119 Instead, you should use the synchronization mechanism provided by the
120 simulation kernel. This could with a SimGrid mutex, a SimGrid
121 condition variables or a SimGrid semaphore, as described in @ref
122 msg_synchro (in Java, only semaphores are available). But actually,
123 many synchronization patterns can be encoded with communication on
124 mailboxes. Typically, if you need one process to notify another one,
125 you could use a condition variable or a semphore, but sending a
126 message to a specific mailbox does the trick in most cases.
127
128 @subsubsection faq_MIA_communication_time How can I get the *real* communication time?
129
130 Communications are synchronous and thus if you simply get the time
131 before and after a communication, you'll only get the transmission
132 time and the time spent to really communicate (it will also take into
133 account the time spent waiting for the other party to be
134 ready). However, getting the *real* communication time is not really
135 hard either. The following solution is a good starting point.
136
137 @code
138 int sender()
139 {
140   m_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size,
141                                   calloc(1,sizeof(double)));
142   *((double*) task->data) = MSG_get_clock();
143   MSG_task_put(task, slaves[i % slaves_count], PORT_22);
144   XBT_INFO("Send completed");
145   return 0;
146 }
147 int receiver()
148 {
149   m_task_t task = NULL;
150   double time1,time2;
151
152   time1 = MSG_get_clock();
153   a = MSG_task_get(&(task), PORT_22);
154   time2 = MSG_get_clock();
155   if(time1<*((double *)task->data))
156      time1 = *((double *) task->data);
157   XBT_INFO("Communication time :  \"%f\" ", time2-time1);
158   free(task->data);
159   MSG_task_destroy(task);
160   return 0;
161 }
162 @endcode
163
164 @subsection faq_MIA_SimDag SimDag related questions
165
166 @subsubsection faq_SG_comm Implementing communication delays between tasks.
167
168 A classic question of SimDag newcomers is about how to express a
169 communication delay between tasks. The thing is that in SimDag, both
170 computation and communication are seen as tasks.  So, if you want to
171 model a data dependency between two DAG tasks t1 and t2, you have to
172 create 3 SD_tasks: t1, t2 and c and add dependencies in the following
173 way:
174
175 @code
176 SD_task_dependency_add(t1, c);
177 SD_task_dependency_add(c, t2);
178 @endcode
179
180 This way task t2 cannot start before the termination of communication c
181 which in turn cannot start before t1 ends.
182
183 When creating task c, you have to associate an amount of data (in bytes)
184 corresponding to what has to be sent by t1 to t2.
185
186 Finally to schedule the communication task c, you have to build a list
187 comprising the workstations on which t1 and t2 are scheduled (w1 and w2
188 for example) and build a communication matrix that should look like
189 [0;amount ; 0; 0].
190
191 @subsubsection faq_SG_DAG How to implement a distributed dynamic scheduler of DAGs.
192
193 Distributed is somehow "contagious". If you start making distributed
194 decisions, there is no way to handle DAGs directly anymore (unless I
195 am missing something). You have to encode your DAGs in term of
196 communicating process to make the whole scheduling process
197 distributed. Here is an example of how you could do that. Assume T1
198 has to be done before T2.
199
200 @code
201  int your_agent(int argc, char *argv[] {
202    ...
203    T1 = MSG_task_create(...);
204    T2 = MSG_task_create(...);
205    ...
206    while(1) {
207      ...
208      if(cond) MSG_task_execute(T1);
209      ...
210      if((MSG_task_get_remaining_computation(T1)=0.0) && (you_re_in_a_good_mood))
211         MSG_task_execute(T2)
212      else {
213         /* do something else */
214      }
215    }
216  }
217 @endcode
218
219 If you decide that the distributed part is not that much important and that
220 DAG is really the level of abstraction you want to work with, then you should
221 give a try to @ref SD_API.
222
223 @subsection faq_MIA_generic Generic features
224
225 @subsubsection faq_MIA_batch_scheduler Is there a native support for batch schedulers in SimGrid?
226
227 No, there is no native support for batch schedulers and none is
228 planned because this is a very specific need (and doing it in a
229 generic way is thus very hard). However some people have implemented
230 their own batch schedulers. Vincent Garonne wrote one during his PhD
231 and put his code in the contrib directory of our SVN so that other can
232 keep working on it. You may find inspiring ideas in it.
233
234 @subsubsection faq_MIA_checkpointing I need a checkpointing thing
235
236 Actually, it depends on whether you want to checkpoint the simulation, or to
237 simulate checkpoints.
238
239 The first one could help if your simulation is a long standing process you
240 want to keep running even on hardware issues. It could also help to
241 <i>rewind</i> the simulation by jumping sometimes on an old checkpoint to
242 cancel recent calculations.@n
243 Unfortunately, such thing will probably never exist in SG. One would have to
244 duplicate all data structures because doing a rewind at the simulator level
245 is very very hard (not talking about the malloc free operations that might
246 have been done in between). Instead, you may be interested in the Libckpt
247 library (http://www.cs.utk.edu/~plank/plank/www/libckpt.html). This is the
248 checkpointing solution used in the condor project, for example. It makes it
249 easy to create checkpoints (at the OS level, creating something like core
250 files), and rerunning them on need.
251
252 If you want to simulate checkpoints instead, it means that you want the
253 state of an executing task (in particular, the progress made towards
254 completion) to be saved somewhere.  So if a host (and the task executing on
255 it) fails (cf. #MSG_HOST_FAILURE), then the task can be restarted
256 from the last checkpoint.@n
257
258 Actually, such a thing does not exist in SimGrid either, but it's just
259 because we don't think it is fundamental and it may be done in the user code
260 at relatively low cost. You could for example use a watcher that
261 periodically get the remaining amount of things to do (using
262 MSG_task_get_remaining_computation()), or fragment the task in smaller
263 subtasks.
264
265 @subsection faq_platform Platform building and Dynamic resources
266
267 @subsubsection faq_platform_example Where can I find SimGrid platform files?
268
269 There are several little examples in the archive, in the examples/platforms
270 directory. From time to time, we are asked for other files, but we
271 don't have much at hand right now.
272
273 You should refer to the Platform Description Archive
274 (http://pda.gforge.inria.fr) project to see the other platform file we
275 have available, as well as the Simulacrum simulator, meant to generate
276 SimGrid platforms using all classical generation algorithms.
277
278 @subsubsection faq_platform_synthetic Generating synthetic but realistic platforms
279
280 Another possibility to get a platform file is to generate synthetic
281 platforms. Getting a realistic result is not a trivial task, and
282 moreover, nobody is really able to define what "realistic" means when
283 speaking of topology files. You can find some more thoughts on this
284 topic in these
285 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">slides</a>.
286
287 If you are looking for an actual tool, there we have a little tool to
288 annotate Tiers-generated topologies. This perl-script is in
289 <tt>tools/platform_generation/</tt> directory of the SVN. Dinda et Al.
290 released a very comparable tool, and called it GridG.
291
292
293 The specified computing power will be available to up to 6 sequential
294 tasks without sharing. If more tasks are placed on this host, the
295 resource will be shared accordingly. For example, if you schedule 12
296 tasks on the host, each will get half of the computing power. Please
297 note that although sound, this model were never scientifically
298 assessed. Please keep this fact in mind when using it.
299
300 @section faq_troubleshooting Troubleshooting
301
302 @subsection faq_trouble_changelog The feature X stopped to work after my last update 
303
304 I guess that you want to read the ChangeLog file, that always contains
305 all the information that could be important to the users during the
306 upgrade. Actually, you may want to read it (alongside with the NEWS
307 file that highlights the most important changes) even before you
308 upgrade your copy of SimGrid, too.
309
310 We do our best to maintain the backward compatibility, but we
311 sometimes have to fix the things that are too broken. If we happen to
312 kill a feature that you were using, we are sorry. We think that you
313 should update to the new way of doing things, but if you can't afford
314 it, that's ok. Just stick to the last version that were working for
315 you, and have a pleasant day.
316
317 @subsection faq_trouble_compil User code compilation problems
318
319 @subsubsection faq_trouble_err_logcat "gcc: _simgrid_this_log_category_does_not_exist__??? undeclared (first use in this function)"
320
321 This is because you are using the log mechanism, but you didn't created
322 any default category in this file. You should refer to @ref XBT_log
323 for all the details, but you simply forgot to call one of
324 XBT_LOG_NEW_DEFAULT_CATEGORY() or XBT_LOG_NEW_DEFAULT_SUBCATEGORY().
325
326 @subsubsection faq_trouble_pthreadstatic "gcc: undefined reference to pthread_key_create"
327
328 This indicates that one of the library SimGrid depends on (libpthread
329 here) was missing on the linking command line. Dependencies of
330 libsimgrid are expressed directly in the dynamic library, so it's
331 quite impossible that you see this message when doing dynamic linking.
332
333 If you compile your code statically (and if you use a pthread version
334 of SimGrid), you must absolutely
335 specify <tt>-lpthread</tt> on the linker command line. As usual, this should
336 come after <tt>-lsimgrid</tt> on this command line.
337
338 @subsection faq_trouble_errors Runtime error messages
339
340 @subsubsection faq_trouble_errors_big_fat_warning I'm told that my XML files are too old.
341
342 The format of the XML platform description files is sometimes
343 improved. For example, we decided to change the units used in SimGrid
344 from MBytes, MFlops and seconds to Bytes, Flops and seconds to ease
345 people exchanging small messages. We also reworked the route
346 descriptions to allow more compact descriptions.
347
348 That is why the XML files are versionned using the 'version' attribute
349 of the root tag. Currently, it should read:
350 @verbatim
351   <platform version="4">
352 @endverbatim
353
354 If your files are too old, you can use the simgrid_update_xml.pl
355 script which can be found in the tools directory of the archive.
356
357 @subsection faq_trouble_debug Debugging SMPI applications
358
359 In order to debug SMPI programs, you can use the following options:
360
361 - <b>-wrapper 'gdb --args'</b>: this option is used to use a wrapper
362   in order to call the SMPI process. Good candidates for this options
363   are "gdb --args", "valgrind", "rr record", "strace", etc;
364
365 - <b>-foreground</b>: this options gives the debugger access to the terminal
366   which is needed in order to use an interactive debugger.
367
368 Both options are needed in order to run the SMPI process under GDB.
369
370 @subsection faq_trouble_valgrind Valgrind-related and other debugger issues
371
372 If you don't, you really should use valgrind to debug your code, it's
373 almost magic.
374
375 @subsubsection faq_trouble_backtraces Truncated backtraces
376
377 When debugging SimGrid, it's easier to pass the
378 --disable-compiler-optimization flag to the configure if valgrind or
379 gdb get fooled by the optimization done by the compiler. But you
380 should remove these flag when everything works before going in
381 production (before launching your 1252135 experiments), or everything
382 will run only one half of the true SimGrid potential.
383
384 @subsection faq_deadlock There is a deadlock in my code!!!
385
386 Unfortunately, we cannot debug every code written in SimGrid.  We
387 furthermore believe that the framework provides ways enough
388 information to debug such information yourself. If the textual output
389 is not enough, Make sure to check the @ref faq_visualization FAQ entry to see
390 how to get a graphical one.
391
392 Now, if you come up with a really simple example that deadlocks and
393 you're absolutely convinced that it should not, you can ask on the
394 list. Just be aware that you'll be severely punished if the mistake is
395 on your side... We have plenty of FAQ entries to redact and new
396 features to implement for the impenitents! ;)
397
398 @subsection faq_surf_network_latency I get weird timings when I play with the latencies.
399
400 OK, first of all, remember that units should be Bytes, Flops and
401 Seconds. If you don't use such units, some SimGrid constants (e.g. the
402 SG_TCP_CTE_GAMMA constant used in most network models) won't have the
403 right unit and you'll end up with weird results.
404
405 Here is what happens with a single transfer of size L on a link
406 (bw,lat) when nothing else happens.
407
408 @verbatim
409 0-----lat--------------------------------------------------t
410 |-----|**** real_bw =min(bw,SG_TCP_CTE_GAMMA/(2*lat)) *****|
411 @endverbatim
412
413 In more complex situations, this min is the solution of a complex
414 max-min linear system.  Have a look
415 <a href="http://lists.gforge.inria.fr/pipermail/simgrid-devel/2006-April/thread.html">here</a>
416 and read the two threads "Bug in SURF?" and "Surf bug not
417 fixed?". You'll have a few other examples of such computations. You
418 can also read "A Network Model for Simulation of Grid Application" by
419 Henri Casanova and Loris Marchal to have all the details. The fact
420 that the real_bw is smaller than bw is easy to understand. The fact
421 that real_bw is smaller than SG_TCP_CTE_GAMMA/(2*lat) is due to the
422 window-based congestion mechanism of TCP. With TCP, you can't exploit
423 your huge network capacity if you don't have a good round-trip-time
424 because of the acks...
425
426 Anyway, what you get is t=lat + L/min(bw,SG_TCP_CTE_GAMMA/(2*lat)).
427
428   * if I you set (bw,lat)=(100 000 000, 0.00001), you get t =  1.00001 (you fully
429 use your link)
430   * if I you set (bw,lat)=(100 000 000, 0.0001),  you get t =  1.0001 (you're on the
431 limit)
432   * if I you set (bw,lat)=(100 000 000, 0.001),   you get t = 10.001  (ouch!)
433
434 This bound on the effective bandwidth of a flow is not the only thing
435 that may make your result be unexpected. For example, two flows
436 competing on a saturated link receive an amount of bandwidth inversely
437 proportional to their round trip time.
438
439 @subsection faq_bugrepport So I've found a bug in SimGrid. How to report it?
440
441 We do our best to make sure to hammer away any bugs of SimGrid, but this is
442 still an academic project so please be patient if/when you find bugs in it.
443 If you do, the best solution is to drop an email either on the simgrid-user
444 or the simgrid-devel mailing list and explain us about the issue.  You can
445 also decide to open a formal bug report using the
446 <a href="https://gforge.inria.fr/tracker/?atid=165&group_id=12&func=browse">relevant
447 interface</a>. You need to login on the server to get the ability to submit
448 bugs.
449
450 We will do our best to solve any problem repported, but you need to help us
451 finding the issue. Just telling "it segfault" isn't enough. Telling "It
452 segfaults when running the attached simulator" doesn't really help either.
453 You may find the following article interesting to see how to repport
454 informative bug repports:
455 http://www.chiark.greenend.org.uk/~sgtatham/bugs.html (it is not SimGrid
456 specific at all, but it's full of good advices).
457
458 */