Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f163d712f3922064452329cae6ab6eb03f057bad
[simgrid.git] / doc / FAQ.doc
1 /*! \page faq Frequently Asked Questions
2
3 \htmlinclude .FAQ.doc.toc
4
5 \section faq_simgrid I'm new to SimGrid. I have some questions. Where should I start?
6
7 You are at the right place... Having a look to these
8 <a href="http://www.loria.fr/~quinson/articles/simgrid-tutorial.pdf">the tutorial slides</a> 
9 (or to these <a href="http://graal.ens-lyon.fr/~alegrand/articles/slides_g5k_simul.pdf">old slides</a>,
10 or to these
11 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">"obsolete" slides</a>)
12 may give you some insights on what SimGrid can help you to do and what
13 are its limitations. Then you definitely should read the \ref
14 MSG_examples. The \ref GRAS_tut can also help you.
15
16 If you are stuck at any point and if this FAQ cannot help you, please drop us a
17 mail to the user mailing list: <simgrid-user@lists.gforge.inria.fr>.
18
19 \subsection faq_interfaces What is the difference between MSG, SimDag, and GRAS? Do they serve the same purpose?
20
21 It depend on how you define "purpose", I guess ;)
22
23 They all allow you to build a prototype of application which you can run
24 within the simulator afterward. They all share the same simulation kernel,
25 which is the core of the SimGrid project. They differ by the way you express
26 your application.
27
28 With SimDag, you express your code as a collection of interdependent
29 parallel tasks. So, in this model, applications can be seen as a DAG of
30 tasks. This is the interface of choice for people wanting to port old
31 code designed for SimGrid v1 or v2 to the framework current version.
32
33 With both GRAS and MSG, your application is seen as a set of communicating
34 processes, exchanging data by the way of messages and performing computation
35 on their own.
36
37 The difference between both is that MSG is somehow easier to use, but GRAS
38 is not limited to the simulator. Once you're done writing your GRAS code,
39 you can run your code both in the simulator or on a real platform. For this,
40 there is two implementations of the GRAS interface, one for simulation, one
41 for real execution. So, you just have to relink your code to chose one of
42 both world. 
43
44 \subsection faq_generic First steps with SimGrid
45
46 If you decide to go for the MSG interface, please read carefully the
47 \ref MSG_examples. You'll find in \ref MSG_ex_master_slave a very
48 simple consisting of a master (that owns a bunch of tasks and
49 distributes them) , some slaves (that process tasks whenever they
50 receive one) and some forwarder agents (that simply pass the tasks
51 they receive to some slaves).
52
53 If you decide to go for the GRAS interface, you should definitively
54 read the \ref GRAS_tut. The first section constitutes an introduction
55 to the tool and presents the model we use. The second section
56 constitutes a complete step-by-step tutorial building a distributed
57 application from the beginning and exemplifying most of the GRAS
58 features in the process. The last section groups some HOWTOS
59 highlighting a given feature of the framework in a more concise way.
60
61 If you decide to go for another interface, I'm afraid your only sources
62 of information will be the source code and the mailing lists...
63
64 \subsection faq_visualization Visualizing and analyzing the results
65
66 It is sometime convenient to "see" how the agents are behaving. If you
67 like colors, you can use <tt>tools/MSG_visualization/colorize.pl </tt>
68 as a filter to your MSG outputs. It works directly with INFO. Beware,
69 INFO() prints on stderr. Do not forget to redirect if you want to
70 filter (e.g. with bash): 
71 \verbatim 
72 ./msg_test small_platform.xml small_deployment.xml 2>&1 | ../../tools/MSG_visualization/colorize.pl
73 \endverbatim
74
75 We also have a more graphical output. Have a look at MSG_paje_output(). It 
76 generates an input to <a href="http://www-id.imag.fr/Logiciels/paje/">Paje</a>.
77 <center>
78 \htmlonly
79  <a href="Paje_MSG_screenshot.jpg"><img src="Paje_MSG_screenshot_thn.jpg"></a>
80 \endhtmlonly
81 </center>
82
83 Visualization with Paje can be seen as a kind of postmortem
84 analysis. However, as soon as you start playing with big simulations,
85 you'll realize that processing such output is kind of tricky. There is
86 so much generic information that it is hard to find the information
87 you are looking for.
88
89 As a matter of fact, logging really depends on simulations (e.g. what
90 kind of events is important...). That is why we do not propose a big
91 dump of your whole simulation (it would slow everything down) but give
92 you neat tools to structure you logs. Have a look at \ref XBT_log. In
93 fact, rather than a post-mortem analysis, you may want to do it on the
94 fly. The process you are running can do whatever you want. Have you
95 thought about adding a global structure where you directly compute the
96 information that are really important rather than writing everything
97 down and then processing huge files?
98
99 \subsection faq_C Argh! Do I really have to code in C?
100
101 Up until now, there is no binding for other languages. If you use C++,
102 you should be able to use the SimGrid library as a standard C library
103 and everything should work fine (simply <i>link</i> against this
104 library; recompiling SimGrid with a C++ compiler won't work and it
105 wouldn't help if you could).
106
107 In fact, we are currently working on Java bindings of MSG to allow
108 all the undergrad students of the world to use this tool. This is a
109 little more tricky than I would have expected, but the work is moving
110 fast forward [2006/05/13]. More languages are evaluated, but for now,
111 we do not feel a real demand for any other language. Please speak up!
112
113 \section faq_installation Installing the SimGrid library
114
115 Many people have been asking me questions on how to use SimGrid. Quite
116 often, the questions were not really about SimGrid but on the
117 installation process. This section is intended to help people that are
118 not familiar with compiling C files under UNIX. If you follow these
119 instructions and still have some troubles, drop an e-mail to
120 <simgrid-user@lists.gforge.inria.fr>.
121
122 \subsection faq_compiling Compiling SimGrid from a stable archive
123
124 First of all, you need to download the latest version of SimGrid from 
125 <a href="http://gforge.inria.fr/frs/?group_id=12">here</a>.
126 Suppose you have uncompressed SimGrid in some temporary location of
127 your home directory (say <tt>/home/joe/tmp/simgrid-3.0.1 </tt>). The
128 simplest way to use SimGrid is to install it in your home
129 directory. Change your directory to
130 <tt>/home/joe/tmp/simgrid-3.0.1</tt> and type
131
132 \verbatim
133 ./configure --prefix=$HOME
134 make
135 make install
136 \endverbatim
137
138 If at some point, something fails, check the section \ref faq_trouble_compil .
139 If it does not help, you can report this problem to the
140 list but, please, avoid sending a laconic mail like "There is a problem. Is it
141 okay?". Send the config.log file which is automatically generated by
142 configure. Try to capture both the standard output and the error output of the
143 <tt>make</tt> command with <tt>script</tt>. There is no way for us to help you
144 without the relevant bits of information.
145
146 Now, the following directory should have been created : 
147
148       \li <tt>/home/joe/doc/simgrid/html/</tt>
149       \li <tt>/home/joe/lib/</tt>
150       \li <tt>/home/joe/include/</tt>
151
152 SimGrid is not a binary, it is a library. Both a static and a dynamic
153 version are available. Here is what you can find if you try a <tt>ls
154 /home/joe/lib</tt>:
155
156 \verbatim libsimgrid.a libsimgrid.la libsimgrid.so libsimgrid.so.0 libsimgrid.so.0.0.1
157 \endverbatim
158
159 Thus, there is two ways to link your program with SimGrid:
160       \li Either you use the static version, e.g 
161 \verbatim gcc libsimgrid.a -o MainProgram MainProgram.c
162 \endverbatim
163           In this case, all the SimGrid functions are directly
164           included in <tt>MainProgram</tt> (hence a bigger binary).
165       \li Either you use the dynamic version (the preferred method)
166 \verbatim gcc -lsimgrid -o MainProgram MainProgram.c
167 \endverbatim
168           In this case, the SimGrid functions are not included in
169           <tt>MainProgram</tt> and you need to set your environment
170           variable in such a way that <tt>libsimgrid.so</tt> will be
171           found at runtime. This can be done by adding the following
172           line in your .bashrc (if you use bash and if you have
173           installed the SimGrid libraries in your home directory):
174 \verbatim export LD_LIBRARY_PATH=$HOME/lib/:$LD_LIBRARY_PATH
175 \endverbatim
176
177 \subsection faq_compiling_java Java bindings don't get compiled
178
179 The configure script detects automatically whether you have the
180 softwares needed to use the Java bindings or not. At the end of the
181 configure, you can see the configuration picked by the script, which
182 should look similar to 
183 \verbatim Configuration of package simgrid' (version 3.3.4-svn) on
184 little64 (=4):
185
186          Compiler:       gcc (version: )
187          
188          CFlags:          -O3 -finline-functions -funroll-loops -fno-strict-aliasing -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror -g3
189          CPPFlags:   
190          LDFlags:        
191                                    
192          Context backend: ucontext
193          Compile Java: no
194                                                          
195          Maintainer mode: no
196          Supernovae mode: yes
197 \endverbatim       
198
199 In this example, Java backends won't be compiled. 
200
201 On Debian-like systems (which includes ubuntu), you need the following
202 packages: sun-java6-jdk libgcj10-dev. If you cannot find the
203 libgcj10-dev, try another version, like libgcj9-dev (on Ubuntu before
204 9.10) or libgcj11-dev (not released yet, but certainly one day).
205 Please note that you need to activate the contrib and non-free
206 repositories in Debian, and the universe ones in Ubuntu. Java comes at
207 this price...
208
209 \subsection faq_compiling_snapshoot SimGrid development snapshots
210
211 We have very high standards on software quality, and we are reluctant releasing
212 a stable release as long as there is still some known bug in the code base. In
213 addition, we added quite an extensive test base, making sure that we correctly
214 test the most important parts of the tool. 
215
216 As an unfortunate conclusion, there may be some time between the stable
217 releases. If you want to benefit from the most recent features we introduced,
218 but don't want to take the risk of an untested version from the SVN, then
219 development snapshots are done for you. 
220
221 These are pre-releases of SimGrid that still fail some tests about features
222 that almost nobody use, or on platforms not being in our core target (which is
223 Linux, Mac, other Unixes and Windows, from the most important to the less
224 one). That means that using this development releases should be safe for most
225 users. 
226
227 These archives can be found on 
228 <a href="http://www.loria.fr/~quinson/simgrid.html">this web page</a>. Once you 
229 got the lastest archive, you can compile it just like any archive (see above).
230
231 \subsection faq_compiling_svn Compiling SimGrid from the SVN
232
233 The project development takes place in the SVN, where all changes are
234 committed when they happen. Then every once in a while, we make sure that the
235 code quality meets our standard and release an archive from the code in the
236 SVN. We afterward go back to the development in the SVN. So, if you need a
237 recently added feature and can afford some little problem with the stability
238 of the lastest features, you may want to use the SVN version instead of a
239 released one.
240
241 For that, you first need to get the "simgrid" module from
242 <a href="http://gforge.inria.fr/scm/?group_id=12">here</a>. 
243
244 You won't find any <tt>configure</tt> and a few other things
245 (<tt>Makefile.in</tt>'s, documentation, ...) will be missing as well. The
246 reason for that is that all these files have to be regenerated using the
247 latest versions of <tt>autoconf</tt>, <tt>libtool</tt>, <tt>automake</tt>
248 (>1.9) and <tt>doxygen</tt> (>1.4). To generate the <tt>configure</tt> and
249 the <tt>Makefile.in</tt>'s, you just have to launch the <tt>bootstrap</tt>
250 command that resides in the top of the source tree. Then just follow the
251 instructions of Section \ref faq_compiling.
252
253 We insist on the fact that you really need the latest versions of
254 autoconf, automake and libtool. Doing this step on exotic architectures/systems
255 (i.e. anything different from a recent linux distribution) may be
256 ... uncertain. If you need to compile the SVN version on a machine where all these
257 dependencies are not met, the easiest is to do <tt>make dist</tt> in the SVN
258 directory of another machine where all dependencies are met. It will create an
259 archive you may deploy on other sites just as a regular stable release.
260
261 In summary, the following commands will checkout the SVN, regenerate the
262 configure script and friends, configure SimGrid and build it.
263
264 \verbatim svn checkout svn://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk simgrid
265 cd simgrid
266 ./bootstrap
267 ./configure --enable-maintainer-mode --prefix=<where to install SimGrid>
268 make \endverbatim
269
270 Then, if you want to install SimGrid on the current box, just do:
271 \verbatim make install \endverbatim
272
273 If you want to build an snapshot of the SVN to deploy it on another box (for
274 example because the other machine don't have the autotools), do:
275 \verbatim make dist \endverbatim
276
277 Moreover, you should never call the autotools manually since you must run
278 them in a specific order with specific arguments. Most of the times, the
279 makefiles will automatically call the tools for you. When it's not possible
280 (such as the first time you checkout the SVN), use the ./bootstrap command
281 to call them explicitly.
282
283
284 \subsection faq_setting_MSG Setting up your own MSG code
285
286 Do not build your simulator by modifying the SimGrid examples.  Go
287 outside the SimGrid source tree and create your own working directory
288 (say <tt>/home/joe/SimGrid/MyFirstScheduler/</tt>).
289
290 Suppose your simulation has the following structure (remember it is
291 just an example to illustrate a possible way to compile everything;
292 feel free to organize it as you want).
293
294       \li <tt>sched.h</tt>: a description of the core of the
295           scheduler (i.e. which functions are can be used by the
296           agents). For example we could find the following functions
297           (master, forwarder, slave).
298
299       \li <tt>sched.c</tt>: a C file including <tt>sched.h</tt> and
300           implementing the core of the scheduler. Most of these
301           functions use the MSG functions defined in section \ref
302           msg_gos_functions.
303
304       \li <tt>masterslave.c</tt>: a C file with the main function, i.e.
305           the MSG initialization (MSG_global_init()), the platform
306           creation (e.g. with MSG_create_environment()), the
307           deployment phase (e.g. with MSG_function_register() and
308           MSG_launch_application()) and the call to
309           MSG_main()).
310
311 To compile such a program, we suggest to use the following
312 Makefile. It is a generic Makefile that we have used many times with
313 our students when we teach the C language.
314
315 \verbatim
316 all: masterslave 
317 masterslave: masterslave.o sched.o
318
319 INSTALL_PATH = $$HOME
320 CC = gcc
321 PEDANTIC_PARANOID_FREAK =       -O0 -Wshadow -Wcast-align \
322                                 -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
323                                 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
324                                 -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
325                                 -Wpointer-arith -Wwrite-strings -finline-functions
326 REASONABLY_CAREFUL_DUDE =       -Wall
327 NO_PRAYER_FOR_THE_WICKED =      -w -O2 
328 WARNINGS =                      $(REASONABLY_CAREFUL_DUDE)
329 CFLAGS = -g $(WARNINGS)
330
331 INCLUDES = -I$(INSTALL_PATH)/include
332 DEFS = -L$(INSTALL_PATH)/lib/
333 LDADD = -lm -lsimgrid 
334 LIBS = 
335
336 %: %.o
337         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ 
338
339 %.o: %.c
340         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
341
342 clean:
343         rm -f $(BIN_FILES) *.o *~
344 .SUFFIXES:
345 .PHONY : clean
346
347 \endverbatim
348
349 The first two lines indicates what should be build when typing make
350 (<tt>masterslave</tt>) and of which files it is to be made of
351 (<tt>masterslave.o</tt> and <tt>sched.o</tt>). This makefile assumes
352 that you have set up correctly your <tt>LD_LIBRARY_PATH</tt> variable
353 (look, there is a <tt>LDADD = -lm -lsimgrid</tt>). If you prefer using
354 the static version, remove the <tt>-lsimgrid</tt> and add a
355 <tt>$(INSTALL_PATH)/lib/libsimgrid.a</tt> on the next line, right
356 after the <tt>LIBS = </tt>.
357
358 More generally, if you have never written a Makefile by yourself, type
359 in a terminal : <tt>info make</tt> and read the introduction. The
360 previous example should be enough for a first try but you may want to
361 perform some more complex compilations...
362
363 \subsection faq_setting_GRAS Setting up your own GRAS code
364
365 If you use the GRAS interface instead of the MSG one, then previous section
366 is not the better source of information. Instead, you should check the GRAS
367 tutorial in general, and the \ref GRAS_tut_tour_setup in particular.
368
369 \section faq_cmake CMAKE
370
371 \subsection faq_intro Some generalitty
372
373 \subsubsection faq_intro1 What is Cmake?
374
375 CMake is a family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. For more information see official web site <a href="http://www.cmake.org/">here</a>.
376
377 \subsubsection faq_intro2 Why cmake?
378
379 CMake permits to developers to compil projects on different plateform. Then many tools are embedded like ctest for making test, a link to cdash for vizualise results but also test coverage and bug reports. 
380
381 \subsubsection faq_intro3 What cmake need?
382
383 CMake needs some prerequists like :
384   \li make
385   \li c, c++ and java compiler regards to developers
386   \li ccmake for graphical used of CMake
387   \li cmake <a href="http://www.cmake.org/cmake/resources/software.html">(download page)</a>
388
389 \subsubsection faq_intro4 Cmake vs Autotools...
390
391 TODO
392
393 \subsection faq_cmakeoption Cmake options
394
395 \subsubsection faq_cmakeoption1 Liste of options
396
397 \verbatim
398 "cmake -D[name]=[value] ... ./"
399  
400 [name]          disable_gtnets                  [value] ON/OFF or TRUE/FALSE or 1/0
401                 disable_java                            ON/OFF or TRUE/FALSE or 1/0
402                 disable_lua                             ON/OFF or TRUE/FALSE or 1/0
403                 disable_ruby                            ON/OFF or TRUE/FALSE or 1/0
404
405                 enable_compile_optimizations            ON/OFF or TRUE/FALSE or 1/0
406                 enable_compile_warnings                 ON/OFF or TRUE/FALSE or 1/0
407                 enable_maintainer_mode                  ON/OFF or TRUE/FALSE or 1/0
408                 enable_supernovae                       ON/OFF or TRUE/FALSE or 1/0
409                 enable_tracing                          ON/OFF or TRUE/FALSE or 1/0
410                 enable_coverage                         ON/OFF or TRUE/FALSE or 1/0
411                 enable_memcheck                         ON/OFF or TRUE/FALSE or 1/0 
412                 enable_print_message                    ON/OFF or TRUE/FALSE or 1/0
413
414                 gtnets_path                             <path_to_gtnets_directory>
415                 prefix                                  <path_to_install_directory>
416                 BIBTEX2HTML                             <path_to_bibtex2html>
417                 with_context                            auto/ucontext/pthread/window     
418 \endverbatim
419                                                                                                                                                           
420 \subsubsection faq_cmakeoption2 Options explaination
421
422   \li disable_gtnets : set to true implie that user doesn't want to use gtnets.
423
424   \li disable_java : set to true implie that user doesn't want to add java langage into simgrid compilation.
425
426   \li disable_lua : set to true implie that user doesn't want to add lua langage into simgrid compilation.
427
428   \li disable_ruby : set to true implie that user doesn't want to add ruby langage into simgrid compilation.
429
430   \li enable_compile_optimizations : add flags "-O3 -finline-functions -funroll-loops -fno-strict-aliasing"
431
432   \li enable_compile_warnings : add flags "-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror"
433
434   \li enable_maintainer_mode : set to true it remakes some files.
435 \verbatim
436 include/surf/simgrid_dtd.h
437 include/xbt/graphxml.h
438
439 src/cunit_unit.c
440 src/ex_unit.c
441 src/dynar_unit.c
442 src/dict_unit.c
443 src/set_unit.c
444 src/swag_unit.c
445 src/xbt_str_unit.c
446 src/xbt_strbuff_unit.c
447 src/xbt_sha_unit.c
448 src/config_unit.c
449 src/xbt_synchro_unit.c
450 src/simgrid_units_main.c
451
452 src/simdag/dax_dtd.c
453 src/simdag/dax_dtd.h
454 src/simdag/dax_dtd.l
455
456 src/surf/simgrid_dtd.c
457 src/surf/simgrid_dtd.l
458
459 src/xbt/graphxml.c
460 src/xbt/graphxml.l
461
462 src/gras/DataDesc/ddt_parse.yy.c
463 \endverbatim
464   \li enable_supernovae : set to true make one file for each lib and compile with those generated files.
465 \verbatim
466 /src/supernovae_sg.c
467 /src/supernovae_gras.c                  
468 /src/supernovae_smpi.c
469 \endverbatim
470
471   \li enable_tracing : To enable the generation of simulation traces for visualization
472
473   \li enable_coverage : When set to true this option enable code coverage by setting -fprofile-arcs -ftest-coverage flags.
474
475   \li enable_memcheck : When set to true this option enable tests for memcheck.
476
477   \li enable_print_message : This option when enable permits to see variables from gras_config.h
478
479   \li gtnets_path : Path to gtnets install directory (ex /usr)
480
481   \li prefix : Path where are installed lib/ doc/ and include/ directories (ex /usr/local)
482
483   \li BIBTEX2HTML : Path where is installed bibtex2html.
484
485   \li with context : specify which context the user wants to use.
486
487 \subsubsection faq_cmakeoption3 Initialisation
488
489 Those options are initialized the first time you launch \"cmake ./\" whithout specified option.
490
491 \verbatim
492 disable_gtnets                  off
493 disable_java                    off
494 disable_lua                     off
495 disable_ruby                    off
496
497 enable_compile_optimizations    off
498 enable_compile_warnings         off
499 enable_maintainer_mode          off
500 enable_supernovae               off
501 enable_tracing                  off
502 enable_coverage                 off
503 enable_memcheck                 off
504 enable_print_message            off
505
506 gtnets_path                     null
507 prefix                          null
508 BIBTEX2HTML                     null
509 with_context                    auto
510 \endverbatim
511
512 \subsubsection faq_cmakeoption4 Option's cache and how to reset?
513
514 When options have been set they are keep into a cache file named \"CMakeCache.txt\". So if you want 
515 reset values you just delete this file located to the project directory.
516
517 \subsection faq_cmakecompilation Cmake compilation
518
519 \subsubsection faq_cmakecompilation1 With command line.
520
521 \verbatim
522 cmake -D[name]=[value] ... ./
523 make
524 \endverbatim
525
526 \subsubsection faq_cmakecompilation2 With ccmake tool.
527
528 \verbatim
529 "ccmake ./"
530 \endverbatim
531 Then follow instructions.
532
533 \subsubsection faq_cmakecompilation3 Resume of command line
534
535  \li CMake
536 \verbatim
537 cmake ./                configure the project
538 make                    build all targets
539 make VERBOSE=1          build all targets and print build command lines
540 make test               test all targets and summarize
541 make dist               make the distrib
542 make distcheck          check the dist (make + make dist + make test) 
543 make install-simgrid    install the project (doc/ lib/ include/)
544 make uninstall          uninstall the project (doc/ lib/ include/)
545 make clean              clean all targets
546 make html               Create simgrid documentation
547 make maintainer-clean   Remove all files generated by mainainer mode
548 \endverbatim
549
550 When the project have been succesfully compiling and build you can make tests.
551
552  \li CTest
553 \verbatim
554 ctest                   launch only tests
555 ctest -D Continuous
556 ctest -D Continuous(Start|Update|Configure|Build)
557 ctest -D Continuous(Test|Coverage|MemCheck|Submit)
558 ctest -D Experimental
559 ctest -D Experimental(Start|Update|Configure|Build)
560 ctest -D Experimental(Test|Coverage|MemCheck|Submit)
561 ctest -D Nightly                                
562 ctest -D Nightly(Start|Update|Configure|Build)
563 ctest -D Nightly(Test|Coverage|MemCheck|Submit)
564 ctest -D NightlyMemoryCheck
565 \endverbatim
566
567 If you want to test before make a commit you can simply make "ctest -D Experimental" and then you can visualize results submitted into Cdash. <a href="http://cdash.inria.fr/CDash/index.php?project=Simgrid">(Go to Cdash site)</a>.
568
569 \subsubsection faq_cmakecompilation4 Examples for different mode.
570
571 \li Mode maintainer
572
573 cmake -Denable_maintainer_mode=on ./
574 \verbatim GTnetS doesn't works : set -Ddisable_gtnets=on
575 with_context auto change to ucontext
576 (skaddr)
577 (sksize)
578 Make : src/simgrid.jar with : /usr/bin/javac
579 Make examples/java with : /usr/bin/javac
580
581 Configuration of package `simgrid' (revision 7228M) on arch (=4):
582         BUILDNAME :             UCONTEXT
583              SITE :             Linux_Ubuntu 9.10_x86_64
584
585         Compiler: c++ :         /usr/bin/c++
586                version:         c++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
587                   c   :         /usr/bin/gcc
588                version:         gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1
589
590         CFlags:                 -g3
591         CPPFlags:               
592         LDFlags:                
593
594         Context backend:        ucontext
595         Compile Gtnets:         0
596                   path:         
597         Compile Java:           1
598         Compile Lua:            1
599         Compile Ruby:           0
600
601         Maintainer mode:        on
602         Supernovae mode:        off
603
604         Simgrid dependencies:   dl -llua5.1
605         Gras dependencies:      pthread
606         Ruby dependencies:      
607         Smpi dependencies:      
608
609         USER_PREFIX:            /usr/local
610         INSTALL_PREFIX:         /usr/local
611
612 -- Configuring done
613 -- Generating done
614 -- Build files have been written to: /home/navarrop/Bureau/simgrid-trunk
615 \endverbatim
616
617 \li Mode supernovae
618
619 cmake -Dsupernovae=on ./
620 \verbatim GTnetS doesn't works : set -Ddisable_gtnets=on
621 with_context auto change to ucontext
622 (skaddr)
623 (sksize)
624 Make : src/simgrid.jar with : /usr/bin/javac
625 Make examples/java with : /usr/bin/javac
626
627 Configuration of package `simgrid' (revision 7228M) on arch (=4):
628         BUILDNAME :             SUPERNOVAE
629              SITE :             Linux_Ubuntu 9.10_x86_64
630
631         Compiler: c++ :         /usr/bin/c++
632                version:         c++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
633                   c   :         /usr/bin/gcc
634                version:         gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1
635
636         CFlags:                 -O3 -finline-functions -funroll-loops -fno-strict-aliasing -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror -g3
637         CPPFlags:               
638         LDFlags:                
639
640         Context backend:        ucontext
641         Compile Gtnets:         0
642                   path:         
643         Compile Java:           1
644         Compile Lua:            1
645         Compile Ruby:           0
646
647         Maintainer mode:        off
648         Supernovae mode:        on
649
650         Simgrid dependencies:   dl -llua5.1
651         Gras dependencies:      pthread
652         Ruby dependencies:      
653         Smpi dependencies:      
654
655         USER_PREFIX:            /usr/local
656         INSTALL_PREFIX:         /usr/local
657
658 -- Configuring done
659 -- Generating done
660 -- Build files have been written to: /home/navarrop/Bureau/simgrid-trunk
661 \endverbatim
662
663 \li Mode GTnetS
664
665 cmake -Dgtnets_path=/home/navarrop/Bureau/usr/ ./
666 \verbatim with_context auto change to ucontext
667 (skaddr)
668 (sksize)
669 Make : src/simgrid.jar with : /usr/bin/javac
670 Make examples/java with : /usr/bin/javac
671
672 Configuration of package `simgrid' (revision 7228M) on arch (=4):
673         BUILDNAME :             GTNETS
674              SITE :             Linux_Ubuntu 9.10_x86_64
675
676         Compiler: c++ :         /usr/bin/c++
677                version:         c++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
678                   c   :         /usr/bin/gcc
679                version:         gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1
680
681         CFlags:                  -L/home/navarrop/Bureau/usr/lib -I/home/navarrop/Bureau/usr/include/gtnets -g3
682         CPPFlags:                -L/home/navarrop/Bureau/usr/lib -I/home/navarrop/Bureau/usr/include/gtnets 
683         LDFlags:                
684
685         Context backend:        ucontext
686         Compile Gtnets:         1
687                   path:         /home/navarrop/Bureau/usr
688         Compile Java:           1
689         Compile Lua:            1
690         Compile Ruby:           0
691
692         Maintainer mode:        off
693         Supernovae mode:        off
694
695         Simgrid dependencies:   dl -llua5.1 -lgtnets
696         Gras dependencies:      pthread
697         Ruby dependencies:      
698         Smpi dependencies:      
699
700         USER_PREFIX:            /usr/local
701         INSTALL_PREFIX:         /usr/local
702
703 INFO -->> Take care to have export LD_LIBRARY_PATH before run make command for make examples with gtnets
704 copy and paste : export LD_LIBRARY_PATH=/home/navarrop/Bureau/usr/lib/:$LD_LIBRARY_PATH
705
706
707 -- Configuring done
708 -- Generating done
709 -- Build files have been written to: /home/navarrop/Bureau/simgrid-trunk
710 \endverbatim
711
712 \subsection faq_cmakeinstall How to install with cmake?
713
714 \subsubsection faq_cmakeinstall1 From svn. 
715
716 \verbatim
717 cmake -Denable_maintainer_mode=on -Dprefix=/home/navarrop/Bureau/install_simgrid ./
718 make 
719 make install-simgrid
720 \endverbatim
721
722 \subsubsection faq_cmakeinstall2 From a distrib
723
724 \verbatim
725 cmake -Dprefix=/home/navarrop/Bureau/install_simgrid ./
726 make
727 make install-simgrid
728 \endverbatim
729
730 \subsection faq_screenshot Screenshot
731
732 \verbatim
733 navarrop@caraja:~$ cd Bureau/simgrid-trunk/
734 navarrop@caraja:~/Bureau/simgrid-trunk$ cmake ./
735
736 GTnetS doesn't works : set -Ddisable_gtnets=on                  <-|some warnings are printed 
737 with_context auto change to ucontext                            <-|
738 (skaddr)                                                        <--info (needed)
739 (sksize)                                                        <--info (needed)
740 Make : src/simgrid.jar with : /usr/bin/javac                    <--info (if java)
741 Make examples/java with : /usr/bin/javac                        <--info (if java)
742
743 Configuration of package `simgrid' (revision 7209M) on arch (=4):
744         BUILDNAME :             UCONTEXT                                <-- name of the compilation regarding to cdash
745              SITE :             Linux_Ubuntu 9.10_x86_64                <-- distribution of the local machine regarding to cdash
746
747         Compiler: c++ :         /usr/bin/c++
748                version:         c++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
749                   c   :         /usr/bin/gcc
750                version:         gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1
751
752         CFlags:                 -g3
753         CPPFlags:               
754         LDFlags:                
755
756         Context backend:        ucontext
757         Compile Gtnets:         0
758                   path:         
759         Compile Java:           1
760         Compile Lua:            1
761         Compile Ruby:           0
762
763         Maintainer mode:        OFF
764         Supernovae mode:        OFF
765
766         Simgrid dependencies:   -ldl -llua5.1
767         Gras dependencies:      pthread
768         Ruby dependencies:      
769         Smpi dependencies:      
770
771         USER_PREFIX:            /usr/local
772         INSTALL_PREFIX:         /usr/local
773
774 -- Configuring done
775 -- Generating done
776 -- Build files have been written to: /home/navarrop/Bureau/simgrid-trunk
777 \endverbatim
778 Here all options are checked and printed. If it doesn't match with your configuration 
779 it is probably due to a wrong configuration.
780
781 \subsection faq_cmakehowto How to modified sources files for developers
782
783 \subsubsection faq_cmakehowto1 Add an executable or examples.
784
785 If you want make an executable you have to create a CMakeList.txt to the src directory. 
786 You must specified where to create the executable, source list, dependencies and the name of the binary.
787
788 \verbatim
789 cmake_minimum_required(VERSION 2.6)
790
791 set(EXECUTABLE_OUTPUT_PATH "./")                        
792 set(LIBRARY_OUTPUT_PATH "${PROJECT_DIRECTORY}/lib")
793
794 add_executable(get_sender get_sender.c)                                 #add_executable(<name_of_target> <src list>)
795
796 ### Add definitions for compile
797 target_link_libraries(get_sender simgrid m pthread -fprofile-arcs)      #target_link_libraries(<name_of_targe> <dependencies>)
798 \endverbatim
799
800 Then you have to modified <project/directory>/buildtools/Cmake/src/CMakeMakeExeLib.txt and add 
801 this line :
802 \verbatim
803 add_subdirectory(${PROJECT_DIRECTORY}/<path_where_is_CMakeList.txt>)
804 \endverbatim
805
806 \subsubsection faq_cmakehowto2 Delete/add sources to lib.
807
808 If you want modified, add or delete source files from a library you have to edit <project/directory>/buildtools/Cmake/src/CMakeDefinePackages.txt
809
810 \verbatim
811 set(JMSG_JAVA_SRC
812         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/MsgException.java
813         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/JniException.java
814         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/NativeException.java
815         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/HostNotFoundException.java
816         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/ProcessNotFoundException.java
817         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/Msg.java
818         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/Process.java
819         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/Host.java
820         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/Task.java
821         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/MsgNative.java
822         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/ApplicationHandler.java
823         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/Sem.java
824 )
825 \endverbatim
826
827 \subsubsection faq_cmakehowto3 Add test
828
829 If you want modified, add or delete tests you have to edit <project/directory>/buildtools/Cmake/src/CMakeTest.txt 
830 with this function : ADD_TEST(<name> <bin> <ARGS>)
831
832 \verbatim
833 add_test(test-simdag-1 ${PROJECT_DIRECTORY}/testsuite/simdag/sd_test --cfg=path:${PROJECT_DIRECTORY}/testsuite/simdag small_platform_variable.xml)
834 \endverbatim
835
836 \subsection faq_cmakeExplain Explaination of sources files for cmake
837
838 \li CMakeLists.txt
839
840 Those files are the "main parts". One located at the project directory call all the cmake sources files. The others
841 are little projects called by the first for make examples.
842
843 \li CMakeCompleteInFiles.txt
844
845 Complete all .in files and define Variables for h files
846
847 \li CMakeDocs.txt
848
849 This file make the html documentation.
850
851 \li CMakeMakeExeLib.txt
852
853 Here are callled all "CMakeLists.txt" for make executables and libraries.
854
855 \li CMakePrintArgs.txt
856
857 This file is called at the end of the build for summarize environment variables.
858
859 \li CMakeDefinePackages.txt
860
861 Here is defined sources packages for compiling libs.
862
863 \li CMakeFlags.txt
864
865 Defined flags which are used for compiling sources.
866
867 \li CMakeSupernovae.txt
868
869 Here are made files for the supernovae mode.
870
871 \li CMakeDistrib.txt
872
873 Here is defined packages for install simgrid and make a distribution.
874
875 \li CMakeMaintainerMode.txt
876
877 Part where are generated source files for maintainer mode.
878
879 \li CMakeOption.txt
880
881 Here are defined options and initialized values.
882
883 \li CMakeTest.txt
884
885 All tests are listed.
886
887 \li CTestConfig.cmake
888
889 Properties which link tests with dashboard.
890
891 \subsection faq_cmakeList List of files added for cmake
892
893 Here is a list of files involved into cmake build (relative to project directory path) :
894 \verbatim
895
896 Cmake sources:
897         ./doc/CMakeLists.txt
898         ./buildtools/Cmake/src/CMakeCompleteInFiles.txt
899         ./buildtools/Cmake/src/CMakeDocs.txt
900         ./buildtools/Cmake/src/CMakeMakeExeLib.txt
901         ./buildtools/Cmake/src/CMakePrintArgs.txt
902         ./buildtools/Cmake/src/CMakeDefinePackages.txt
903         ./buildtools/Cmake/src/CMakeFlags.txt
904         ./buildtools/Cmake/src/CMakeSupernovae.txt
905         ./buildtools/Cmake/src/CMakeDistrib.txt
906         ./buildtools/Cmake/src/CMakeMaintainerMode.txt
907         ./buildtools/Cmake/src/CMakeOption.txt
908         ./buildtools/Cmake/src/CMakeTest.txt
909         ./buildtools/Cmake/src/CTestConfig.cmake
910
911 Test files for define properties :
912         ./buildtools/Cmake/prog_test/prog_GRAS_ARCH.c
913         ./buildtools/Cmake/prog_test/prog_max_size.c
914         ./buildtools/Cmake/prog_test/prog_sem_init.c
915         ./buildtools/Cmake/prog_test/prog_stackgrowth.c
916         ./buildtools/Cmake/prog_test/prog_vsnprintf.c
917         ./buildtools/Cmake/prog_test/prog_AC_CHECK_MCSC.c
918         ./buildtools/Cmake/prog_test/prog_GRAS_CHECK_STRUCT_COMPACTION.c
919         ./buildtools/Cmake/prog_test/prog_mutex_timedlock.c
920         ./buildtools/Cmake/prog_test/prog_sem_timedwait.c
921         ./buildtools/Cmake/prog_test/prog_stacksetup.c
922         ./buildtools/Cmake/prog_test/prog_getline.c
923         ./buildtools/Cmake/prog_test/prog_gtnets.cpp
924         ./buildtools/Cmake/prog_test/prog_printf_null.c
925         ./buildtools/Cmake/prog_test/prog_snprintf.c
926         ./buildtools/Cmake/prog_test/prog_va_copy.c
927
928 CMakeLists for each binaries or examples:
929         ./CMakeLists.txt
930         ./src/CMakeLists.txt
931         ./teshsuite/gras/empty_main/CMakeLists.txt
932         ./teshsuite/gras/small_sleep/CMakeLists.txt
933         ./teshsuite/gras/datadesc/CMakeLists.txt
934         ./teshsuite/gras/msg_handle/CMakeLists.txt
935         ./teshsuite/simdag/CMakeLists.txt
936         ./teshsuite/simdag/partask/CMakeLists.txt
937         ./teshsuite/simdag/platforms/CMakeLists.txt
938         ./teshsuite/simdag/network/CMakeLists.txt
939         ./teshsuite/simdag/network/mxn/CMakeLists.txt
940         ./teshsuite/simdag/network/p2p/CMakeLists.txt
941         ./teshsuite/xbt/CMakeLists.txt
942         ./teshsuite/msg/CMakeLists.txt
943         ./tools/gras/CMakeLists.txt
944         ./tools/tesh/CMakeLists.txt
945         ./testsuite/simdag/CMakeLists.txt
946         ./testsuite/xbt/CMakeLists.txt
947         ./testsuite/surf/CMakeLists.txt
948         ./examples/gras/properties/CMakeLists.txt
949         ./examples/gras/ping/CMakeLists.txt
950         ./examples/gras/pmm/CMakeLists.txt
951         ./examples/gras/mmrpc/CMakeLists.txt
952         ./examples/gras/synchro/CMakeLists.txt
953         ./examples/gras/timer/CMakeLists.txt
954         ./examples/gras/mutual_exclusion/simple_token/CMakeLists.txt
955         ./examples/gras/spawn/CMakeLists.txt
956         ./examples/gras/chrono/CMakeLists.txt
957         ./examples/gras/rpc/CMakeLists.txt
958         ./examples/gras/all2all/CMakeLists.txt
959         ./examples/simdag/properties/CMakeLists.txt
960         ./examples/simdag/CMakeLists.txt
961         ./examples/simdag/metaxml/CMakeLists.txt
962         ./examples/simdag/dax/CMakeLists.txt
963         ./examples/smpi/CMakeLists.txt
964         ./examples/amok/bandwidth/CMakeLists.txt
965         ./examples/amok/saturate/CMakeLists.txt
966         ./examples/msg/priority/CMakeLists.txt
967         ./examples/msg/properties/CMakeLists.txt
968         ./examples/msg/migration/CMakeLists.txt
969         ./examples/msg/gtnets/CMakeLists.txt
970         ./examples/msg/parallel_task/CMakeLists.txt
971         ./examples/msg/trace/CMakeLists.txt
972         ./examples/msg/suspend/CMakeLists.txt
973         ./examples/msg/masterslave/CMakeLists.txt
974         ./examples/msg/actions/CMakeLists.txt
975         ./examples/msg/sendrecv/CMakeLists.txt
976 \endverbatim
977
978 \section faq_howto Feature related questions
979
980 \subsection faq_MIA "Could you please add (your favorite feature here) to SimGrid?"
981
982 Here is the deal. The whole SimGrid project (MSG, SURF, GRAS, ...) is
983 meant to be kept as simple and generic as possible. We cannot add
984 functions for everybody's needs when these functions can easily be
985 built from the ones already in the API. Most of the time, it is
986 possible and when it was not possible we always have upgraded the API
987 accordingly. When somebody asks us a question like "How to do that?
988 Is there a function in the API to simply do this?", we're always glad
989 to answer and help. However if we don't need this code for our own
990 need, there is no chance we're going to write it... it's your job! :)
991 The counterpart to our answers is that once you come up with a neat
992 implementation of this feature (task duplication, RPC, thread
993 synchronization, ...), you should send it to us and we will be glad to
994 add it to the distribution. Thus, other people will take advantage of
995 it (and we don't have to answer this question again and again ;).
996
997 You'll find in this section a few "Missing In Action" features. Many
998 people have asked about it and we have given hints on how to simply do
999 it with MSG. Feel free to contribute...
1000
1001 \subsection faq_MIA_MSG MSG features
1002
1003 \subsubsection faq_MIA_examples I want some more complex MSG examples!
1004
1005 Many people have come to ask me a more complex example and each time,
1006 they have realized afterward that the basics were in the previous three
1007 examples. 
1008
1009 Of course they have often been needing more complex functions like
1010 MSG_process_suspend(), MSG_process_resume() and
1011 MSG_process_isSuspended() (to perform synchronization), or
1012 MSG_task_Iprobe() and MSG_process_sleep() (to avoid blocking
1013 receptions), or even MSG_process_create() (to design asynchronous
1014 communications or computations). But the examples are sufficient to
1015 start.
1016
1017 We know. We should add some more examples, but not really some more
1018 complex ones... We should add some examples that illustrate some other
1019 functionalists (like how to simply encode asynchronous
1020 communications, RPC, process migrations, thread synchronization, ...)
1021 and we will do it when we will have a little bit more time. We have
1022 tried to document the examples so that they are understandable. Tell
1023 us if something is not clear and once again feel free to participate!
1024 :)
1025
1026 \subsubsection faq_MIA_taskdup Missing in action: MSG Task duplication/replication
1027
1028 There is no task duplication in MSG. When you create a task, you can
1029 process it or send it somewhere else. As soon as a process has sent
1030 this task, he doesn't have this task anymore. It's gone. The receiver
1031 process has got the task. However, you could decide upon receiving to
1032 create a "copy" of a task but you have to handle by yourself the
1033 semantic associated to this "duplication".
1034
1035 As we already told, we prefer keeping the API as simple as
1036 possible. This kind of feature is rather easy to implement by users
1037 and the semantic you associate really depends on people. Having a
1038 *generic* task duplication mechanism is not that trivial (in
1039 particular because of the data field). That is why I would recommand
1040 that you write it by yourself even if I can give you advice on how to
1041 do it.
1042
1043 You have the following functions to get informations about a task:
1044 MSG_task_get_name(), MSG_task_get_compute_duration(),
1045 MSG_task_get_remaining_computation(), MSG_task_get_data_size(),
1046 and MSG_task_get_data().
1047
1048 You could use a dictionary (#xbt_dict_t) of dynars (#xbt_dynar_t). If
1049 you still don't see how to do it, please come back to us...
1050
1051 \subsubsection faq_MIA_asynchronous I want to do asynchronous communications in MSG
1052
1053 Up until now, there is no asynchronous communications in MSG. However,
1054 you can create as many process as you want so you should be able to do
1055 whatever you want... I've written a queue module to help implementing
1056 some asynchronous communications at low cost (creating thousands of
1057 process only to handle communications may be problematic in term of
1058 performance at some point). I'll add it in the distribution asap.
1059
1060 \subsubsection faq_MIA_thread_synchronization I need to synchronize my MSG processes
1061
1062 You obviously cannot use pthread_mutexes of pthread_conds. The best
1063 thing would be to propose similar structures. Unfortunately, we
1064 haven't found time to do it yet. However you can try to play with
1065 MSG_process_suspend() and MSG_process_resume(). You can even do some
1066 synchronization with fake communications (using MSG_task_get(),
1067 MSG_task_put() and MSG_task_Iprobe()).
1068
1069 \subsubsection faq_MIA_host_load Where is the get_host_load function hidden in MSG?
1070
1071 There is no such thing because its semantic wouldn't be really
1072 clear. Of course, it is something about the amount of host throughput,
1073 but there is as many definition of "host load" as people asking for
1074 this function. First, you have to remember that resource availability
1075 may vary over time, which make any load notion harder to define.
1076
1077 It may be instantaneous value or an average one. Moreover it may be only the
1078 power of the computer, or may take the background load into account, or may
1079 even take the currently running tasks into account. In some SURF models,
1080 communications have an influence on computational power. Should it be taken
1081 into account too?
1082
1083 First of all, it's near to impossible to predict the load beforehands in the
1084 simulator since it depends on too much parameters (background load
1085 variation, bandwidth sharing algorithmic complexity) some of them even being
1086 not known beforehands (other task starting at the same time). So, getting
1087 this information is really hard (just like in real life). It's not just that
1088 we want MSG to be as painful as real life. But as it is in some way
1089 realistic, we face some of the same problems as we would face in real life.
1090
1091 How would you do it for real? The most common option is to use something
1092 like NWS that performs active probes. The best solution is probably to do
1093 the same within MSG, as in next code snippet. It is very close from what you
1094 would have to do out of the simulator, and thus gives you information that
1095 you could also get in real settings to not hinder the realism of your
1096 simulation. 
1097
1098 \verbatim
1099 double get_host_load() {
1100    m_task_t task = MSG_task_create("test", 0.001, 0, NULL);
1101    double date = MSG_get_clock();
1102
1103    MSG_task_execute(task);
1104    date = MSG_get_clock() - date;
1105    MSG_task_destroy(task);
1106    return (0.001/date);
1107 }
1108 \endverbatim
1109
1110 Of course, it may not match your personal definition of "host load". In this
1111 case, please detail what you mean on the mailing list, and we will extend
1112 this FAQ section to fit your taste if possible.
1113
1114 \subsubsection faq_MIA_communication_time How can I get the *real* communication time?  
1115
1116 Communications are synchronous and thus if you simply get the time
1117 before and after a communication, you'll only get the transmission
1118 time and the time spent to really communicate (it will also take into
1119 account the time spent waiting for the other party to be
1120 ready). However, getting the *real* communication time is not really
1121 hard either. The following solution is a good starting point.
1122
1123 \verbatim
1124 int sender()
1125 {
1126   m_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size, 
1127                                   calloc(1,sizeof(double)));
1128   *((double*) task->data) = MSG_get_clock();
1129   MSG_task_put(task, slaves[i % slaves_count], PORT_22);
1130   INFO0("Send completed");
1131   return 0;
1132 }
1133 int receiver()
1134 {
1135   m_task_t task = NULL;
1136   double time1,time2;
1137
1138   time1 = MSG_get_clock();
1139   a = MSG_task_get(&(task), PORT_22);
1140   time2 = MSG_get_clock();
1141   if(time1<*((double *)task->data))
1142      time1 = *((double *) task->data);
1143   INFO1("Communication time :  \"%f\" ", time2-time1);
1144   free(task->data);
1145   MSG_task_destroy(task);
1146   return 0;
1147 }
1148 \endverbatim
1149
1150 \subsection faq_MIA_SimDag SimDag related questions
1151
1152 \subsubsection faq_SG_comm Implementing communication delays between tasks.
1153
1154 A classic question of SimDag newcomers is about how to express a
1155 communication delay between tasks. The thing is that in SimDag, both
1156 computation and communication are seen as tasks.  So, if you want to
1157 model a data dependency between two DAG tasks t1 and t2, you have to
1158 create 3 SD_tasks: t1, t2 and c and add dependencies in the following
1159 way:
1160
1161 \verbatim
1162 SD_task_dependency_add(NULL, NULL, t1, c);
1163 SD_task_dependency_add(NULL, NULL, c, t2);
1164 \endverbatim
1165
1166 This way task t2 cannot start before the termination of communication c
1167 which in turn cannot start before t1 ends.
1168
1169 When creating task c, you have to associate an amount of data (in bytes)
1170 corresponding to what has to be sent by t1 to t2.
1171
1172 Finally to schedule the communication task c, you have to build a list
1173 comprising the workstations on which t1 and t2 are scheduled (w1 and w2
1174 for example) and build a communication matrix that should look like
1175 [0;amount ; 0; 0].
1176
1177 \subsubsection faq_SG_DAG How to implement a distributed dynamic scheduler of DAGs.
1178
1179 Distributed is somehow "contagious". If you start making distributed
1180 decisions, there is no way to handle DAGs directly anymore (unless I
1181 am missing something). You have to encode your DAGs in term of
1182 communicating process to make the whole scheduling process
1183 distributed. Here is an example of how you could do that. Assume T1
1184 has to be done before T2.
1185
1186 \verbatim
1187  int your_agent(int argc, char *argv[] {
1188    ...
1189    T1 = MSG_task_create(...);
1190    T2 = MSG_task_create(...);
1191    ...
1192    while(1) {
1193      ...
1194      if(cond) MSG_task_execute(T1);
1195      ...
1196      if((MSG_task_get_remaining_computation(T1)=0.0) && (you_re_in_a_good_mood))
1197         MSG_task_execute(T2)
1198      else {
1199         /* do something else */
1200      }
1201    }
1202  }
1203 \endverbatim
1204  
1205 If you decide that the distributed part is not that much important and that
1206 DAG is really the level of abstraction you want to work with, then you should
1207 give a try to \ref SD_API.
1208
1209 \subsection faq_MIA_generic Generic features
1210
1211 \subsubsection faq_more_processes Increasing the amount of simulated processes
1212
1213 Here are a few tricks you can apply if you want to increase the amount
1214 of processes in your simulations.
1215
1216  - <b>A few thousands of simulated processes</b> (soft tricks)\n
1217    SimGrid can use either pthreads library or the UNIX98 contextes. On
1218    most systems, the number of pthreads is limited and then your
1219    simulation may be limited for a stupid reason. This is especially
1220    true with the current linux pthreads, and I cannot get more than
1221    2000 simulated processes with pthreads on my box. The UNIX98
1222    contexts allow me to raise the limit to 25,000 simulated processes
1223    on my laptop.\n\n
1224    The <tt>--with-context</tt> option of the <tt>./configure</tt>
1225    script allows you to choose between UNIX98 contextes
1226    (<tt>--with-context=ucontext</tt>) and the pthread version
1227    (<tt>--with-context=pthread</tt>). The default value is ucontext
1228    when the script detect a working UNIX98 context implementation. On
1229    Windows boxes, the provided value is discarded and an adapted
1230    version is picked up.\n\n
1231    We experienced some issues with contextes on some rare systems
1232    (solaris 8 and lower or old alpha linuxes comes to mind). The main
1233    problem is that the configure script detect the contextes as being
1234    functional when it's not true. If you happen to use such a system,
1235    switch manually to the pthread version, and provide us with a good
1236    patch for the configure script so that it is done automatically ;)
1237
1238  - <b>Hundred thousands of simulated processes</b> (hard-core tricks)\n 
1239    As explained above, SimGrid can use UNIX98 contextes to represent
1240    and handle the simulated processes. Thanks to this, the main
1241    limitation to the number of simulated processes becomes the
1242    available memory.\n\n
1243    Here are some tricks I had to use in order to run a token ring
1244    between 25,000 processes on my laptop (1Gb memory, 1.5Gb swap).\n
1245    - First of all, make sure your code runs for a few hundreds
1246      processes before trying to push the limit. Make sure it's
1247      valgrind-clean, ie that valgrind does not report neither memory
1248      error nor memory leaks. Indeed, numerous simulated processes
1249      result in *fat* simulation hindering debugging.
1250    - It was really boring to write 25,000 entries in the deployment
1251      file, so I wrote a little script
1252      <tt>examples/gras/mutual_exclusion/simple_token/make_deployment.pl</tt>, which you may
1253      want to adapt to your case. You could also think about hijacking
1254      the SURFXML parser (have look at \ref faq_flexml_bypassing).
1255    - The deployment file became quite big, so I had to do what is in
1256      the FAQ entry \ref faq_flexml_limit
1257    - Each UNIX98 context has its own stack entry. As debugging this is
1258      quite hairly, the default value is a bit overestimated so that
1259      user don't get into trouble about this. You want to tune this
1260      size to increse the number of processes. This is the
1261      <tt>STACK_SIZE</tt> define in 
1262      <tt>src/xbt/xbt_context_sysv.c</tt>, which is 128kb by default.
1263      Reduce this as much as you can, but be warned that if this value
1264      is too low, you'll get a segfault. The token ring example, which
1265      is quite simple, runs with 40kb stacks.     
1266    - You may tweak the logs to reduce the stack size further.  When
1267      logging something, we try to build the string to display in a
1268      char array on the stack. The size of this array is constant (and
1269      equal to XBT_LOG_BUFF_SIZE, defined in include/xbt/log/h). If the
1270      string is too large to fit this buffer, we move to a dynamically
1271      sized buffer. In which case, we have to traverse one time the log
1272      event arguments to compute the size we need for the buffer,
1273      malloc it, and traverse the argument list again to do the actual
1274      job.\n     
1275      The idea here is to move XBT_LOG_BUFF_SIZE to 1, forcing the logs
1276      to use a dynamic array each time. This allows us to lower further
1277      the stack size at the price of some performance loss...\n
1278      This allowed me to run the reduce the stack size to ... 4k. Ie,
1279      on my 1Gb laptop, I can run more than 250,000 processes!
1280
1281 \subsubsection faq_MIA_batch_scheduler Is there a native support for batch schedulers in SimGrid?
1282
1283 No, there is no native support for batch schedulers and none is
1284 planned because this is a very specific need (and doing it in a
1285 generic way is thus very hard). However some people have implemented
1286 their own batch schedulers. Vincent Garonne wrote one during his PhD
1287 and put his code in the contrib directory of our SVN so that other can
1288 keep working on it. You may find inspiring ideas in it.
1289
1290 \subsubsection faq_MIA_checkpointing I need a checkpointing thing
1291
1292 Actually, it depends on whether you want to checkpoint the simulation, or to
1293 simulate checkpoints. 
1294
1295 The first one could help if your simulation is a long standing process you
1296 want to keep running even on hardware issues. It could also help to
1297 <i>rewind</i> the simulation by jumping sometimes on an old checkpoint to
1298 cancel recent calculations.\n 
1299 Unfortunately, such thing will probably never exist in SG. One would have to
1300 duplicate all data structures because doing a rewind at the simulator level
1301 is very very hard (not talking about the malloc free operations that might
1302 have been done in between). Instead, you may be interested in the Libckpt
1303 library (http://www.cs.utk.edu/~plank/plank/www/libckpt.html). This is the
1304 checkpointing solution used in the condor project, for example. It makes it
1305 easy to create checkpoints (at the OS level, creating something like core
1306 files), and rerunning them on need.
1307
1308 If you want to simulate checkpoints instead, it means that you want the
1309 state of an executing task (in particular, the progress made towards
1310 completion) to be saved somewhere.  So if a host (and the task executing on
1311 it) fails (cf. #MSG_HOST_FAILURE), then the task can be restarted
1312 from the last checkpoint.\n
1313
1314 Actually, such a thing does not exists in SimGrid either, but it's just
1315 because we don't think it is fundamental and it may be done in the user code
1316 at relatively low cost. You could for example use a watcher that
1317 periodically get the remaining amount of things to do (using
1318 MSG_task_get_remaining_computation()), or fragment the task in smaller
1319 subtasks.
1320
1321 \subsection faq_platform Platform building and Dynamic resources
1322
1323 \subsubsection faq_platform_example Where can I find SimGrid platform files?
1324
1325 There is several little examples in the archive, in the examples/msg
1326 directory. From time to time, we are asked for other files, but we
1327 don't have much at hand right now. 
1328
1329 You should refer to the Platform Description Archive
1330 (http://pda.gforge.inria.fr) project to see the other platform file we
1331 have available, as well as the Simulacrum simulator, meant to generate
1332 SimGrid platforms using all classical generation algorithms.
1333
1334 \subsubsection faq_platform_alnem How can I automatically map an existing platform?
1335
1336 We are working on a project called ALNeM (Application-Level Network
1337 Mapper) which goal is to automatically discover the topology of an
1338 existing network. Its output will be a platform description file
1339 following the SimGrid syntax, so everybody will get the ability to map
1340 their own lab network (and contribute them to the catalog project).
1341 This tool is not ready yet, but it move quite fast forward. Just stay
1342 tuned.
1343
1344 \subsubsection faq_platform_synthetic Generating synthetic but realistic platforms
1345
1346 The third possibility to get a platform file (after manual or
1347 automatic mapping of real platforms) is to generate synthetic
1348 platforms. Getting a realistic result is not a trivial task, and
1349 moreover, nobody is really able to define what "realistic" means when
1350 speaking of topology files. You can find some more thoughts on this
1351 topic in these
1352 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">slides</a>.
1353
1354 If you are looking for an actual tool, there we have a little tool to
1355 annotate Tiers-generated topologies. This perl-script is in
1356 <tt>tools/platform_generation/</tt> directory of the SVN. Dinda et Al.
1357 released a very comparable tool, and called it GridG.
1358
1359 \subsubsection faq_SURF_dynamic Expressing dynamic resource availability in platform files
1360
1361 A nice feature of SimGrid is that it enables you to seamlessly have
1362 resources whose availability change over time. When you build a
1363 platform, you generally declare hosts like that:
1364
1365 \verbatim
1366   <host id="host A" power="100.00"/>
1367 \endverbatim 
1368
1369 If you want the availability of "host A" to change over time, the only
1370 thing you have to do is change this definition like that:
1371
1372 \verbatim
1373   <host id="host A" power="100.00" availability_file="trace_A.txt" state_file="trace_A_failure.txt"/>
1374 \endverbatim
1375
1376 For hosts, availability files are expressed in fraction of available
1377 power. Let's have a look at what "trace_A.txt" may look like:
1378
1379 \verbatim
1380 PERIODICITY 1.0
1381 0.0 1.0
1382 11.0 0.5
1383 20.0 0.9
1384 \endverbatim
1385
1386 At time 0, our host will deliver 100 flop/s. At time 11.0, it will
1387 deliver only 50 flop/s until time 20.0 where it will will start
1388 delivering 90 flop/s. Last at time 21.0 (20.0 plus the periodicity
1389 1.0), we'll be back to the beginning and it will deliver 100 flop/s.
1390
1391 Now let's look at the state file:
1392 \verbatim
1393 PERIODICITY 10.0
1394 1.0 -1.0
1395 2.0 1.0
1396 \endverbatim
1397
1398 A negative value means "off" while a positive one means "on". At time
1399 1.0, the host is on. At time 1.0, it is turned off and at time 2.0, it
1400 is turned on again until time 12 (2.0 plus the periodicity 10.0). It
1401 will be turned on again at time 13.0 until time 23.0, and so on.
1402
1403 Now, let's look how the same kind of thing can be done for network
1404 links. A usual declaration looks like:
1405
1406 \verbatim
1407   <link id="LinkA" bandwidth="10.0" latency="0.2"/>
1408 \endverbatim
1409
1410 You have at your disposal the following options: bandwidth_file,
1411 latency_file and state_file. The only difference with hosts is that
1412 bandwidth_file and latency_file do not express fraction of available
1413 power but are expressed directly in bytes per seconds and seconds.
1414
1415 \subsubsection faq_platform_multipath How to express multipath routing in platform files?
1416
1417 It is unfortunately impossible to express the fact that there is more
1418 than one routing path between two given hosts. Let's consider the
1419 following platform file:
1420
1421 \verbatim
1422 <route src="A" dst="B">
1423    <link:ctn id="1"/>
1424 </route>
1425 <route src="B" dst="C">
1426   <link:ctn id="2"/>
1427 </route>
1428 <route src="A" dst="C">
1429   <link:ctn id="3"/>
1430 </route>
1431 \endverbatim
1432
1433 Although it is perfectly valid, it does not mean that data traveling
1434 from A to C can either go directly (using link 3) or through B (using
1435 links 1 and 2). It simply means that the routing on the graph is not
1436 trivial, and that data do not following the shortest path in number of
1437 hops on this graph. Another way to say it is that there is no implicit
1438 in these routing descriptions. The system will only use the routes you
1439 declare (such as &lt;route src="A" dst="C"&gt;&lt;link:ctn
1440 id="3"/&gt;&lt;/route&gt;), without trying to build new routes by aggregating
1441 the provided ones.
1442   
1443 You are also free to declare platform where the routing is not
1444 symmetric. For example, add the following to the previous file:
1445
1446 \verbatim
1447 <route src="C" dst="A">
1448   <link:ctn id="2"/>
1449   <link:ctn id="1"/>
1450 </route>
1451 \endverbatim
1452
1453 This makes sure that data from C to A go through B where data from A
1454 to C go directly. Don't worry about realism of such settings since
1455 we've seen ways more weird situation in real settings (in fact, that's
1456 the realism of very regular platforms which is questionable, but
1457 that's another story).
1458
1459 \subsubsection faq_flexml_bypassing Bypassing the XML parser with your own C functions
1460
1461 So you want to bypass the XML files parser, uh? Maybe doing some parameter
1462 sweep experiments on your simulations or so? This is possible, and
1463 it's not even really difficult (well. Such a brutal idea could be
1464 harder to implement). Here is how it goes.
1465
1466 For this, you have to first remember that the XML parsing in SimGrid is done
1467 using a tool called FleXML. Given a DTD, this gives a flex-based parser. If
1468 you want to bypass the parser, you need to provide some code mimicking what
1469 it does and replacing it in its interactions with the SURF code. So, let's
1470 have a look at these interactions.
1471
1472 FleXML parser are close to classical SAX parsers. It means that a
1473 well-formed SimGrid platform XML file might result in the following
1474 "events":
1475
1476   - start "platform_description" with attribute version="2"
1477   - start "host" with attributes id="host1" power="1.0"
1478   - end "host"
1479   - start "host" with attributes id="host2" power="2.0"
1480   - end "host"
1481   - start "link" with ...
1482   - end "link"
1483   - start "route" with ...
1484   - start "link:ctn" with ...
1485   - end "link:ctn"
1486   - end "route"
1487   - end "platform_description"
1488
1489 The communication from the parser to the SURF code uses two means:
1490 Attributes get copied into some global variables, and a surf-provided
1491 function gets called by the parser for each event. For example, the event
1492   - start "host" with attributes id="host1" power="1.0"
1493
1494 let the parser do something roughly equivalent to:
1495 \verbatim
1496   strcpy(A_host_id,"host1");
1497   A_host_power = 1.0;
1498   STag_host();
1499 \endverbatim
1500
1501 In SURF, we attach callbacks to the different events by initializing the
1502 pointer functions to some the right surf functions. Since there can be
1503 more than one callback attached to the same event (if more than one
1504 model is in use, for example), they are stored in a dynar. Example in
1505 workstation_ptask_L07.c:
1506 \verbatim
1507   /* Adding callback functions */
1508   surf_parse_reset_parser();
1509   surfxml_add_callback(STag_surfxml_host_cb_list, &parse_cpu_init);
1510   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
1511   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
1512   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
1513   surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
1514   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
1515                 
1516   /* Parse the file */
1517   surf_parse_open(file);
1518   xbt_assert1((!surf_parse()), "Parse error in %s", file);
1519   surf_parse_close();
1520 \endverbatim
1521     
1522 So, to bypass the FleXML parser, you need to write your own version of the
1523 surf_parse function, which should do the following:
1524    - Fill the A_<tag>_<attribute> variables with the wanted values
1525    - Call the corresponding STag_<tag>_fun function to simulate tag start
1526    - Call the corresponding ETag_<tag>_fun function to simulate tag end
1527    - (do the same for the next set of values, and loop)
1528
1529 Then, tell SimGrid that you want to use your own "parser" instead of the stock one:
1530 \verbatim
1531   surf_parse = surf_parse_bypass_environment;
1532   MSG_create_environment(NULL);
1533   surf_parse = surf_parse_bypass_application;
1534   MSG_launch_application(NULL);
1535 \endverbatim
1536
1537 A set of macros are provided at the end of
1538 include/surf/surfxml_parse.h to ease the writing of the bypass
1539 functions. An example of this trick is distributed in the file
1540 examples/msg/masterslave/masterslave_bypass.c
1541
1542 \subsection faq_simgrid_configuration Changing SimGrid's behavior
1543
1544 A number of options can be given at runtime to change the default
1545 SimGrid behavior. In particular, you can change the default cpu and
1546 network models...
1547
1548 \subsubsection faq_simgrid_configuration_gtnets Using GTNetS
1549
1550 It is possible to use a packet-level network simulator
1551 instead of the default flow-based simulation. You may want to use such
1552 an approach if you have doubts about the validity of the default model
1553 or if you want to perform some validation experiments. At the moment,
1554 we support the GTNetS simulator (it is still rather experimental
1555 though, so leave us a message if you play with it). 
1556
1557
1558 <i>
1559 To enable GTNetS model inside SimGrid it is needed to patch the GTNetS simulator source code 
1560 and build/install it from scratch
1561 </i>
1562
1563  - <b>Download and enter the recent downloaded GTNetS directory</b>
1564
1565  \verbatim
1566  svn checkout svn://scm.gforge.inria.fr/svn/simgrid/contrib/trunk/GTNetS/
1567  cd GTNetS
1568  \endverbatim
1569
1570
1571  - <b>Use the following commands to unzip and patch GTNetS package to work within SimGrid.</b>
1572
1573  \verbatim
1574  unzip gtnets-current.zip
1575  tar zxvf gtnets-current-patch.tgz 
1576  cd gtnets-current
1577  cat ../00*.patch | patch -p1
1578  \endverbatim
1579
1580   - <b>OPTIONALLY</b> you can use a patch for itanium 64bit processor family.
1581
1582   \verbatim
1583   cat ../AMD64-FATAL-Removed-DUL_SIZE_DIFF-Added-fPIC-compillin.patch | patch -p1
1584   \endverbatim
1585
1586  - <b>Compile GTNetS</b>
1587
1588    Due to portability issues it is possible that GTNetS does not compile in your architecture. The patches furnished in SimGrid SVN repository are intended for use in Linux architecture only. Unfortunately, we do not have the time, the money, neither the manpower to guarantee GTNetS portability. We advice you to use one of GTNetS communication channel to get more help in compiling GTNetS. 
1589
1590
1591  \verbatim
1592  ln -sf Makefile.linux Makefile
1593  make depend
1594  make debug
1595  \endverbatim
1596
1597
1598  - <b>NOTE</b> A lot of warnings are expected but the application should compile
1599  just fine. If the makefile insists in compiling some QT libraries
1600  please try a make clean before asking for help.
1601
1602
1603  - <b>To compile optimized version</b>
1604
1605  \verbatim
1606  make opt
1607  \endverbatim
1608
1609
1610  - <b>Installing GTNetS</b>
1611
1612  It is important to put the full path of your libgtsim-xxxx.so file when creating the symbolic link. Replace < userhome > by some path you have write access to.
1613
1614  \verbatim
1615  ln -sf /<absolute_path>/gtnets_current/libgtsim-debug.so /<userhome>/usr/lib/libgtnets.so
1616  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/<userhome>/usr/lib/libgtnets.so
1617  mkdir /<userhome>/usr/include/gtnets
1618  cp -fr SRC/*.h /<userhome>/usr/include/gtnets
1619  \endverbatim
1620
1621
1622  - <b>Enable GTNetS support in SimGrid</b>
1623
1624    \verbatim
1625    ./configure --with-gtnets=/<userhome>/usr
1626    \endverbatim
1627
1628  - <b>Once you have followed all the instructions for compiling and
1629    installing successfully you can activate this feature at 
1630    runntime with the following options:</b>
1631
1632    \verbatim
1633    cd simgrid/example/msg/
1634    make
1635    make check
1636    \endverbatim
1637
1638
1639  - <b>Or try the GTNetS model dogbone example with</b>
1640
1641  \verbatim
1642  gtnets/gtnets gtnets/onelink-p.xml gtnets/onelink-d.xml --cfg=network_model:GTNets
1643  \endverbatim
1644
1645  
1646  A long version of this <a href="http://gforge.inria.fr/docman/view.php/12/6283/GTNetS HowTo.html">HowTo</a>  it is available 
1647
1648
1649  More about GTNetS simulator at <a href="http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/index.html">GTNetS Website</a>
1650
1651
1652  - <b>DISCLAIMER</b>
1653  The patches provided by us worked successfully with GTNetS found 
1654  <a href="http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/software/gtnets-current.zip">here</a>, 
1655  dated from 12th June 2008. Due to the discontinuing development of
1656  GTNetS it is impossible to precise a version number. We STRONGLY recommend you
1657  to download and install the GTNetS version found in SimGrid repository as explained above.
1658  
1659
1660
1661
1662 \subsubsection faq_simgrid_configuration_alternate_network Using alternative flow models
1663
1664 The default simgrid network model uses a max-min based approach as
1665 explained in the research report
1666 <a href="ftp://ftp.ens-lyon.fr/pub/LIP/Rapports/RR/RR2002/RR2002-40.ps.gz">A Network Model for Simulation of Grid Application</a>.
1667 Other models have been proposed and implemented since then (see for example 
1668 <a href="http://mescal.imag.fr/membres/arnaud.legrand/articles/simutools09.pdf">Accuracy Study and Improvement of Network Simulation in the SimGrid Framework</a>)
1669 and can be activated at runtime. For example:
1670 \verbatim
1671 ./mycode platform.xml deployment.xml --cfg=workstation_model:compound --cfg=network_model:LV08 -cfg=cpu_model:Cas01
1672 \endverbatim
1673
1674 Possible models for the network are currently "Constant", "CM02",
1675 "LegrandVelho", "GTNets", Reno", "Reno2", "Vegas". Others will
1676 probably be added in the future and many of the previous ones are
1677 experimental and are likely to disappear without notice...
1678
1679 \section faq_troubleshooting Troubleshooting
1680
1681 \subsection faq_trouble_lib_compil SimGrid compilation and installation problems
1682
1683 \subsubsection faq_trouble_lib_config ./configure fails!
1684
1685 We know only one reason for the configure to fail:
1686
1687  - <b>You are using a broken build environment</b>\n
1688    If symptom is that configure complains about gcc not being able to build
1689    executables, you are probably missing the libc6-dev package. Damn Ubuntu.
1690
1691 If you experience other kind of issue, please get in touch with us. We are
1692 always interested in improving our portability to new systems.
1693
1694 \subsubsection faq_trouble_distcheck Dude! "make check" fails on my machine!
1695
1696 Don't assume we never run this target, because we do. Check
1697 http://bob.loria.fr:8010 if you don't believe us.
1698
1699 There is several reasons which may cause the make check to fail on your
1700 machine:
1701
1702  - <b>You are using a broken libc (probably concerning the contextes)</b>.\n
1703    The symptom is that the "make check" fails within the examples/msg directory.\n
1704    By default, SimGrid uses something called ucontexts. This is part of the
1705    libc, but it's quite undertested. For example, some (old) versions of the
1706    glibc on alpha do not implement these functions, but provide the stubs
1707    (which return ENOSYS: not implemented). It may fool our detection mechanism
1708    and leads to segfaults. There is not much we can do to fix the bug.
1709    A workaround is to compile with --with-context=pthread to avoid
1710    ucontext completely. You'll be a bit more limited in the number
1711    of simulated processes you can start concurrently, but 5000
1712    processes is still enough for most purposes, isn't it?\n
1713    This limitation is the reason why we insist on using this piece of ...
1714    software even if it's so troublesome.\n
1715    <b>=> use --with-pthread on AMD64 architecture that do not have an 
1716    ultra-recent libc.</b>
1717    
1718  - <b>There is a bug in SimGrid we aren't aware of</b>.\n
1719    If none of the above apply, please drop us a mail on the mailing list so
1720    that we can check it out. Make sure to read \ref faq_bugrepport
1721    before you do so.
1722
1723 \subsection faq_trouble_compil User code compilation problems
1724
1725 \subsubsection faq_trouble_err_logcat "gcc: _simgrid_this_log_category_does_not_exist__??? undeclared (first use in this function)"
1726
1727 This is because you are using the log mecanism, but you didn't created
1728 any default category in this file. You should refer to \ref XBT_log
1729 for all the details, but you simply forgot to call one of
1730 XBT_LOG_NEW_DEFAULT_CATEGORY() or XBT_LOG_NEW_DEFAULT_SUBCATEGORY().
1731
1732 \subsubsection faq_trouble_pthreadstatic "gcc: undefined reference to pthread_key_create"
1733
1734 This indicates that one of the library SimGrid depends on (libpthread
1735 here) was missing on the linking command line. Dependencies of
1736 libsimgrid are expressed directly in the dynamic library, so it's
1737 quite impossible that you see this message when doing dynamic linking. 
1738
1739 If you compile your code statically (and if you use a pthread version
1740 of SimGrid -- see \ref faq_more_processes), you must absolutely
1741 specify <tt>-lpthread</tt> on the linker command line. As usual, this should
1742 come after <tt>-lsimgrid</tt> on this command line.
1743
1744 \subsection faq_trouble_errors Runtime error messages
1745
1746 \subsubsection faq_flexml_limit "surf_parse_lex: Assertion `next limit' failed."
1747
1748 This is because your platform file is too big for the parser. 
1749
1750 Actually, the message comes directly from FleXML, the technology on top of
1751 which the parser is built. FleXML has the bad idea of fetching the whole
1752 document in memory before parsing it. And moreover, the memory buffer size
1753 must be determined at compilation time.
1754
1755 We use a value which seems big enough for our need without bloating the
1756 simulators footprints. But of course your mileage may vary. In this case,
1757 just edit src/surf/surfxml.l modify the definition of
1758 FLEXML_BUFFERSTACKSIZE. E.g.
1759
1760 \verbatim
1761 #define FLEXML_BUFFERSTACKSIZE 1000000000
1762 \endverbatim
1763
1764 Then recompile and everything should be fine, provided that your version of
1765 Flex is recent enough (>= 2.5.31). If not the compilation process should
1766 warn you.
1767
1768 A while ago, we worked on FleXML to reduce a bit its memory consumption, but
1769 these issues remain. There is two things we should do:
1770
1771   - use a dynamic buffer instead of a static one so that the only limit
1772     becomes your memory, not a stupid constant fixed at compilation time
1773     (maybe not so difficult).
1774   - change the parser so that it does not need to get the whole file in
1775     memory before parsing
1776     (seems quite difficult, but I'm a complete newbe wrt flex stuff).
1777
1778 These are changes to FleXML itself, not SimGrid. But since we kinda hijacked
1779 the development of FleXML, I can grant you that any patches would be really
1780 welcome and quickly integrated.
1781
1782 <b>Update:</b> A new version of FleXML (1.7) was released. Most of the work
1783 was done by William Dowling, who use it in his own work. The good point is
1784 that it now use a dynamic buffer, and that the memory usage was greatly
1785 improved. The downside is that William also changed some things internally,
1786 and it breaks the hack we devised to bypass the parser, as explained in 
1787 \ref faq_flexml_bypassing. Indeed, this is not a classical usage of the
1788 parser, and Will didn't imagine that we may have used (and even documented)
1789 such a crude usage of FleXML. So, we now have to repair the bypassing
1790 functionality to use the lastest FleXML version and fix the memory usage in
1791 SimGrid.
1792
1793 \subsubsection faq_trouble_gras_transport GRAS spits networking error messages
1794
1795 Gras, on real platforms, naturally use regular sockets to communicate. They
1796 are deeply hidden in the gras abstraction, but when things go wrong, you may
1797 get some weird error messages. Here are some example, with the probable
1798 reason:
1799
1800  - <b>Transport endpoint is not connected</b>: several processes try to open
1801    a server socket on the same port number of the same machine. This is
1802    naturally bad and each process should pick its own port number for this.\n
1803    Maybe, you just have some processes remaining from a previous experiment 
1804    on your machine.\n
1805    Killing them may help, but again if you kill -KILL them, you'll have to
1806    wait for a while: they didn't close there sockets properly and the system
1807    needs a while to notice that this port is free again.
1808
1809  - <b>Socket closed by remote side</b>: if the remote process is not
1810    supposed to close the socket at this point, it may be dead.
1811    
1812  - <b>Connection reset by peer</b>: I found this on Internet about this
1813    error. I think it's what's happening here, too:\n   
1814    <i>This basically means that a network error occurred while the client was
1815    receiving data from the server. But what is really happening is that the
1816    server actually accepts the connection, processes the request, and sends
1817    a reply to the client. However, when the server closes the socket, the
1818    client believes that the connection has been terminated abnormally
1819    because the socket implementation sends a TCP reset segment telling the
1820    client to throw away the data and report an error.\n
1821    Sometimes, this problem is caused by not properly closing the
1822    input/output streams and the socket connection. Make sure you close the
1823    input/output streams and socket connection properly. If everything is
1824    closed properly, however, and the problem persists, you can work around
1825    it by adding a one-second sleep before closing the streams and the
1826    socket. This technique, however, is not reliable and may not work on all
1827    systems.</i>\n
1828    Since GRAS sockets are closed properly (repeat after me: there is no bug
1829    in GRAS), it is either that you are closing your sockets on server side
1830    before the client get a chance to read them (use gras_os_sleep() to delay
1831    the server), or the server died awfully before the client got the data.
1832
1833 \subsubsection faq_trouble_errors_big_fat_warning I'm told that my XML files are too old.
1834
1835 The format of the XML platform description files is sometimes
1836 improved. For example, we decided to change the units used in SimGrid
1837 from MBytes, MFlops and seconds to Bytes, Flops and seconds to ease
1838 people exchanging small messages. We also reworked the route
1839 descriptions to allow more compact descriptions.
1840
1841 That is why the XML files are versionned using the 'version' attribute
1842 of the root tag. Currently, it should read:
1843 \verbatim
1844   <platform version="2">
1845 \endverbatim
1846
1847 If your files are too old, you can use the simgrid_update_xml.pl
1848 script which can be found in the tools directory of the archive.
1849
1850 \subsection faq_trouble_valgrind Valgrind-related and other debugger issues
1851
1852 If you don't, you really should use valgrind to debug your code, it's
1853 almost magic.
1854
1855 \subsubsection faq_trouble_vg_longjmp longjmp madness in valgrind
1856
1857 This is when valgrind starts complaining about longjmp things, just like:
1858
1859 \verbatim ==21434== Conditional jump or move depends on uninitialised value(s)
1860 ==21434==    at 0x420DBE5: longjmp (longjmp.c:33)
1861 ==21434==
1862 ==21434== Use of uninitialised value of size 4
1863 ==21434==    at 0x420DC3A: __longjmp (__longjmp.S:48)
1864 \endverbatim
1865
1866 This is the sign that you didn't used the exception mecanism well. Most
1867 probably, you have a <tt>return;</tt> somewhere within a <tt>TRY{}</tt>
1868 block. This is <b>evil</b>, and you must not do this. Did you read the section
1869 about \ref XBT_ex??
1870
1871 \subsubsection faq_trouble_vg_libc Valgrind spits tons of errors about backtraces!
1872
1873 It may happen that valgrind, the memory debugger beloved by any decent C
1874 programmer, spits tons of warnings like the following :
1875 \verbatim ==8414== Conditional jump or move depends on uninitialised value(s)
1876 ==8414==    at 0x400882D: (within /lib/ld-2.3.6.so)
1877 ==8414==    by 0x414EDE9: (within /lib/tls/i686/cmov/libc-2.3.6.so)
1878 ==8414==    by 0x400B105: (within /lib/ld-2.3.6.so)
1879 ==8414==    by 0x414F937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
1880 ==8414==    by 0x4150F4C: (within /lib/tls/i686/cmov/libc-2.3.6.so)
1881 ==8414==    by 0x400B105: (within /lib/ld-2.3.6.so)
1882 ==8414==    by 0x415102D: __libc_dlopen_mode (in /lib/tls/i686/cmov/libc-2.3.6.so)
1883 ==8414==    by 0x412D6B9: backtrace (in /lib/tls/i686/cmov/libc-2.3.6.so)
1884 ==8414==    by 0x8076446: xbt_dictelm_get_ext (dict_elm.c:714)
1885 ==8414==    by 0x80764C1: xbt_dictelm_get (dict_elm.c:732)
1886 ==8414==    by 0x8079010: xbt_cfg_register (config.c:208)
1887 ==8414==    by 0x806821B: MSG_config (msg_config.c:42)
1888 \endverbatim
1889
1890 This problem is somewhere in the libc when using the backtraces and there is
1891 very few things we can do ourselves to fix it. Instead, here is how to tell
1892 valgrind to ignore the error. Add the following to your ~/.valgrind.supp (or
1893 create this file on need). Make sure to change the obj line according to
1894 your personnal mileage (change 2.3.6 to the actual version you are using,
1895 which you can retrieve with a simple "ls /lib/ld*.so").
1896
1897 \verbatim {
1898    name: Backtrace madness
1899    Memcheck:Cond
1900    obj:/lib/ld-2.3.6.so
1901    fun:dl_open_worker
1902    fun:_dl_open
1903    fun:do_dlopen
1904    fun:dlerror_run
1905    fun:__libc_dlopen_mode
1906 }\endverbatim
1907
1908 Then, you have to specify valgrind to use this suppression file by passing
1909 the <tt>--suppressions=$HOME/.valgrind.supp</tt> option on the command line.
1910 You can also add the following to your ~/.bashrc so that it gets passed
1911 automatically. Actually, it passes a bit more options to valgrind, and this
1912 happen to be my personnal settings. Check the valgrind documentation for
1913 more information.
1914
1915 \verbatim export VALGRIND_OPTS="--leak-check=yes --leak-resolution=high --num-callers=40 --tool=memcheck --suppressions=$HOME/.valgrind.supp" \endverbatim
1916
1917 \subsubsection faq_trouble_backtraces Truncated backtraces
1918
1919 When debugging SimGrid, it's easier to pass the
1920 --disable-compiler-optimization flag to the configure if valgrind or
1921 gdb get fooled by the optimization done by the compiler. But you
1922 should remove these flag when everything works before going in
1923 production (before launching your 1252135 experiments), or everything
1924 will run only one half of the true SimGrid potential.
1925
1926 \subsection faq_deadlock There is a deadlock in my code!!!
1927
1928 Unfortunately, we cannot debug every code written in SimGrid.  We
1929 furthermore believe that the framework provides ways enough
1930 information to debug such informations yourself. If the textual output
1931 is not enough, Make sure to check the \ref faq_visualization FAQ entry to see
1932 how to get a graphical one.
1933
1934 Now, if you come up with a really simple example that deadlocks and
1935 you're absolutely convinced that it should not, you can ask on the
1936 list. Just be aware that you'll be severely punished if the mistake is
1937 on your side... We have plenty of FAQ entries to redact and new
1938 features to implement for the impenitents! ;)
1939
1940 \subsection faq_surf_network_latency I get weird timings when I play with the latencies.
1941
1942 OK, first of all, remember that units should be Bytes, Flops and
1943 Seconds. If you don't use such units, some SimGrid constants (e.g. the
1944 SG_TCP_CTE_GAMMA constant used in most network models) won't have the
1945 right unit and you'll end up with weird results.
1946
1947 Here is what happens with a single transfer of size L on a link
1948 (bw,lat) when nothing else happens.
1949
1950 \verbatim
1951 0-----lat--------------------------------------------------t
1952 |-----|**** real_bw =min(bw,SG_TCP_CTE_GAMMA/(2*lat)) *****|
1953 \endverbatim
1954
1955 In more complex situations, this min is the solution of a complex
1956 max-min linear system.  Have a look 
1957 <a href="http://lists.gforge.inria.fr/pipermail/simgrid-devel/2006-April/thread.html">here</a>
1958 and read the two threads "Bug in SURF?" and "Surf bug not
1959 fixed?". You'll have a few other examples of such computations. You
1960 can also read "A Network Model for Simulation of Grid Application" by
1961 Henri Casanova and Loris Marchal to have all the details. The fact
1962 that the real_bw is smaller than bw is easy to understand. The fact
1963 that real_bw is smaller than SG_TCP_CTE_GAMMA/(2*lat) is due to the
1964 window-based congestion mechanism of TCP. With TCP, you can't exploit
1965 your huge network capacity if you don't have a good round-trip-time
1966 because of the acks...
1967
1968 Anyway, what you get is t=lat + L/min(bw,SG_TCP_CTE_GAMMA/(2*lat)).
1969
1970   * if I you set (bw,lat)=(100 000 000, 0.00001), you get t =  1.00001 (you fully
1971 use your link)
1972   * if I you set (bw,lat)=(100 000 000, 0.0001),  you get t =  1.0001 (you're on the
1973 limit)
1974   * if I you set (bw,lat)=(100 000 000, 0.001),   you get t = 10.001  (ouch!)
1975
1976 This bound on the effective bandwidth of a flow is not the only thing
1977 that may make your result be unexpected. For example, two flows
1978 competing on a saturated link receive an amount of bandwidth inversely
1979 proportional to their round trip time.
1980
1981 \subsection faq_bugrepport So I've found a bug in SimGrid. How to report it?
1982
1983 We do our best to make sure to hammer away any bugs of SimGrid, but this is
1984 still an academic project so please be patient if/when you find bugs in it.
1985 If you do, the best solution is to drop an email either on the simgrid-user
1986 or the simgrid-devel mailing list and explain us about the issue.  You can
1987 also decide to open a formal bug report using the
1988 <a href="https://gforge.inria.fr/tracker/?atid=165&group_id=12&func=browse">relevant
1989 interface</a>. You need to login on the server to get the ability to submit
1990 bugs. 
1991
1992 We will do our best to solve any problem repported, but you need to help us
1993 finding the issue. Just telling "it segfault" isn't enough. Telling "It
1994 segfaults when running the attached simulator" doesn't really help either.
1995 You may find the following article interesting to see how to repport
1996 informative bug repports:
1997 http://www.chiark.greenend.org.uk/~sgtatham/bugs.html (it is not SimGrid
1998 specific at all, but it's full of good advices).
1999
2000 \author Arnaud Legrand (arnaud.legrand::imag.fr)
2001 \author Martin Quinson (martin.quinson::loria.fr)
2002
2003
2004 */
2005
2006 ******************************************************************
2007 *              OLD CRUFT NOT USED ANYMORE                        *
2008 ******************************************************************
2009
2010
2011 \subsection faq_crosscompile Cross-compiling a Windows DLL of SimGrid from linux
2012
2013 At the moment, we do not distribute Windows pre-compiled version of SimGrid
2014 because the support for this platform is still experimental. We know that
2015 some parts of the GRAS environment do not work, and we think that the others
2016 environments (MSG and SD) have good chances to work, but we didn't test
2017 ourselves. This section explains how we generate the SimGrid DLL so that you
2018 can build it for yourself. First of all, you need to have a version more
2019 recent than 3.1 (ie, a SVN version as time of writting).
2020
2021 In order to cross-compile the package to windows from linux, you need to
2022 install mingw32 (minimalist gnu win32). On Debian, you can do so by
2023 installing the packages mingw32 (compiler), mingw32-binutils (linker and
2024 so), mingw32-runtime.
2025
2026 You can use the VPATH support of configure to compile at the same time for
2027 linux and windows without dupplicating the source nor cleaning the tree
2028 between each. Just run bootstrap (if you use the SVN) to run the autotools.
2029 Then, create a linux and a win directories. Then, type:
2030 \verbatim  cd linux; ../configure --srcdir=.. <usual configure flags>; make; cd ..
2031 cd win;  ../configure --srcdir=.. --host=i586-mingw32msvc <flags>; make; cd ..
2032 \endverbatim
2033 The trick to VPATH builds is to call configure from another directory,
2034 passing it an extra --srcdir argument to tell it where all the sources are.
2035 It will understand you want to use VPATH. Then, the trick to cross-compile
2036 is simply to add a --host argument specifying the target you want to build
2037 for. The i586-mingw32msvc string is what you have to pass to use the mingw32
2038 environment as distributed in Debian.
2039
2040 After that, you can run all make targets from both directories, and test
2041 easily that what you change for one arch does not break the other one. 
2042
2043 It is possible that this VPATH build thing breaks from time to time in the
2044 SVN since it's quite fragile, but it's granted to work in any released
2045 version. If you experience problems, drop us a mail. 
2046
2047 Another possible source of issue is that at the moment, building the
2048 examples request to use the gras_stub_generator tool, which is a compiled
2049 program, not a script. In cross-compilation, you need to cross-execute with
2050 wine for example, which is not really pleasant. We are working on this, but
2051 in the meanwhile, simply don't build the examples in cross-compilation
2052 (<tt>cd src</tt> before running make).
2053     
2054 Program (cross-)compiled with mingw32 do request an extra DLL at run-time to be
2055 usable. For example, if you want to test your build with wine, you should do
2056 the following to put this library where wine looks for DLLs.
2057 \verbatim 
2058 cp /usr/share/doc/mingw32-runtime/mingwm10.dll.gz ~/.wine/c/windows/system/
2059 gunzip ~/.wine/c/windows/system/mingwm10.dll.gz
2060 \endverbatim
2061
2062 The DLL is built in src/.libs, and installed in the <i>prefix</i>/bin directory
2063 when you run make install. 
2064
2065 If you want to use it in a native project on windows, you need to use 
2066 simgrid.dll and mingwm10.dll. For each DLL, you need to build .def file
2067 under linux (listing the defined symbols), and convert it into a .lib file
2068 under windows (specifying this in a way that windows compilers like). To
2069 generate the def files, run (under linux):
2070 \verbatim echo "LIBRARY libsimgrid-0.dll" > simgrid.def
2071 echo EXPORTS >> simgrid.def
2072 nm libsimgrid-0.dll | grep ' T _' | sed 's/.* T _//' >> simgrid.def
2073 nm libsimgrid-0.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> simgrid.def
2074
2075 echo "LIBRARY mingwm10.dll" > mingwm10.def
2076 echo EXPORTS >> mingwm10.def
2077 nm mingwm10.dll | grep ' T _' | sed 's/.* T _//' >> mingwm10.def
2078 nm mingwm10.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> mingwm10.def
2079 \endverbatim
2080
2081 To create the import .lib files, use the <tt>lib</tt> windows tool (from
2082 MSVC) the following way to produce simgrid.lib and mingwm10.lib
2083 \verbatim lib /def:simgrid.def
2084 lib /def:mingwm10.def
2085 \endverbatim
2086
2087 If you happen to use Borland C Builder, the right command line is the
2088 following (note that you don't need any file.def to get this working).
2089 \verbatim implib simgrid.lib libsimgrid-0.dll
2090 implib mingwm10.lib mingwm10.dll
2091 \endverbatim
2092
2093 Then, set the following parameters in Visual C++ 2005:
2094 Linker -> Input -> Additional dependencies = simgrid.lib mingwm10.lib
2095
2096 Just in case you wonder how to generate a DLL from libtool in another
2097 project, we added -no-undefined to any lib*_la_LDFLAGS variables so that
2098 libtool accepts to generate a dynamic library under windows. Then, to make
2099 it true, we pass any dependencies (such as -lws2 under windows or -lpthread
2100 on need) on the linking line. Passing such deps is a good idea anyway so
2101 that they get noted in the library itself, avoiding the users to know about
2102 our dependencies and put them manually on their compilation line. Then we
2103 added the AC_LIBTOOL_WIN32_DLL macro just before AC_PROG_LIBTOOL in the
2104 configure.ac. It means that we exported any symbols which need to be.
2105 Nowadays, functions get automatically exported, so we don't need to load our
2106 header files with tons of __declspec(dllexport) cruft. We only need to do so
2107 for data, but there is no public data in SimGrid so we are good.
2108