1 /*! \page faq Frequently Asked Questions
3 \htmlinclude .FAQ.doc.toc
5 \section faq_simgrid I'm new to SimGrid. I have some questions. Where should I start?
7 You are at the right place... Having a look to these
8 <a href="http://graal.ens-lyon.fr/~alegrand/articles/slides_g5k_simul.pdf">slides</a>
10 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">"obsolete" slides</a>)
11 may give you some insights on what SimGrid can help you to do and what
12 are its limitations. Then you definitely should read the \ref
13 MSG_examples. There is also a mailing list: <simgrid-user@lists.gforge.inria.fr>.
15 \subsection faq_interfaces What is the difference between MSG, SimDag, and GRAS? Do they serve the same purpose?
17 It depend on how you define "purpose", I guess ;)
19 They all allow you to build a prototype of application which you can run
20 within the simulator afterward. They all share the same simulation kernel,
21 which is the core of the SimGrid project. They differ by the way you express
24 With SimDag, you express your code as a collection of interdependent
25 parallel tasks. So, in this model, applications can be seen as a DAG of
28 With both GRAS and MSG, your application is seen as a set of communicating
29 processes, exchanging data by the way of messages and performing computation
32 The difference between both is that MSG is somehow easier to use, but GRAS
33 is not limitated to the simulator. Once you're done writing your GRAS code,
34 you can run your code both in the simulator or on a real platform. For this,
35 there is two implementations of the GRAS interface, one for simulation, one
36 for real execution. So, you just have to relink your code to chose one of
39 \subsection faq_generic First steps with SimGrid
41 If you decide to go for the MSG interface, please read carefully the
42 \ref MSG_examples. You'll find in \ref MSG_ex_master_slave a very
43 simple consisting of a master (that owns a bunch of tasks and
44 distributes them) , some slaves (that process tasks whenever they
45 receive one) and some forwarder agents (that simply pass the tasks
46 they receive to some slaves).
48 If you decide to go for the GRAS interface, you should definitively
49 read the \ref GRAS_tut. The first section constitutes an introduction
50 to the tool and presents the model we use. The second section
51 constitutes a complete step-by-step tutorial building a distributed
52 application from the begining and exemplifying most of the GRAS
53 features in the process. The last section groups some HOWTOS
54 highlighting a given feature of the framework in a more concise way.
56 If you decide to go for another interface, I'm afraid your only sources
57 of information will be the source code and the mailing lists...
59 \subsection faq_visualization Visualizing and analyzing the results
61 It is sometime convenient to "see" how the agents are behaving. If you
62 like colors, you can use <tt>tools/MSG_visualization/colorize.pl </tt>
63 as a filter to your MSG outputs. It works directly with INFO. Beware,
64 INFO() prints on stderr. Do not forget to redirect if you want to
65 filter (e.g. with bash):
67 ./msg_test small_platform.xml small_deployment.xml 2>&1 | ../../tools/MSG_visualization/colorize.pl
70 We also have a more graphical output. Have a look at MSG_paje_output(). It
71 generates an input to <a href="http://www-id.imag.fr/Logiciels/paje/">Paje</a>.
74 <a href="Paje_MSG_screenshot.jpg"><img src="Paje_MSG_screenshot_thn.jpg"></a>
78 Vizualization with Paje can be seen as a kind of postmortem
79 analysis. However, as soon as you start playing with big simulations,
80 you'll realize that processing such output is kind of tricky. There is
81 so much generic informations that it is hard to find the information
84 As a matter of fact, loging really depends on simulations (e.g. what
85 kind of events is important...). That is why we do not propose a big
86 dump of your whole simulation (it would slow everything down) but give
87 you neat tools to structure you logs. Have a look at \ref XBT_log. In
88 fact, rather than a post-mortem analysis, you may want to do it on the
89 fly. The process you are running can do whatever you want. Have you
90 thought about adding a global structure where you directly compute the
91 informations that are really important rather than writing everything
92 down and then processing huge files?
94 \subsection faq_C Argh! Do I really have to code in C?
96 Up until now, there is no binding for other languages. If you use C++,
97 you should be able to use the SimGrid library as a standard C library
98 and everything should work fine (simply <i>link</i> against this
99 library; recompiling SimGrid with a C++ compiler won't work and it
100 wouldn't help if you could).
102 In fact, we are currently working on Java bindings of MSG to allow
103 all the undergrad students of the world to use this tool. This is a
104 little more tricky than I would have expected, but the work is moving
105 fast forward [2006/05/13]. More languages are evaluated, but for now,
106 we do not feel a real demand for any other language. Please speak up!
108 \section faq_installation Installing the SimGrid library
110 Many people have been asking me questions on how to use SimGrid. Quite
111 often, the questions were not really about SimGrid but on the
112 installation process. This section is intended to help people that are
113 not familiar with compiling C files under UNIX. If you follow these
114 instructions and still have some troubles, drop an e-mail to
115 <simgrid-user@lists.gforge.inria.fr>.
117 \subsection faq_compiling Compiling SimGrid from an archive
119 First of all, you need to download the latest version of SimGrid from
120 <a href="http://gforge.inria.fr/frs/?group_id=12">here</a>.
121 Suppose you have uncompressed SimGrid in some temporary location of
122 your home directory (say <tt>/home/joe/tmp/simgrid-3.0.1 </tt>). The
123 simplest way to use SimGrid is to install it in your home
124 directory. Change your directory to
125 <tt>/home/joe/tmp/simgrid-3.0.1</tt> and type
127 \verbatim./configure --prefix=$HOME
132 If at some point, something fails, check the section "\ref
133 faq_trouble_compil". If it does not help, you can report this problem to the
134 list but, please, avoid sending a laconic mail like "There is a problem. Is it
135 okay?". Send the config.log file which is automatically generated by
136 configure. Try to capture both the standard output and the error output of the
137 <tt>make</tt> command with <tt>script</tt>. There is no way for us to help you
138 without the relevant bits of information.
140 Now, the following directory should have been created :
142 \li <tt>/home/joe/doc/simgrid/html/</tt>
143 \li <tt>/home/joe/lib/</tt>
144 \li <tt>/home/joe/include/</tt>
146 SimGrid is not a binary, it is a library. Both a static and a dynamic
147 version are available. Here is what you can find if you try a <tt>ls
150 \verbatim libsimgrid.a libsimgrid.la libsimgrid.so libsimgrid.so.0 libsimgrid.so.0.0.1
153 Thus, there is two ways to link your program with SimGrid:
154 \li Either you use the static version, e.g
155 \verbatim gcc libsimgrid.a -o MainProgram MainProgram.c
157 In this case, all the SimGrid functions are directly
158 included in <tt>MainProgram</tt> (hence a bigger binary).
159 \li Either you use the dynamic version (the preferred method)
160 \verbatim gcc -lsimgrid -o MainProgram MainProgram.c
162 In this case, the SimGrid functions are not included in
163 <tt>MainProgram</tt> and you need to set your environment
164 variable in such a way that <tt>libsimgrid.so</tt> will be
165 found at runtime. This can be done by adding the following
166 line in your .bashrc (if you use bash and if you have
167 installed the SimGrid libraries in your home directory):
168 \verbatim export LD_LIBRARY_PATH=$HOME/lib/:$LD_LIBRARY_PATH
172 \subsection faq_compiling_svn Compiling SimGrid from the SVN
174 The project development takes place in the svn, where all changes are
175 commited when they happen. Then every once in a while, we make sure that the
176 code quality meets our standard and release an archive from the code in the
177 SVN. We afterward go back to the development in the SVN. So, if you need a
178 recently added feature and can afford some little problem with the stability
179 of the lastest features, you may want to use the SVN version instead of a
182 For that, you first need to get the "simgrid" module from
183 <a href="http://gforge.inria.fr/scm/?group_id=12">here</a>.
185 You won't find any <tt>configure</tt> and a few other things
186 (<tt>Makefile.in</tt>'s, documentation, ...) will be missing as well. The
187 reason for that is that all these files have to be regenerated using the
188 latest versions of <tt>autoconf</tt>, <tt>libtool</tt>, <tt>automake</tt>
189 (>1.9) and <tt>doxygen</tt> (>1.4). To generate the <tt>configure</tt> and
190 the <tt>Makefile.in</tt>'s, you just have to launch the <tt>bootstrap</tt>
191 command that resides in the top of the source tree. Then just follow the
192 instructions of Section \ref faq_compiling.
194 We insist on the fact that you really need the latest versions of
195 autoconf, automake and libtool. Doing this step on exotic architectures/systems
196 (i.e. anything different from a recent linux distribution) may be
197 ... uncertain. If you need to compile the SVN version on a machine where all these
198 dependencies are not met, the easiest is to do <tt>make dist</tt> in the SVN
199 dir of another machine where all dependencies are met. It will create an
200 archive you may deploy on other sites just as a regular stable release.
202 In summary, the following commands will checkout the SVN, regenerate the
203 configure script and friends, configure SimGrid and build it.
205 \verbatim svn checkout svn://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk simgrid
208 ./configure --enable-maintainer-mode --prefix=<where to install SimGrid>
211 Then, if you want to install SimGrid on the current box, just do:
212 \verbatim make install \endverbatim
214 If you want to build an snapshot of the SVN to deploy it on another box (for
215 example because the other machine don't have the autotools), do:
216 \verbatim make dist \endverbatim
218 Moreover, you should never call the autotools manually since you must run
219 them in a specific order with specific arguments. Most of the times, the
220 makefiles will automatically call the tools for you. When it's not possible
221 (such as the first time you checkout the SVN), use the ./bootstrap command
222 to call them explicitely.
225 \subsection faq_setting_MSG Setting up your own MSG code
227 Do not build your simulator by modifying the SimGrid examples. Go
228 outside the SimGrid source tree and create your own working directory
229 (say <tt>/home/joe/SimGrid/MyFirstScheduler/</tt>).
231 Suppose your simulation has the following structure (remember it is
232 just an example to illustrate a possible way to compile everything;
233 feel free to organize it as you want).
235 \li <tt>sched.h</tt>: a description of the core of the
236 scheduler (i.e. which functions are can be used by the
237 agents). For example we could find the following functions
238 (master, forwarder, slave).
240 \li <tt>sched.c</tt>: a C file including <tt>sched.h</tt> and
241 implementing the core of the scheduler. Most of these
242 functions use the MSG functions defined in section \ref
245 \li <tt>masterslave.c</tt>: a C file with the main function, i.e.
246 the MSG initialization (MSG_global_init()), the platform
247 creation (e.g. with MSG_create_environment()), the
248 deployment phase (e.g. with MSG_function_register() and
249 MSG_launch_application()) and the call to
252 To compile such a program, we suggest to use the following
253 Makefile. It is a generic Makefile that we have used many times with
254 our students when we teach the C language.
258 masterslave: masterslave.o sched.o
260 INSTALL_PATH = $$HOME
262 PEDANTIC_PARANOID_FREAK = -O0 -Wshadow -Wcast-align \
263 -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
264 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
265 -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
266 -Wpointer-arith -Wwrite-strings -finline-functions
267 REASONABLY_CAREFUL_DUDE = -Wall
268 NO_PRAYER_FOR_THE_WICKED = -w -O2
269 WARNINGS = $(REASONABLY_CAREFUL_DUDE)
270 CFLAGS = -g $(WARNINGS)
272 INCLUDES = -I$(INSTALL_PATH)/include
273 DEFS = -L$(INSTALL_PATH)/lib/
274 LDADD = -lm -lsimgrid
278 $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@
281 $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
284 rm -f $(BIN_FILES) *.o *~
290 The first two lines indicates what should be build when typing make
291 (<tt>masterslave</tt>) and of which files it is to be made of
292 (<tt>masterslave.o</tt> and <tt>sched.o</tt>). This makefile assumes
293 that you have set up correctly your <tt>LD_LIBRARY_PATH</tt> variable
294 (look, there is a <tt>LDADD = -lm -lsimgrid</tt>). If you prefer using
295 the static version, remove the <tt>-lsimgrid</tt> and add a
296 <tt>$(INSTALL_PATH)/lib/libsimgrid.a</tt> on the next line, right
297 after the <tt>LIBS = </tt>.
299 More generally, if you have never written a Makefile by yourself, type
300 in a terminal : <tt>info make</tt> and read the introduction. The
301 previous example should be enough for a first try but you may want to
302 perform some more complex compilations...
304 \subsection faq_setting_GRAS Setting up your own GRAS code
306 If you use the GRAS interface instead of the MSG one, then previous section
307 is not the better source of information. Instead, you should check the GRAS
308 tutorial in general, and the \ref GRAS_tut_tour_setup in particular.
310 \subsection faq_crosscompile Cross-compiling a Windows DLL of SimGrid from linux
312 At the moment, we do not distribute Windows pre-compiled version of SimGrid
313 because the support for this platform is still experimental. We know that
314 some parts of the GRAS environment do not work, and we think that the others
315 environments (MSG and SD) have good chances to work, but we didn't test
316 ourselves. This section explains how we generate the SimGrid DLL so that you
317 can build it for yourself. First of all, you need to have a version more
318 recent than 3.1 (ie, a SVN version as time of writting).
320 In order to cross-compile the package to windows from linux, you need to
321 install mingw32 (minimalist gnu win32). On Debian, you can do so by
322 installing the packages mingw32 (compiler), mingw32-binutils (linker and
323 so), mingw32-runtime.
325 You can use the VPATH support of configure to compile at the same time for
326 linux and windows without dupplicating the source nor cleaning the tree
327 between each. Just run bootstrap (if you use the SVN) to run the autotools.
328 Then, create a linux and a win directories. Then, type:
329 \verbatim cd linux; ../configure --srcdir=.. <usual configure flags>; make; cd ..
330 cd win; ../configure --srcdir=.. --host=i586-mingw32msvc <flags>; make; cd ..
332 The trick to VPATH builds is to call configure from another directory,
333 passing it an extra --srcdir argument to tell it where all the sources are.
334 It will understand you want to use VPATH. Then, the trick to cross-compile
335 is simply to add a --host argument specifying the target you want to build
336 for. The i586-mingw32msvc string is what you have to pass to use the mingw32
337 environment as distributed in Debian.
339 After that, you can run all make targets from both directories, and test
340 easily that what you change for one arch does not break the other one.
342 It is possible that this VPATH build thing breaks from time to time in the
343 SVN since it's quite fragile, but it's granted to work in any released
344 version. If you experience problems, drop us a mail.
346 Another possible source of issue is that at the moment, building the
347 examples request to use the gras_stub_generator tool, which is a compiled
348 program, not a script. In cross-compilation, you need to cross-execute with
349 wine for example, which is not really pleasant. We are working on this, but
350 in the meanwhile, simply don't build the examples in cross-compilation
351 (<tt>cd src</tt> before running make).
353 Program (cross-)compiled with mingw32 do request an extra DLL at run-time to be
354 usable. For example, if you want to test your build with wine, you should do
355 the following to put this library where wine looks for DLLs.
357 cp /usr/share/doc/mingw32-runtime/mingwm10.dll.gz ~/.wine/c/windows/system/
358 gunzip ~/.wine/c/windows/system/mingwm10.dll.gz
361 The DLL is builded in src/.libs, and installed in the <i>prefix</i>/bin directory
362 when you run make install.
364 If you want to use it in a native project on windows, you need to use
365 simgrid.dll and mingwm10.dll. For each DLL, you need to build .def file
366 under linux (listing the defined symbols), and convert it into a .lib file
367 under windows (specifying this in a way that windows compilers like). To
368 generate the def files, run (under linux):
369 \verbatim echo "LIBRARY libsimgrid-0.dll" > simgrid.def
370 echo EXPORTS >> simgrid.def
371 nm libsimgrid-0.dll | grep ' T _' | sed 's/.* T _//' >> simgrid.def
372 nm libsimgrid-0.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> simgrid.def
374 echo "LIBRARY mingwm10.dll" > mingwm10.def
375 echo EXPORTS >> mingwm10.def
376 nm mingwm10.dll | grep ' T _' | sed 's/.* T _//' >> mingwm10.def
377 nm mingwm10.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> mingwm10.def
380 To create the import .lib files, use the <tt>lib</tt> windows tool (from
381 MSVC) the following way to produce simgrid.lib and mingwm10.lib
382 \verbatim lib /def:simgrid.def
383 lib /def:mingwm10.def
386 If you happen to use Borland C Builder, the right command line is the
387 following (note that you don't need any file.def to get this working).
388 \verbatim implib simgrid.lib libsimgrid-0.dll
389 implib mingwm10.lib mingwm10.dll
392 Then, set the following parameters in Visual C++ 2005:
393 Linker -> Input -> Additional dependencies = simgrid.lib mingwm10.lib
395 Just in case you wonder how to generate a DLL from libtool in another
396 project, we added -no-undefined to any lib*_la_LDFLAGS variables so that
397 libtool accepts to generate a dynamic library under windows. Then, to make
398 it true, we pass any dependencies (such as -lws2 under windows or -lpthread
399 on need) on the linking line. Passing such deps is a good idea anyway so
400 that they get noted in the library itself, avoiding the users to know about
401 our dependencies and put them manually on their compilation line. Then we
402 added the AC_LIBTOOL_WIN32_DLL macro just before AC_PROG_LIBTOOL in the
403 configure.ac. It means that we exported any symbols which need to be.
404 Nowadays, functions get automatically exported, so we don't need to load our
405 header files with tons of __declspec(dllexport) cruft. We only need to do so
406 for data, but there is no public data in SimGrid so we are good.
408 \section faq_howto Feature related questions
410 \subsection faq_MIA "Could you please add (your favorite feature here) to SimGrid?"
412 Here is the deal. The whole SimGrid project (MSG, SURF, GRAS, ...) is
413 meant to be kept as simple and generic as possible. We cannot add
414 functions for everybody's need when these functions can easily be
415 built from the ones already in the API. Most of the time, it is
416 possible and when it was not possible we always have upgraded the API
417 accordingly. When somebody asks us a question like "How to do that?
418 Is there a function in the API to simply do this?", we're always glad
419 to answer and help. However if we don't need this code for our own
420 need, there is no chance we're going to write it... it's your job! :)
421 The counterpart to our answers is that once you come up with a neat
422 implementation of this feature (task duplication, RPC, thread
423 synchronization, ...), you should send it to us and we will be glad to
424 add it to the distribution. Thus, other people will take advantage of
425 it (and we don't have to answer this question again and again ;).
427 You'll find in this section a few "Missing In Action" features. Many
428 people have asked about it and we have given hints on how to simply do
429 it with MSG. Feel free to contribute...
431 \subsection faq_MIA_MSG MSG features
433 \subsubsection faq_MIA_examples I want some more complex MSG examples!
435 Many people have come to ask me a more complex example and each time,
436 they have realized afterward that the basics were in the previous three
439 Of course they have often been needing more complex functions like
440 MSG_process_suspend(), MSG_process_resume() and
441 MSG_process_isSuspended() (to perform synchronization), or
442 MSG_task_Iprobe() and MSG_process_sleep() (to avoid blocking
443 receptions), or even MSG_process_create() (to design asynchronous
444 communications or computations). But the examples are sufficient to
447 We know. We should add some more examples, but not really some more
448 complex ones... We should add some examples that illustrate some other
449 functionalities (like how to simply encode asynchronous
450 communications, RPC, process migrations, thread synchronization, ...)
451 and we will do it when we will have a little bit more time. We have
452 tried to document the examples so that they are understandable. Tell
453 us if something is not clear and once again feel free to participate!
456 \subsubsection faq_MIA_taskdup Missing in action: MSG Task duplication/replication
458 There is no task duplication in MSG. When you create a task, you can
459 process it or send it somewhere else. As soon as a process has sent
460 this task, he doesn't have this task anymore. It's gone. The receiver
461 process has got the task. However, you could decide upon receiving to
462 create a "copy" of a task but you have to handle by yourself the
463 semantic associated to this "duplication".
465 As we already told, we prefer keeping the API as simple as
466 possible. This kind of feature is rather easy to implement by users
467 and the semantic you associate really depends on people. Having a
468 *generic* task duplication mechanism is not that trivial (in
469 particular because of the data field). That is why I would recommand
470 that you write it by yourself even if I can give you advice on how to
473 You have the following functions to get informations about a task:
474 MSG_task_get_name(), MSG_task_get_compute_duration(),
475 MSG_task_get_remaining_computation(), MSG_task_get_data_size(),
476 and MSG_task_get_data().
478 You could use a dictionnary (#xbt_dict_t) of dynars (#xbt_dynar_t). If
479 you still don't see how to do it, please come back to us...
481 \subsubsection faq_MIA_asynchronous I want to do asynchronous communications in MSG
483 Up until now, there is no asynchronous communications in MSG. However,
484 you can create as many process as you want so you should be able to do
485 whatever you want... I've written a queue module to help implementing
486 some asynchronous communications at low cost (creating thousands of
487 process only to handle communications may be problematic in term of
488 performance at some point). I'll add it in the distribution asap.
490 \subsubsection faq_MIA_thread_synchronization I need to synchronize my MSG processes
492 You obviously cannot use pthread_mutexes of pthread_conds. The best
493 thing would be to propose similar structures. Unfortunately, we
494 haven't found time to do it yet. However you can try to play with
495 MSG_process_suspend() and MSG_process_resume(). You can even do some
496 synchronization with fake communications (using MSG_task_get(),
497 MSG_task_put() and MSG_task_Iprobe()).
499 \subsubsection faq_MIA_host_load Where is the get_host_load function hidden in MSG?
501 There is no such thing because its semantic wouldn't be really
502 clear. Of course, it is something about the amount of host throughput,
503 but there is as many definition of "host load" as people asking for
504 this function. First, you have to remember that resource availability
505 may vary over time, which make any load notion harder to define.
507 It may be instantaneous value or an average one. Moreover it may be only the
508 power of the computer, or may take the background load into account, or may
509 even take the currently running tasks into account. In some SURF models,
510 communications have an influence on computational power. Should it be taken
513 First of all, it's near to impossible to predict the load beforehands in the
514 simulator since it depends on too much parameters (background load
515 variation, bandwidth sharing algorithmic complexity) some of them even being
516 not known beforehands (other task starting at the same time). So, getting
517 this information is really hard (just like in real life). It's not just that
518 we want MSG to be as painful as real life. But as it is in some way
519 realistic, we face some of the same problems as we would face in real life.
521 How would you do it for real? The most common option is to use something
522 like NWS that performs active probes. The best solution is probably to do
523 the same within MSG, as in next code snippet. It is very close from what you
524 would have to do out of the simulator, and thus gives you information that
525 you could also get in real settings to not hinder the realism of your
529 double get_host_load() {
530 m_task_t task = MSG_task_create("test", 0.001, 0, NULL);
531 double date = MSG_get_clock();
533 MSG_task_execute(task);
534 date = MSG_get_clock() - date;
535 MSG_task_destroy(task);
540 Of course, it may not match your personal definition of "host load". In this
541 case, please detail what you mean on the mailing list, and we will extend
542 this FAQ section to fit your taste if possible.
544 \subsubsection faq_MIA_communication_time How can I get the *real* communication time?
546 Communications are synchronous and thus if you simply get the time
547 before and after a communication, you'll only get the transmission
548 time and the time spent to really communicate (it will also take into
549 account the time spent waiting for the other party to be
550 ready). However, getting the *real* communication time is not really
551 hard either. The following solution is a good starting point.
556 m_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size,
557 calloc(1,sizeof(double)));
558 *((double*) task->data) = MSG_get_clock();
559 MSG_task_put(task, slaves[i % slaves_count], PORT_22);
560 INFO0("Send completed");
565 m_task_t task = NULL;
568 time1 = MSG_get_clock();
569 a = MSG_task_get(&(task), PORT_22);
570 time2 = MSG_get_clock();
571 if(time1<*((double *)task->data))
572 time1 = *((double *) task->data);
573 INFO1("Communication time : \"%f\" ", time2-time1);
575 MSG_task_destroy(task);
580 \subsection faq_MIA_SimDag SimDag related questions
582 \subsubsection faq_SG_comm Implementing communication delays between tasks.
584 A classic question of SimDag newcommers is about how to express a
585 communication delay between tasks. The thing is that in SimDag, both
586 computation and communication are seen as tasks. So, if you want to
587 model a data dependency between two DAG tasks t1 and t2, you have to
588 create 3 SD_tasks: t1, t2 and c and add dependencies in the following
592 SD_task_dependency_add(NULL, NULL, t1, c);
593 SD_task_dependency_add(NULL, NULL, c, t2);
596 This way task t2 cannot start before the termination of communication c
597 which in turn cannot start before t1 ends.
599 When creating task c, you have to associate an amount of data (in bytes)
600 corresponding to what has to be sent by t1 to t2.
602 Finally to schedule the communication task c, you have to build a list
603 comprising the workstations on which t1 and t2 are scheduled (w1 and w2
604 for example) and build a communication matrix that should look like
607 \subsubsection faq_SG_DAG How to implement a distributed dynamic scheduler of DAGs.
609 Distributed is somehow "contagious". If you start making distributed
610 decisions, there is no way to handle DAGs directly anymore (unless I
611 am missing something). You have to encode your DAGs in term of
612 communicating process to make the whole scheduling process
613 distributed. Here is an example of how you could do that. Assume T1
614 has to be done before T2.
617 int your_agent(int argc, char *argv[] {
619 T1 = MSG_task_create(...);
620 T2 = MSG_task_create(...);
624 if(cond) MSG_task_execute(T1);
626 if((MSG_task_get_remaining_computation(T1)=0.0) && (you_re_in_a_good_mood))
629 /* do something else */
635 If you decide that the distributed part is not that much important and that
636 DAG is really the level of abstraction you want to work with, then you should
637 give a try to \ref SD_API.
639 \subsubsection faq_SG Where has SG disappeared?
641 OK, it's time to explain what's happening to the SimGrid project. Let's
642 start with a little bit of history.
644 * Historically, SimGrid was a low-level toolkit for scheduling with
645 classical models such as DAGs. That was SimGrid v.1.* aka SG, written
646 by Henri Casanova. I (Arnaud) had been using it in its earliest
647 versions during an internship at UCSD.
649 Then we have realized that encoding distributed algorithm in SG was a
652 * So we have built MSG on top of SG and have released SimGrid v.2.*. MSG
653 offered a very basic API to encode a distributed application easily.
654 However encoding MSG on top of SG was not really convenient and did not
655 use the DAG part since the control of the task synchronization was done
656 on top of MSG and no more in SG. We have been playing a little bit with
657 MSG. We have realized that:
659 \li 1) the platform modeling was quite flexible and could be "almost"
660 automated (e.g. using random generator and post-annotations);
662 \li 2) SG was the bottleneck because of the way we were using
663 it. We needed to simulate concurrent transfers, complex load
664 sharing mechanisms. Many optimizations (e.g. trace integration)
665 were totally inefficient when combined with MSG and made extending SG
666 to implement new sharing policies, parallel tasks models, or failures
667 (many people were asking for these kind of features) a real pain;
669 \li 3) the application modeling was not really easy. Even though the
670 application modeling depends on people's applications, we thought
671 we could improve things here. One of our target here was realistic
672 distributed applications ranging from computer sensor networks like
673 the NWS to peer-to-peer applications;
675 * So we have been planning mainly two things for SimGrid 3:
677 \li 1) I have proposed to get rid of SG and to re-implement a new kernel
678 that would be faster and more flexible. That is what I did in the
679 end of 2004: SURF. SURF is based on a fast max-min linear solver
680 using O(1) data-structures. I have quickly replaced SG by SURF in
681 MSG and the result has been that on the MSG example, the new
682 version was more than 10 times faster while we had gain a lot of
683 flexibility. I think I could still easily make MSG faster but I
684 have to work on MSG now (e.g. using some of the O(1)
685 data-structures I've been using to build SURF) since it has become
686 the bottleneck. Some MSG functions have been removed from the API
687 but they were mainly intended to build the platform by hand (they
688 had appeared in the earliest versions of MSG) and were therefore
689 not useful anymore since we are providing a complete mechanism to
690 automatically build the platform and deploy the agents on it.;
692 \li 2) GRAS is a new project Martin and I have come up with. The idea is
693 to have a programming environment that let you program real
694 distributed applications while letting you the ability to run it in
695 the simulator without having to change the slightest line of your
696 code. From the simulation point of view, GRAS performs the
697 application modeling automatically... Up until now, GRAS works on
698 top MSG for historical reasons but I'm going to make it work
699 directly on top of SURF so that it can use all the flex and the
700 speed provided by SURF.
702 Those two things are working, but we want to make everything as clean as
703 possible before releasing SimGrid v.3.
705 So what about those nice DAGs we used to have in SimGrid v.1.? They're
706 not anymore in SimGrid v.3. At least not in their original form... Let
707 me recall you the way SimGrid 3 is organized:
721 XBT is our tool box and now, you should have an idea of what the other
722 ones are. As you can see, the primitive SG is not here
723 anymore. However we have written a brand new and cleaner API for this
724 purpose: \ref SD_API. It is built directly on top of SURF and provides
725 an API rather close to the old SG:
728 _________________________
730 |________________________|
731 | | MSG | GRAS | SimDag |
732 | -----------------------|
734 | -----------------------|
736 --------------------------
739 The nice thing is that, as it is writen on top of SURF, it seamlessly
740 support DAG of parallel tasks as well as complex communications
741 patterns. Some old codes using SG are currently under rewrite using
742 \ref SD_API to check that all needful functions are provided.
744 \subsection faq_MIA_generic Generic features
746 \subsubsection faq_more_processes Increasing the amount of simulated processes
748 Here are a few tricks you can apply if you want to increase the amount
749 of processes in your simulations.
751 - <b>A few thousands of simulated processes</b> (soft tricks)\n
752 SimGrid can use either pthreads library or the UNIX98 contextes. On
753 most systems, the number of pthreads is limited and then your
754 simulation may be limited for a stupid reason. This is especially
755 true with the current linux pthreads, and I cannot get more than
756 2000 simulated processes with pthreads on my box. The UNIX98
757 contexts allow me to raise the limit to 25,000 simulated processes
759 The <tt>--with-context</tt> option of the <tt>./configure</tt>
760 script allows you to choose between UNIX98 contextes
761 (<tt>--with-context=ucontext</tt>) and the pthread version
762 (<tt>--with-context=pthread</tt>). The default value is ucontext
763 when the script detect a working UNIX98 context implementation. On
764 Windows boxes, the provided value is discarded and an adapted
765 version is picked up.\n\n
766 We experienced some issues with contextes on some rare systems
767 (solaris 8 and lower or old alpha linuxes comes to mind). The main
768 problem is that the configure script detect the contextes as being
769 functional when it's not true. If you happen to use such a system,
770 switch manually to the pthread version, and provide us with a good
771 patch for the configure script so that it is done automatically ;)
773 - <b>Hundred thousands of simulated processes</b> (hard-core tricks)\n
774 As explained above, SimGrid can use UNIX98 contextes to represent
775 and handle the simulated processes. Thanks to this, the main
776 limitation to the number of simulated processes becomes the
777 available memory.\n\n
778 Here are some tricks I had to use in order to run a token ring
779 between 25,000 processes on my laptop (1Gb memory, 1.5Gb swap).\n
780 - First of all, make sure your code runs for a few hundreds
781 processes before trying to push the limit. Make sure it's
782 valgrind-clean, ie that valgrind does not report neither memory
783 error nor memory leaks. Indeed, numerous simulated processes
784 result in *fat* simulation hindering debugging.
785 - It was really boring to write 25,000 entries in the deployment
786 file, so I wrote a little script
787 <tt>examples/gras/tokenS/make_deployment.pl</tt>, which you may
788 want to adapt to your case. You could also think about hijacking
789 the SURFXML parser (have look at \ref faq_flexml_bypassing).
790 - The deployment file became quite big, so I had to do what is in
791 the FAQ entry \ref faq_flexml_limit
792 - Each UNIX98 context has its own stack entry. As debugging this is
793 quite hairly, the default value is a bit overestimated so that
794 user don't get into trouble about this. You want to tune this
795 size to increse the number of processes. This is the
796 <tt>STACK_SIZE</tt> define in
797 <tt>src/xbt/context_private.h</tt>, which is 128kb by default.
798 Reduce this as much as you can, but be warned that if this value
799 is too low, you'll get a segfault. The token ring example, which
800 is quite simple, runs with 40kb stacks.
802 \subsubsection faq_MIA_batch_scheduler Is there a native support for batch schedulers in SimGrid?
804 No, there is no native support for batch schedulers and none is
805 planned because this is a very specific need (and doing it in a
806 generic way is thus very hard). However some people have implemented
807 their own batch schedulers. Vincent Garonne wrote one during his PhD
808 and put his code in the contrib directory of our SVN so that other can
809 keep working on it. You may find inspinring ideas in it.
811 \subsubsection faq_MIA_checkpointing I need a checkpointing thing
813 Actually, it depends on whether you want to checkpoint the simulation, or to
814 simulate checkpoints.
816 The first one could help if your simulation is a long standing process you
817 want to keep running even on hardware issues. It could also help to
818 <i>rewind</i> the simulation by jumping sometimes on an old checkpoint to
819 cancel recent calculations.\n
820 Unfortunately, such thing will probably never exist in SG. One would have to
821 duplicate all data structures because doing a rewind at the simulator level
822 is very very hard (not talking about the malloc free operations that might
823 have been done in between). Instead, you may be interested in the Libckpt
824 library (http://www.cs.utk.edu/~plank/plank/www/libckpt.html). This is the
825 checkpointing solution used in the condor project, for example. It makes it
826 easy to create checkpoints (at the OS level, creating something like core
827 files), and rerunning them on need.
829 If you want to simulate checkpoints instead, it means that you want the
830 state of an executing task (in particular, the progress made towards
831 completion) to be saved somewhere. So if a host (and the task executing on
832 it) fails (cf. #MSG_HOST_FAILURE), then the task can be restarted
833 from the last checkpoint.\n
835 Actually, such a thing does not exists in SimGrid either, but it's just
836 because we don't think it is fundamental and it may be done in the user code
837 at relatively low cost. You could for example use a watcher that
838 periodically get the remaining amount of things to do (using
839 MSG_task_get_remaining_computation()), or fragment the task in smaller
842 \subsection faq_platform Platform building and Dynamic resources
844 \subsubsection faq_platform Building a realistic platform
846 We can speak more than an hour on this subject and we still do not have
847 the right answer, just some ideas. You can read the following
848 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">slides</a>.
849 It may give you some hints. You can also have a look at the
850 <tt>tools/platform_generation/</tt> directory. There is a perl-script
851 we use to annotate a Tiers generated platform.
853 \subsubsection faq_SURF_dynamic Building a dynamic platform, with resource availability
855 A nice feature of SimGrid is that it enables you to seamlessly have
856 resources whose availability change over time. When you build a
857 platform, you generally declare CPUs like that:
860 <cpu name="Cpu A" power="100.00"/>
863 If you want the availability of "CPU A" to change over time, the only
864 thing you have to do is change this definition like that:
867 <cpu name="Cpu A" power="100.00" availability_file="trace_A.txt" state_file="trace_A_failure.txt"/>
870 For CPUs, availability files are expressed in fraction of available
871 power. Let's have a look at what "trace_A.txt" may look like:
880 At time 0, our CPU will deliver 100 flop/s. At time 11.0, it will
881 deliver only 50 flop/s until time 20.0 where it will will start
882 delivering 90 flop/s. Last at time 21.0 (20.0 plus the periodicity
883 1.0), we'll be back to the beginning and it will deliver 100 flop/s.
885 Now let's look at the state file:
892 A negative value means "off" while a positive one means "on". At time
893 1.0, the CPU is on. At time 1.0, it is turned off and at time 2.0, it
894 is turned on again until time 12 (2.0 plus the periodicity 10.0). It
895 will be turned on again at time 13.0 until time 23.0, and so on.
897 Now, let's look how the same kind of thing can be done for network
898 links. A usual declaration looks like:
901 <network_link name="LinkA" bandwidth="10.0" latency="0.2"/>
904 You have at your disposal the following options: bandwidth_file,
905 latency_file and state_file. The only difference with CPUs is that
906 bandwidth_file and latency_file do not express fraction of available
907 power but are expressed directly in bytes per seconds and seconds.
909 \subsubsection faq_platform_multipath Is it possible to have several paths between two given hosts?
911 The answer is no, unfortunately. Let's consider the following platform
915 <route src="A" dst="B">
916 <route_element name="1"/>
918 <route src="B" dst="C">
919 <route_element name="2"/>
921 <route src="A" dst="C">
922 <route_element name="3"/>
926 Althrough it is perfectly valid, it does not mean that data traveling
927 from A to C can either go directly (using link 3) or through B (using
928 links 1 and 2). It simply means that the routing on the graph is not
929 trivial, and that data do not following the shortest path in number of
930 hops on this graph. Another way to say it is that there is no implicit
931 in these routing descriptions. The system will only use the routes you
932 declare (such as <route src="A" dst="C"><route_element
933 name="3"/></route>), without trying to build new routes by aggregating
936 You are also free to declare platform where the routing is not
937 symetric. For example, add the following to the previous file:
940 <route src="C" dst="A">
941 <route_element name="2"/>
942 <route_element name="1"/>
946 This makes sure that data from C to A go through B where data from A
947 to C go directly. Do not worry about realism of such settings since
948 we've seen ways more weird situation in real settings.
950 \subsubsection faq_flexml_bypassing Bypassing the XML parser with your own C functions
952 So you want to bypass the XML files parser, uh? Maybe doin some parameter
953 sweep experiments on your simulations or so? This is possible, but it's not
954 really easy. Here is how it goes.
956 For this, you have to first remember that the XML parsing in SimGrid is done
957 using a tool called FleXML. Given a DTD, this gives a flex-based parser. If
958 you want to bypass the parser, you need to provide some code mimicking what
959 it does and replacing it in its interactions with the SURF code. So, let's
960 have a look at these interactions.
962 FleXML parser are close to classical SAX parsers. It means that a
963 well-formed SimGrid platform XML file might result in the following
966 - start "platform_description"
967 - start "cpu" with attributes name="host1" power="1.0"
969 - start "cpu" with attributes name="host2" power="2.0"
971 - start "network_link" with ...
973 - start "route" with ...
975 - start "route" with ...
977 - end "platform_description"
979 The communication from the parser to the SURF code uses two means:
980 Attributes get copied into some global variables, and a surf-provided
981 function gets called by the parser for each event. For example, the event
982 - start "cpu" with attributes name="host1" power="1.0"
984 let the parser do the equivalent of:
986 strcpy("host1",A_cpu_name);
991 In SURF, we attach callbacks to the different events by initializing the
992 pointer functions to some the right surf functions. Example in
993 workstation_KCCFLN05.c (surf_parse_open() ends up calling surf_parse()):
995 // Building the routes
996 surf_parse_reset_parser();
997 STag_route_fun=parse_route_set_endpoints;
998 ETag_route_element_fun=parse_route_elem;
999 ETag_route_fun=parse_route_set_route;
1000 surf_parse_open(file);
1001 xbt_assert1((!surf_parse()),"Parse error in %s",file);
1005 So, to bypass the FleXML parser, you need to write your own version of the
1006 surf_parse function, which should do the following:
1007 - Call the corresponding STag_<tag>_fun function to simulate tag start
1008 - Fill the A_<tag>_<attribute> variables with the wanted values
1009 - Call the corresponding ETag_<tag>_fun function to simulate tag end
1010 - (do the same for the next set of values, and loop)
1012 Then, tell SimGrid that you want to use your own "parser" instead of the stock one:
1014 surf_parse = surf_parse_bypass;
1015 MSG_create_environment(NULL);
1018 An example of this trick is distributed in the file examples/msg/masterslave/masterslave_bypass.c
1020 \section faq_troubleshooting Troubleshooting
1022 \subsection faq_trouble_lib_compil SimGrid compilation and installation problems
1024 \subsubsection faq_trouble_lib_config ./configure fails!
1026 We now only one reason for the configure to fail:
1028 - <b>You are using a borken build environment</b>\n
1029 If symptom is that configure complains about gcc not being able to build
1030 executables, you are probably missing the libc6-dev package. Damn Ubuntu.
1032 If you experience other kind of issue, please get in touch with us. We are
1033 always interested in improving our portability to new systems.
1035 \subsubsection faq_trouble_distcheck Dude! "make check" fails on my machine!
1037 Don't assume we never run this target, because we do. Check
1038 http://bob.loria.fr:8010 if you don't believe us.
1040 There is several reasons which may cause the make check to fail on your
1043 - <b>You are using a borken libc (probably concerning the contextes)</b>.\n
1044 The symptom is that the "make check" fails within the examples/msg directory.\n
1045 By default, SimGrid uses something called ucontexts. This is part of the
1046 libc, but it's quite undertested. For example, some (old) versions of the
1047 glibc on alpha do not implement these functions, but provide the stubs
1048 (which return ENOSYS: not implemented). It may fool our detection mecanism
1049 and leads to segfaults. There is not much we can do to fix the bug.
1050 A workaround is to compile with --with-context=pthread to avoid
1051 ucontext completely. You'll be a bit more limitated in the number
1052 of simulated processes you can start concurently, but 5000
1053 processes is still enough for most purposes, isn't it?\n
1054 This limitation is the reason why we insist on using this piece of ...
1055 software even if it's so troublesome.\n
1056 <b>=> use --with-pthread on AMD64 architecture that do not have an
1057 ultra-recent libc.</b>
1059 - <b>There is a bug in SimGrid we aren't aware of</b>.\n
1060 If none of the above apply, please drop us a mail on the mailing list so
1061 that we can check it out. Make sure to read \ref faq_bugrepport
1064 \subsection faq_trouble_compil User code compilation problems
1066 \subsubsection faq_trouble_err_logcat "gcc: _simgrid_this_log_category_does_not_exist__??? undeclared (first use in this function)"
1068 This is because you are using the log mecanism, but you didn't created
1069 any default category in this file. You should refer to \ref XBT_log
1070 for all the details, but you simply forgot to call one of
1071 XBT_LOG_NEW_DEFAULT_CATEGORY() or XBT_LOG_NEW_DEFAULT_SUBCATEGORY().
1073 \subsubsection faq_trouble_pthreadstatic "gcc: undefinded reference to pthread_key_create"
1075 This indicates that one of the library SimGrid depends on (libpthread
1076 here) was missing on the linking command line. Dependencies of
1077 libsimgrid are expressed directly in the dynamic library, so it's
1078 quite impossible that you see this message when doing dynamic linking.
1080 If you compile your code statically (and if you use a pthread version
1081 of SimGrid -- see \ref faq_more_processes), you must absolutely
1082 specify <tt>-lpthread</tt> on the linker command line. As usual, this should
1083 come after <tt>-lsimgrid</tt> on this command line.
1085 \subsection faq_trouble_errors Runtime error messages
1087 \subsubsection faq_flexml_limit "surf_parse_lex: Assertion `next limit' failed."
1089 This is because your platform file is too big for the parser.
1091 Actually, the message comes directly from FleXML, the technology on top of
1092 which the parser is built. FleXML has the bad idea of fetching the whole
1093 document in memory before parsing it. And moreover, the memory buffer size
1094 must be determinded at compilation time.
1096 We use a value which seems big enough for our need without bloating the
1097 simulators footprints. But of course your mileage may vary. In this case,
1098 just edit src/surf/surfxml.l modify the definition of
1099 FLEXML_BUFFERSTACKSIZE. E.g.
1102 #define FLEXML_BUFFERSTACKSIZE 1000000000
1105 Then recompile and everything should be fine, provided that your version of
1106 Flex is recent enough (>= 2.5.31). If not the compilation process should
1109 A while ago, we worked on FleXML to reduce a bit its memory consumtion, but
1110 these issues remain. There is two things we should do:
1112 - use a dynamic buffer instead of a static one so that the only limit
1113 becomes your memory, not a stupid constant fixed at compilation time
1114 (maybe not so difficult).
1115 - change the parser so that it does not need to get the whole file in
1116 memory before parsing
1117 (seems quite difficult, but I'm a complete newbe wrt flex stuff).
1119 These are changes to FleXML itself, not SimGrid. But since we kinda hijacked
1120 the development of FleXML, I can grant you that any patches would be really
1121 welcome and quickly integrated.
1123 <b>Update:</b> A new version of FleXML (1.7) was released. Most of the work
1124 was done by William Dowling, who use it in his own work. The good point is
1125 that it now use a dynamic buffer, and that the memory usage was greatly
1126 improved. The downside is that William also changed some things internally,
1127 and it breaks the hack we devised to bypass the parser, as explained in
1128 \ref faq_flexml_bypassing. Indeed, this is not a classical usage of the
1129 parser, and Will didn't imagine that we may have used (and even documented)
1130 such a crude usage of FleXML. So, we now have to repare the bypassing
1131 functionnality to use the lastest FleXML version and fix the memory usage in
1134 \subsubsection faq_trouble_gras_transport GRAS spits networking error messages
1136 Gras, on real platforms, naturally use regular sockets to communicate. They
1137 are deeply hiden in the gras abstraction, but when things go wrong, you may
1138 get some weird error messages. Here are some example, with the probable
1141 - <b>Transport endpoint is not connected</b>: several processes try to open
1142 a server socket on the same port number of the same machine. This is
1143 naturally bad and each process should pick its own port number for this.\n
1144 Maybe, you just have some processes remaining from a previous experiment
1146 Killing them may help, but again if you kill -KILL them, you'll have to
1147 wait for a while: they didn't close there sockets properly and the system
1148 needs a while to notice that this port is free again.
1150 - <b>Socket closed by remote side</b>: if the remote process is not
1151 supposed to close the socket at this point, it may be dead.
1153 - <b>Connection reset by peer</b>: I found this on internet about this
1154 error. I think it's what's happening here, too:\n
1155 <i>This basically means that a network error occurred while the client was
1156 receiving data from the server. But what is really happening is that the
1157 server actually accepts the connection, processes the request, and sends
1158 a reply to the client. However, when the server closes the socket, the
1159 client believes that the connection has been terminated abnormally
1160 because the socket implementation sends a TCP reset segment telling the
1161 client to throw away the data and report an error.\n
1162 Sometimes, this problem is caused by not properly closing the
1163 input/output streams and the socket connection. Make sure you close the
1164 input/output streams and socket connection properly. If everything is
1165 closed properly, however, and the problem persists, you can work around
1166 it by adding a one-second sleep before closing the streams and the
1167 socket. This technique, however, is not reliable and may not work on all
1169 Since GRAS sockets are closed properly (repeat after me: there is no bug
1170 in GRAS), it is either that you are closing your sockets on server side
1171 before the client get a chance to read them (use gras_os_sleep() to delay
1172 the server), or the server died awfully before the client got the data.
1174 \subsubsection faq_trouble_errors_big_fat_warning I'm told that my XML files are too old.
1176 We have decided to change the units in SimGrid. Now we use Bytes, Flops and
1177 seconds instead of MBytes, MFlops and seconds... Units should be updated
1178 accordingly and the version of platform_description should be set to a
1179 valuer greater than 1:
1181 <platform_description version="1">
1183 You should try to use the surfxml_update.pl script that can be found
1184 <a href="https://gforge.inria.fr/plugins/scmsvn/viewcvs.php/contrib/trunk/platform_generation/?rev=4721&root=simgrid"">here</a>.
1186 \subsection faq_trouble_valgrind Valgrind-related issues
1188 If you don't, you really should use valgrind to debug your code, it's
1191 \subsubsection faq_trouble_vg_context Stack switching problems and truncated backtraces
1193 With the default version of simgrid, valgrind will probably spit tons
1194 of warnings about stack switching like the following, and produce
1195 truncated bactraces where only one call appears instead of the whole
1199 ==14908== Warning: client switching stacks? SP change: 0xBEA2A48C --> 0x476F350
1200 ==14908== to suppress, use: --max-stackframe=1171541700 or greater
1201 ==14908== Warning: client switching stacks? SP change: 0x476E1E4 --> 0xBEA2A48C
1202 ==14908== to suppress, use: --max-stackframe=1171537240 or greater
1203 ==14908== Warning: client switching stacks? SP change: 0xBEA2A48C --> 0x4792420
1204 ==14908== to suppress, use: --max-stackframe=1171685268 or greater
1205 ==14908== further instances of this message will not be shown.
1208 This is because valgrind don't like too much the UNIX98 contextes we
1209 use by default in simgrid for efficiency reasons. Simply add the
1210 --with-pthread flag to your configure when debugging your code. You
1211 may also find --disable-compiler-optimization usefull if valgrind or
1212 gdb get fooled by the optimization done by the compiler. But you
1213 should remove these flages when everything works before going in
1214 production (before launching your 1252135 experiments), or everything
1215 will run only one third of the true SimGrid potential.
1217 \subsubsection faq_trouble_vg_longjmp longjmp madness in valgrind
1219 This is when valgrind starts complaining about longjmp things, just like:
1221 \verbatim ==21434== Conditional jump or move depends on uninitialised value(s)
1222 ==21434== at 0x420DBE5: longjmp (longjmp.c:33)
1224 ==21434== Use of uninitialised value of size 4
1225 ==21434== at 0x420DC3A: __longjmp (__longjmp.S:48)
1228 or even when it reports scary things like:
1230 \verbatim ==24023== Warning: client switching stacks? SP change: 0xBE3FF618 --> 0xBE7FF710
1231 x86->IR: unhandled instruction bytes: 0xF4 0xC7 0x83 0xD0
1232 ==24023== to suppress, use: --max-stackframe=4194552 or greater
1233 ==24023== Your program just tried to execute an instruction that Valgrind
1234 ==24023== did not recognise. There are two possible reasons for this.
1235 ==24023== 1. Your program has a bug and erroneously jumped to a non-code
1236 ==24023== location. If you are running Memcheck and you just saw a
1237 ==24023== warning about a bad jump, it's probably your program's fault.
1238 ==24023== 2. The instruction is legitimate but Valgrind doesn't handle it,
1239 ==24023== i.e. it's Valgrind's fault. If you think this is the case or
1240 ==24023== you are not sure, please let us know.
1241 ==24023== Either way, Valgrind will now raise a SIGILL signal which will
1242 ==24023== probably kill your program.
1244 ==24023== Process terminating with default action of signal 4 (SIGILL)
1245 ==24023== Illegal opcode at address 0x420D234
1246 ==24023== at 0x420D234: abort (abort.c:124)
1249 This is the sign that you didn't used the exception mecanism well. Most
1250 probably, you have a <tt>return;</tt> somewhere within a <tt>TRY{}</tt>
1251 block. This is <b>evil</b>, and you must not do this. Did you read the section
1254 \subsubsection faq_trouble_vg_libc Valgrind spits tons of errors about backtraces!
1256 It may happen that valgrind, the memory debugger beloved by any decent C
1257 programmer, spits tons of warnings like the following :
1258 \verbatim ==8414== Conditional jump or move depends on uninitialised value(s)
1259 ==8414== at 0x400882D: (within /lib/ld-2.3.6.so)
1260 ==8414== by 0x414EDE9: (within /lib/tls/i686/cmov/libc-2.3.6.so)
1261 ==8414== by 0x400B105: (within /lib/ld-2.3.6.so)
1262 ==8414== by 0x414F937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
1263 ==8414== by 0x4150F4C: (within /lib/tls/i686/cmov/libc-2.3.6.so)
1264 ==8414== by 0x400B105: (within /lib/ld-2.3.6.so)
1265 ==8414== by 0x415102D: __libc_dlopen_mode (in /lib/tls/i686/cmov/libc-2.3.6.so)
1266 ==8414== by 0x412D6B9: backtrace (in /lib/tls/i686/cmov/libc-2.3.6.so)
1267 ==8414== by 0x8076446: xbt_dictelm_get_ext (dict_elm.c:714)
1268 ==8414== by 0x80764C1: xbt_dictelm_get (dict_elm.c:732)
1269 ==8414== by 0x8079010: xbt_cfg_register (config.c:208)
1270 ==8414== by 0x806821B: MSG_config (msg_config.c:42)
1273 This problem is somewhere in the libc when using the backtraces and there is
1274 very few things we can do ourselves to fix it. Instead, here is how to tell
1275 valgrind to ignore the error. Add the following to your ~/.valgrind.supp (or
1276 create this file on need). Make sure to change the obj line according to
1277 your personnal mileage (change 2.3.6 to the actual version you are using,
1278 which you can retrieve with a simple "ls /lib/ld*.so").
1281 name: Backtrace madness
1283 obj:/lib/ld-2.3.6.so
1288 fun:__libc_dlopen_mode
1291 Then, you have to specify valgrind to use this suppression file by passing
1292 the <tt>--suppressions=$HOME/.valgrind.supp</tt> option on the command line.
1293 You can also add the following to your ~/.bashrc so that it gets passed
1294 automatically. Actually, it passes a bit more options to valgrind, and this
1295 happen to be my personnal settings. Check the valgrind documentation for
1298 \verbatim export VALGRIND_OPTS="--leak-check=yes --leak-resolution=high --num-callers=40 --tool=memcheck --suppressions=$HOME/.valgrind.supp" \endverbatim
1300 \subsection faq_deadlock There is a deadlock in my code!!!
1302 Unfortunately, we cannot debug every code written in SimGrid. We
1303 furthermore believe that the framework provides ways enough
1304 information to debug such informations yourself. If the textual output
1305 is not enough, Make sure to check the \ref faq_visualization FAQ entry to see
1306 how to get a graphical one.
1308 Now, if you come up with a really simple example that deadlocks and
1309 you're absolutely convinced that it should not, you can ask on the
1310 list. Just be aware that you'll be severely punished if the mistake is
1311 on your side... We have plenty of FAQ entries to redact and new
1312 features to implement for the impenitents! ;)
1314 \subsection faq_surf_network_latency I get weird timings when I play with the latencies.
1316 OK, first of all, remember that units should be Bytes, Flops and
1317 Seconds. If you don't use such units, some SimGrid constants (e.g. the
1318 SG_TCP_CTE_GAMMA constant used in most network models) won't have the
1319 right unit and you'll end up with weird results.
1321 Here is what happens with a single transfer of size L on a link
1322 (bw,lat) when nothing else happens.
1325 0-----lat--------------------------------------------------t
1326 |-----|**** real_bw =min(bw,SG_TCP_CTE_GAMMA/(2*lat)) *****|
1329 In more complex situations, this min is the solution of a complex
1330 max-min linear system. Have a look
1331 <a href="http://lists.gforge.inria.fr/pipermail/simgrid-devel/2006-April/thread.html">here</a>
1332 and read the two threads "Bug in SURF?" and "Surf bug not
1333 fixed?". You'll have a few other examples of such computations. You
1334 can also read "A Network Model for Simulation of Grid Application" by
1335 Henri Casanova and Loris Marchal to have all the details. The fact
1336 that the real_bw is smaller than bw is easy to understand. The fact
1337 that real_bw is smaller than SG_TCP_CTE_GAMMA/(2*lat) is due to the
1338 window-based congestion mechanism of TCP. With TCP, you can't exploit
1339 your huge network capacity if you don't have a good round-trip-time
1340 because of the acks...
1342 Anyway, what you get is t=lat + L/min(bw,SG_TCP_CTE_GAMMA/(2*lat)).
1344 * if I you set (bw,lat)=(100 000 000, 0.00001), you get t = 1.00001 (you fully
1346 * if I you set (bw,lat)=(100 000 000, 0.0001), you get t = 1.0001 (you're on the
1348 * if I you set (bw,lat)=(100 000 000, 0.001), you get t = 10.001 (ouch!)
1350 This bound on the effective bandwidth of a flow is not the only thing
1351 that may make your result be unexpected. For example, two flows
1352 competing on a saturated link receive an amount of bandwidth inversely
1353 proportional to their round trip time.
1355 \subsection faq_bugrepport So I've found a bug in SimGrid. How to report it?
1357 We do our best to make sure to hammer away any bugs of SimGrid, but this is
1358 still an academic project so please be patient if/when you find bugs in it.
1359 If you do, the best solution is to drop an email either on the simgrid-user
1360 or the simgrid-devel mailing list and explain us about the issue. You can
1361 also decide to open a formal bug report using the
1362 <a href="https://gforge.inria.fr/tracker/?atid=165&group_id=12&func=browse">relevant
1363 interface</a>. You need to login on the server to get the ability to submit
1366 We will do our best to solve any problem repported, but you need to help us
1367 finding the issue. Just telling "it segfault" isn't enough. Telling "It
1368 segfaults when running the attached simulator" doesn't really help either.
1369 You may find the following article interesting to see how to repport
1370 informative bug repports:
1371 http://www.chiark.greenend.org.uk/~sgtatham/bugs.html (it is not SimGrid
1372 specific at all, but it's full of good advices).
1374 \author Arnaud Legrand (arnaud.legrand::imag.fr)
1375 \author Martin Quinson (martin.quinson::loria.fr)