Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
6e5182f062c7de7ad1c89fb5ba044ff20fde7d6b
[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]          enable_gtnets                   [value] ON/OFF or TRUE/FALSE or 1/0
401                 enable_java                             ON/OFF or TRUE/FALSE or 1/0
402                 enable_lua                              ON/OFF or TRUE/FALSE or 1/0
403                 enable_ruby                             ON/OFF or TRUE/FALSE or 1/0
404                 enable_compile_optimizations            ON/OFF or TRUE/FALSE or 1/0
405                 enable_compile_warnings                 ON/OFF or TRUE/FALSE or 1/0
406                 enable_maintainer_mode                  ON/OFF or TRUE/FALSE or 1/0
407                 enable_supernovae                       ON/OFF or TRUE/FALSE or 1/0
408                 enable_tracing                          ON/OFF or TRUE/FALSE or 1/0
409                 enable_coverage                         ON/OFF or TRUE/FALSE or 1/0
410                 enable_memcheck                         ON/OFF or TRUE/FALSE or 1/0 
411                 enable_print_message                    ON/OFF or TRUE/FALSE or 1/0
412
413                 gtnets_path                             <path_to_gtnets_directory>
414                 prefix                                  <path_to_install_directory>
415                 BIBTEX2HTML                             <path_to_bibtex2html>
416                 with_context                            auto/ucontext/pthread/window     
417 \endverbatim
418                                                                                                                                                           
419 \subsubsection faq_cmakeoption2 Options explaination
420
421   \li enable_gtnets : set to true implie that user wants to use gtnets.
422
423   \li enable_java : set to true implie that user wants to add java langage into simgrid compilation.
424
425   \li enable_lua : set to true implie that user wants to add lua langage into simgrid compilation.
426
427   \li enable_ruby : set to true implie that user wants to add ruby langage into simgrid compilation.
428
429   \li enable_compile_optimizations : add flags "-O3 -finline-functions -funroll-loops -fno-strict-aliasing"
430
431   \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"
432
433   \li enable_maintainer_mode : set to true it remakes some files.
434 \verbatim
435 include/surf/simgrid_dtd.h
436 include/xbt/graphxml.h
437
438 src/cunit_unit.c
439 src/ex_unit.c
440 src/dynar_unit.c
441 src/dict_unit.c
442 src/set_unit.c
443 src/swag_unit.c
444 src/xbt_str_unit.c
445 src/xbt_strbuff_unit.c
446 src/xbt_sha_unit.c
447 src/config_unit.c
448 src/xbt_synchro_unit.c
449 src/simgrid_units_main.c
450
451 src/simdag/dax_dtd.c
452 src/simdag/dax_dtd.h
453 src/simdag/dax_dtd.l
454
455 src/surf/simgrid_dtd.c
456 src/surf/simgrid_dtd.l
457
458 src/xbt/graphxml.c
459 src/xbt/graphxml.l
460
461 src/gras/DataDesc/ddt_parse.yy.c
462 \endverbatim
463   \li enable_supernovae : set to true make one file for each lib and compile with those generated files.
464 \verbatim
465 /src/supernovae_sg.c
466 /src/supernovae_gras.c                  
467 /src/supernovae_smpi.c
468 \endverbatim
469
470   \li enable_tracing : To enable the generation of simulation traces for visualization
471
472   \li enable_coverage : When set to true this option enable code coverage by setting -fprofile-arcs -ftest-coverage flags.
473
474   \li enable_memcheck : When set to true this option enable tests for memcheck.
475
476   \li enable_print_message : This option when enable permits to see variables from gras_config.h
477
478   \li gtnets_path : Path to gtnets install directory (ex /usr)
479
480   \li prefix : Path where are installed lib/ doc/ and include/ directories (ex /usr/local)
481
482   \li BIBTEX2HTML : Path where is installed bibtex2html.
483
484   \li with context : specify which context the user wants to use.
485
486 \subsubsection faq_cmakeoption3 Initialisation
487
488 Those options are initialized the first time you launch \"cmake ./\" whithout specified option.
489
490 \verbatim
491 enable_gtnets                   on
492 enable_lua                      on
493 enable_ruby                     on
494 enable_java                     off
495 enable_compile_optimizations    off
496 enable_compile_warnings         off
497 enable_maintainer_mode          off
498 enable_supernovae               off
499 enable_tracing                  off
500 enable_coverage                 off
501 enable_memcheck                 off
502 enable_print_message            off
503
504 gtnets_path                     null
505 prefix                          null
506 BIBTEX2HTML                     null
507 with_context                    auto
508 \endverbatim
509
510 \subsubsection faq_cmakeoption4 Option's cache and how to reset?
511
512 When options have been set they are keep into a cache file named \"CMakeCache.txt\". So if you want 
513 reset values you just delete this file located to the project directory.
514
515 \subsection faq_cmakecompilation Cmake compilation
516
517 \subsubsection faq_cmakecompilation1 With command line.
518
519 \verbatim
520 cmake -D[name]=[value] ... ./
521 make
522 \endverbatim
523
524 \subsubsection faq_cmakecompilation2 With ccmake tool.
525
526 \verbatim
527 "ccmake ./"
528 \endverbatim
529 Then follow instructions.
530
531 \subsubsection faq_cmakecompilation3 Resume of command line
532
533  \li CMake
534 \verbatim
535 cmake ./                configure the project
536 make                    build all targets
537 make VERBOSE=1          build all targets and print build command lines
538 make test               test all targets and summarize
539 make dist               make the distrib
540 make distcheck          check the dist (make + make dist + make test) 
541 make install-simgrid    install the project (doc/ lib/ include/)
542 make uninstall          uninstall the project (doc/ lib/ include/)
543 make clean              clean all targets
544 make java-clean         clean files created by java option
545 make doc-clean          clean files created for making doc
546 make supernovae-clean   clean supernovae files
547 make maintainer-clean   clean maintainer files
548 make all-clean          execute the 5 upper clean command
549 make html               Create simgrid documentation
550 make maintainer-clean   Remove all files generated by mainainer mode
551 \endverbatim
552
553 When the project have been succesfully compiling and build you can make tests.
554
555  \li CTest
556 \verbatim
557 ctest                   launch only tests
558 ctest -D Continuous
559 ctest -D Continuous(Start|Update|Configure|Build)
560 ctest -D Continuous(Test|Coverage|MemCheck|Submit)
561 ctest -D Experimental
562 ctest -D Experimental(Start|Update|Configure|Build)
563 ctest -D Experimental(Test|Coverage|MemCheck|Submit)
564 ctest -D Nightly                                
565 ctest -D Nightly(Start|Update|Configure|Build)
566 ctest -D Nightly(Test|Coverage|MemCheck|Submit)
567 ctest -D NightlyMemoryCheck
568 \endverbatim
569
570 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>.
571
572 \subsubsection faq_cmakecompilation4 Examples for different mode.
573
574 \li Mode maintainer
575
576 cmake -Denable_maintainer_mode=on ./
577 \verbatim GTnetS doesn't works : set -Ddisable_gtnets=on
578 with_context auto change to ucontext
579 (skaddr)
580 (sksize)
581 Make : src/simgrid.jar with : /usr/bin/javac
582 Make examples/java with : /usr/bin/javac
583
584 Configuration of package `simgrid' (revision 7228M) on arch (=4):
585         BUILDNAME :             UCONTEXT
586              SITE :             Linux_Ubuntu 9.10_x86_64
587
588         Compiler: c++ :         /usr/bin/c++
589                version:         c++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
590                   c   :         /usr/bin/gcc
591                version:         gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1
592
593         CFlags:                 -g3
594         CPPFlags:               
595         LDFlags:                
596
597         Context backend:        ucontext
598         Compile Gtnets:         0
599                   path:         
600         Compile Java:           1
601         Compile Lua:            1
602         Compile Ruby:           0
603
604         Maintainer mode:        on
605         Supernovae mode:        off
606
607         Simgrid dependencies:   dl -llua5.1
608         Gras dependencies:      pthread
609         Ruby dependencies:      
610         Smpi dependencies:      
611
612         USER_PREFIX:            /usr/local
613         INSTALL_PREFIX:         /usr/local
614
615 -- Configuring done
616 -- Generating done
617 -- Build files have been written to: /home/navarrop/Bureau/simgrid-trunk
618 \endverbatim
619
620 \li Mode supernovae
621
622 cmake -Dsupernovae=on ./
623 \verbatim GTnetS doesn't works : set -Ddisable_gtnets=on
624 with_context auto change to ucontext
625 (skaddr)
626 (sksize)
627 Make : src/simgrid.jar with : /usr/bin/javac
628 Make examples/java with : /usr/bin/javac
629
630 Configuration of package `simgrid' (revision 7228M) on arch (=4):
631         BUILDNAME :             SUPERNOVAE
632              SITE :             Linux_Ubuntu 9.10_x86_64
633
634         Compiler: c++ :         /usr/bin/c++
635                version:         c++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
636                   c   :         /usr/bin/gcc
637                version:         gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1
638
639         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
640         CPPFlags:               
641         LDFlags:                
642
643         Context backend:        ucontext
644         Compile Gtnets:         0
645                   path:         
646         Compile Java:           1
647         Compile Lua:            1
648         Compile Ruby:           0
649
650         Maintainer mode:        off
651         Supernovae mode:        on
652
653         Simgrid dependencies:   dl -llua5.1
654         Gras dependencies:      pthread
655         Ruby dependencies:      
656         Smpi dependencies:      
657
658         USER_PREFIX:            /usr/local
659         INSTALL_PREFIX:         /usr/local
660
661 -- Configuring done
662 -- Generating done
663 -- Build files have been written to: /home/navarrop/Bureau/simgrid-trunk
664 \endverbatim
665
666 \li Mode GTnetS
667
668 cmake -Dgtnets_path=/home/navarrop/Bureau/usr/ ./
669 \verbatim with_context auto change to ucontext
670 (skaddr)
671 (sksize)
672 Make : src/simgrid.jar with : /usr/bin/javac
673 Make examples/java with : /usr/bin/javac
674
675 Configuration of package `simgrid' (revision 7228M) on arch (=4):
676         BUILDNAME :             GTNETS
677              SITE :             Linux_Ubuntu 9.10_x86_64
678
679         Compiler: c++ :         /usr/bin/c++
680                version:         c++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
681                   c   :         /usr/bin/gcc
682                version:         gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1
683
684         CFlags:                  -L/home/navarrop/Bureau/usr/lib -I/home/navarrop/Bureau/usr/include/gtnets -g3
685         CPPFlags:                -L/home/navarrop/Bureau/usr/lib -I/home/navarrop/Bureau/usr/include/gtnets 
686         LDFlags:                
687
688         Context backend:        ucontext
689         Compile Gtnets:         1
690                   path:         /home/navarrop/Bureau/usr
691         Compile Java:           1
692         Compile Lua:            1
693         Compile Ruby:           0
694
695         Maintainer mode:        off
696         Supernovae mode:        off
697
698         Simgrid dependencies:   dl -llua5.1 -lgtnets
699         Gras dependencies:      pthread
700         Ruby dependencies:      
701         Smpi dependencies:      
702
703         USER_PREFIX:            /usr/local
704         INSTALL_PREFIX:         /usr/local
705
706 INFO -->> Take care to have export LD_LIBRARY_PATH before run make command for make examples with gtnets
707 copy and paste : export LD_LIBRARY_PATH=/home/navarrop/Bureau/usr/lib/:$LD_LIBRARY_PATH
708
709
710 -- Configuring done
711 -- Generating done
712 -- Build files have been written to: /home/navarrop/Bureau/simgrid-trunk
713 \endverbatim
714
715 \subsection faq_cmakeinstall How to install with cmake?
716
717 \subsubsection faq_cmakeinstall1 From svn. 
718
719 \verbatim
720 cmake -Denable_maintainer_mode=on -Dprefix=/home/navarrop/Bureau/install_simgrid ./
721 make 
722 make install-simgrid
723 \endverbatim
724
725 \subsubsection faq_cmakeinstall2 From a distrib
726
727 \verbatim
728 cmake -Dprefix=/home/navarrop/Bureau/install_simgrid ./
729 make
730 make install-simgrid
731 \endverbatim
732
733 \subsection faq_screenshot Screenshot
734
735 \verbatim
736 navarrop@caraja:~$ cd Bureau/simgrid-trunk/
737 navarrop@caraja:~/Bureau/simgrid-trunk$ cmake ./
738
739 GTnetS doesn't works : set -Ddisable_gtnets=on                  <-|some warnings are printed 
740 with_context auto change to ucontext                            <-|
741 (skaddr)                                                        <--info (needed)
742 (sksize)                                                        <--info (needed)
743 Make : src/simgrid.jar with : /usr/bin/javac                    <--info (if java)
744 Make examples/java with : /usr/bin/javac                        <--info (if java)
745
746 Configuration of package `simgrid' (revision 7209M) on arch (=4):
747         BUILDNAME :             UCONTEXT                                <-- name of the compilation regarding to cdash
748              SITE :             Linux_Ubuntu 9.10_x86_64                <-- distribution of the local machine regarding to cdash
749
750         Compiler: c++ :         /usr/bin/c++
751                version:         c++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
752                   c   :         /usr/bin/gcc
753                version:         gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1
754
755         CFlags:                 -g3
756         CPPFlags:               
757         LDFlags:                
758
759         Context backend:        ucontext
760         Compile Gtnets:         0
761                   path:         
762         Compile Java:           1
763         Compile Lua:            1
764         Compile Ruby:           0
765
766         Maintainer mode:        OFF
767         Supernovae mode:        OFF
768
769         Simgrid dependencies:   -ldl -llua5.1
770         Gras dependencies:      pthread
771         Ruby dependencies:      
772         Smpi dependencies:      
773
774         USER_PREFIX:            /usr/local
775         INSTALL_PREFIX:         /usr/local
776
777 -- Configuring done
778 -- Generating done
779 -- Build files have been written to: /home/navarrop/Bureau/simgrid-trunk
780 \endverbatim
781 Here all options are checked and printed. If it doesn't match with your configuration 
782 it is probably due to a wrong configuration.
783
784 \subsection faq_cmakehowto How to modified sources files for developers
785
786 \subsubsection faq_cmakehowto1 Add an executable or examples.
787
788 If you want make an executable you have to create a CMakeList.txt to the src directory. 
789 You must specified where to create the executable, source list, dependencies and the name of the binary.
790
791 \verbatim
792 cmake_minimum_required(VERSION 2.6)
793
794 set(EXECUTABLE_OUTPUT_PATH "./")                        
795 set(LIBRARY_OUTPUT_PATH "${PROJECT_DIRECTORY}/lib")
796
797 add_executable(get_sender get_sender.c)                                 #add_executable(<name_of_target> <src list>)
798
799 ### Add definitions for compile
800 target_link_libraries(get_sender simgrid m pthread -fprofile-arcs)      #target_link_libraries(<name_of_targe> <dependencies>)
801 \endverbatim
802
803 Then you have to modified <project/directory>/buildtools/Cmake/src/CMakeMakeExeLib.txt and add 
804 this line :
805 \verbatim
806 add_subdirectory(${PROJECT_DIRECTORY}/<path_where_is_CMakeList.txt>)
807 \endverbatim
808
809 \subsubsection faq_cmakehowto2 Delete/add sources to lib.
810
811 If you want modified, add or delete source files from a library you have to edit <project/directory>/buildtools/Cmake/src/CMakeDefinePackages.txt
812
813 \verbatim
814 set(JMSG_JAVA_SRC
815         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/MsgException.java
816         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/JniException.java
817         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/NativeException.java
818         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/HostNotFoundException.java
819         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/ProcessNotFoundException.java
820         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/Msg.java
821         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/Process.java
822         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/Host.java
823         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/Task.java
824         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/MsgNative.java
825         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/ApplicationHandler.java
826         ${PROJECT_DIRECTORY}/src/java/simgrid/msg/Sem.java
827 )
828 \endverbatim
829
830 \subsubsection faq_cmakehowto3 Add test
831
832 If you want modified, add or delete tests you have to edit <project/directory>/buildtools/Cmake/src/CMakeTest.txt 
833 with this function : ADD_TEST(<name> <bin> <ARGS>)
834
835 \verbatim
836 add_test(test-simdag-1 ${PROJECT_DIRECTORY}/testsuite/simdag/sd_test --cfg=path:${PROJECT_DIRECTORY}/testsuite/simdag small_platform_variable.xml)
837 \endverbatim
838
839 \subsection faq_cmakeExplain Explaination of sources files for cmake
840
841 \li CMakeLists.txt
842
843 Those files are the "main parts". One located at the project directory call all the cmake sources files. The others
844 are little projects called by the first for make examples.
845
846 \li CMakeCompleteInFiles.txt
847
848 Complete all .in files and define Variables for h files
849
850 \li CMakeDocs.txt
851
852 This file make the html documentation.
853
854 \li CMakeMakeExeLib.txt
855
856 Here are callled all "CMakeLists.txt" for make executables and libraries.
857
858 \li CMakePrintArgs.txt
859
860 This file is called at the end of the build for summarize environment variables.
861
862 \li CMakeDefinePackages.txt
863
864 Here is defined sources packages for compiling libs.
865
866 \li CMakeFlags.txt
867
868 Defined flags which are used for compiling sources.
869
870 \li CMakeSupernovae.txt
871
872 Here are made files for the supernovae mode.
873
874 \li CMakeDistrib.txt
875
876 Here is defined packages for install simgrid and make a distribution.
877
878 \li CMakeMaintainerMode.txt
879
880 Part where are generated source files for maintainer mode.
881
882 \li CMakeOption.txt
883
884 Here are defined options and initialized values.
885
886 \li CMakeTest.txt
887
888 All tests are listed.
889
890 \li CTestConfig.cmake
891
892 Properties which link tests with dashboard.
893
894 \subsection faq_cmakeList List of files added for cmake
895
896 Here is a list of files involved into cmake build (relative to project directory path) :
897 \verbatim
898
899 Cmake sources:
900         ./doc/CMakeLists.txt
901         ./buildtools/Cmake/src/CMakeCompleteInFiles.txt
902         ./buildtools/Cmake/src/CMakeDocs.txt
903         ./buildtools/Cmake/src/CMakeMakeExeLib.txt
904         ./buildtools/Cmake/src/CMakePrintArgs.txt
905         ./buildtools/Cmake/src/CMakeDefinePackages.txt
906         ./buildtools/Cmake/src/CMakeFlags.txt
907         ./buildtools/Cmake/src/CMakeSupernovae.txt
908         ./buildtools/Cmake/src/CMakeDistrib.txt
909         ./buildtools/Cmake/src/CMakeMaintainerMode.txt
910         ./buildtools/Cmake/src/CMakeOption.txt
911         ./buildtools/Cmake/src/CMakeTest.txt
912         ./buildtools/Cmake/src/CTestConfig.cmake
913
914 Test files for define properties :
915         ./buildtools/Cmake/prog_test/prog_GRAS_ARCH.c
916         ./buildtools/Cmake/prog_test/prog_max_size.c
917         ./buildtools/Cmake/prog_test/prog_sem_init.c
918         ./buildtools/Cmake/prog_test/prog_stackgrowth.c
919         ./buildtools/Cmake/prog_test/prog_vsnprintf.c
920         ./buildtools/Cmake/prog_test/prog_AC_CHECK_MCSC.c
921         ./buildtools/Cmake/prog_test/prog_GRAS_CHECK_STRUCT_COMPACTION.c
922         ./buildtools/Cmake/prog_test/prog_mutex_timedlock.c
923         ./buildtools/Cmake/prog_test/prog_sem_timedwait.c
924         ./buildtools/Cmake/prog_test/prog_stacksetup.c
925         ./buildtools/Cmake/prog_test/prog_getline.c
926         ./buildtools/Cmake/prog_test/prog_gtnets.cpp
927         ./buildtools/Cmake/prog_test/prog_printf_null.c
928         ./buildtools/Cmake/prog_test/prog_snprintf.c
929         ./buildtools/Cmake/prog_test/prog_va_copy.c
930
931 CMakeLists for each binaries or examples:
932         ./CMakeLists.txt
933         ./src/CMakeLists.txt
934         ./teshsuite/gras/empty_main/CMakeLists.txt
935         ./teshsuite/gras/small_sleep/CMakeLists.txt
936         ./teshsuite/gras/datadesc/CMakeLists.txt
937         ./teshsuite/gras/msg_handle/CMakeLists.txt
938         ./teshsuite/simdag/CMakeLists.txt
939         ./teshsuite/simdag/partask/CMakeLists.txt
940         ./teshsuite/simdag/platforms/CMakeLists.txt
941         ./teshsuite/simdag/network/CMakeLists.txt
942         ./teshsuite/simdag/network/mxn/CMakeLists.txt
943         ./teshsuite/simdag/network/p2p/CMakeLists.txt
944         ./teshsuite/xbt/CMakeLists.txt
945         ./teshsuite/msg/CMakeLists.txt
946         ./tools/gras/CMakeLists.txt
947         ./tools/tesh/CMakeLists.txt
948         ./testsuite/simdag/CMakeLists.txt
949         ./testsuite/xbt/CMakeLists.txt
950         ./testsuite/surf/CMakeLists.txt
951         ./examples/gras/properties/CMakeLists.txt
952         ./examples/gras/ping/CMakeLists.txt
953         ./examples/gras/pmm/CMakeLists.txt
954         ./examples/gras/mmrpc/CMakeLists.txt
955         ./examples/gras/synchro/CMakeLists.txt
956         ./examples/gras/timer/CMakeLists.txt
957         ./examples/gras/mutual_exclusion/simple_token/CMakeLists.txt
958         ./examples/gras/spawn/CMakeLists.txt
959         ./examples/gras/chrono/CMakeLists.txt
960         ./examples/gras/rpc/CMakeLists.txt
961         ./examples/gras/all2all/CMakeLists.txt
962         ./examples/simdag/properties/CMakeLists.txt
963         ./examples/simdag/CMakeLists.txt
964         ./examples/simdag/metaxml/CMakeLists.txt
965         ./examples/simdag/dax/CMakeLists.txt
966         ./examples/smpi/CMakeLists.txt
967         ./examples/amok/bandwidth/CMakeLists.txt
968         ./examples/amok/saturate/CMakeLists.txt
969         ./examples/msg/priority/CMakeLists.txt
970         ./examples/msg/properties/CMakeLists.txt
971         ./examples/msg/migration/CMakeLists.txt
972         ./examples/msg/gtnets/CMakeLists.txt
973         ./examples/msg/parallel_task/CMakeLists.txt
974         ./examples/msg/trace/CMakeLists.txt
975         ./examples/msg/suspend/CMakeLists.txt
976         ./examples/msg/masterslave/CMakeLists.txt
977         ./examples/msg/actions/CMakeLists.txt
978         ./examples/msg/sendrecv/CMakeLists.txt
979 \endverbatim
980
981 \section faq_howto Feature related questions
982
983 \subsection faq_MIA "Could you please add (your favorite feature here) to SimGrid?"
984
985 Here is the deal. The whole SimGrid project (MSG, SURF, GRAS, ...) is
986 meant to be kept as simple and generic as possible. We cannot add
987 functions for everybody's needs when these functions can easily be
988 built from the ones already in the API. Most of the time, it is
989 possible and when it was not possible we always have upgraded the API
990 accordingly. When somebody asks us a question like "How to do that?
991 Is there a function in the API to simply do this?", we're always glad
992 to answer and help. However if we don't need this code for our own
993 need, there is no chance we're going to write it... it's your job! :)
994 The counterpart to our answers is that once you come up with a neat
995 implementation of this feature (task duplication, RPC, thread
996 synchronization, ...), you should send it to us and we will be glad to
997 add it to the distribution. Thus, other people will take advantage of
998 it (and we don't have to answer this question again and again ;).
999
1000 You'll find in this section a few "Missing In Action" features. Many
1001 people have asked about it and we have given hints on how to simply do
1002 it with MSG. Feel free to contribute...
1003
1004 \subsection faq_MIA_MSG MSG features
1005
1006 \subsubsection faq_MIA_examples I want some more complex MSG examples!
1007
1008 Many people have come to ask me a more complex example and each time,
1009 they have realized afterward that the basics were in the previous three
1010 examples. 
1011
1012 Of course they have often been needing more complex functions like
1013 MSG_process_suspend(), MSG_process_resume() and
1014 MSG_process_isSuspended() (to perform synchronization), or
1015 MSG_task_Iprobe() and MSG_process_sleep() (to avoid blocking
1016 receptions), or even MSG_process_create() (to design asynchronous
1017 communications or computations). But the examples are sufficient to
1018 start.
1019
1020 We know. We should add some more examples, but not really some more
1021 complex ones... We should add some examples that illustrate some other
1022 functionalists (like how to simply encode asynchronous
1023 communications, RPC, process migrations, thread synchronization, ...)
1024 and we will do it when we will have a little bit more time. We have
1025 tried to document the examples so that they are understandable. Tell
1026 us if something is not clear and once again feel free to participate!
1027 :)
1028
1029 \subsubsection faq_MIA_taskdup Missing in action: MSG Task duplication/replication
1030
1031 There is no task duplication in MSG. When you create a task, you can
1032 process it or send it somewhere else. As soon as a process has sent
1033 this task, he doesn't have this task anymore. It's gone. The receiver
1034 process has got the task. However, you could decide upon receiving to
1035 create a "copy" of a task but you have to handle by yourself the
1036 semantic associated to this "duplication".
1037
1038 As we already told, we prefer keeping the API as simple as
1039 possible. This kind of feature is rather easy to implement by users
1040 and the semantic you associate really depends on people. Having a
1041 *generic* task duplication mechanism is not that trivial (in
1042 particular because of the data field). That is why I would recommand
1043 that you write it by yourself even if I can give you advice on how to
1044 do it.
1045
1046 You have the following functions to get informations about a task:
1047 MSG_task_get_name(), MSG_task_get_compute_duration(),
1048 MSG_task_get_remaining_computation(), MSG_task_get_data_size(),
1049 and MSG_task_get_data().
1050
1051 You could use a dictionary (#xbt_dict_t) of dynars (#xbt_dynar_t). If
1052 you still don't see how to do it, please come back to us...
1053
1054 \subsubsection faq_MIA_asynchronous I want to do asynchronous communications in MSG
1055
1056 Up until now, there is no asynchronous communications in MSG. However,
1057 you can create as many process as you want so you should be able to do
1058 whatever you want... I've written a queue module to help implementing
1059 some asynchronous communications at low cost (creating thousands of
1060 process only to handle communications may be problematic in term of
1061 performance at some point). I'll add it in the distribution asap.
1062
1063 \subsubsection faq_MIA_thread_synchronization I need to synchronize my MSG processes
1064
1065 You obviously cannot use pthread_mutexes of pthread_conds. The best
1066 thing would be to propose similar structures. Unfortunately, we
1067 haven't found time to do it yet. However you can try to play with
1068 MSG_process_suspend() and MSG_process_resume(). You can even do some
1069 synchronization with fake communications (using MSG_task_get(),
1070 MSG_task_put() and MSG_task_Iprobe()).
1071
1072 \subsubsection faq_MIA_host_load Where is the get_host_load function hidden in MSG?
1073
1074 There is no such thing because its semantic wouldn't be really
1075 clear. Of course, it is something about the amount of host throughput,
1076 but there is as many definition of "host load" as people asking for
1077 this function. First, you have to remember that resource availability
1078 may vary over time, which make any load notion harder to define.
1079
1080 It may be instantaneous value or an average one. Moreover it may be only the
1081 power of the computer, or may take the background load into account, or may
1082 even take the currently running tasks into account. In some SURF models,
1083 communications have an influence on computational power. Should it be taken
1084 into account too?
1085
1086 First of all, it's near to impossible to predict the load beforehands in the
1087 simulator since it depends on too much parameters (background load
1088 variation, bandwidth sharing algorithmic complexity) some of them even being
1089 not known beforehands (other task starting at the same time). So, getting
1090 this information is really hard (just like in real life). It's not just that
1091 we want MSG to be as painful as real life. But as it is in some way
1092 realistic, we face some of the same problems as we would face in real life.
1093
1094 How would you do it for real? The most common option is to use something
1095 like NWS that performs active probes. The best solution is probably to do
1096 the same within MSG, as in next code snippet. It is very close from what you
1097 would have to do out of the simulator, and thus gives you information that
1098 you could also get in real settings to not hinder the realism of your
1099 simulation. 
1100
1101 \verbatim
1102 double get_host_load() {
1103    m_task_t task = MSG_task_create("test", 0.001, 0, NULL);
1104    double date = MSG_get_clock();
1105
1106    MSG_task_execute(task);
1107    date = MSG_get_clock() - date;
1108    MSG_task_destroy(task);
1109    return (0.001/date);
1110 }
1111 \endverbatim
1112
1113 Of course, it may not match your personal definition of "host load". In this
1114 case, please detail what you mean on the mailing list, and we will extend
1115 this FAQ section to fit your taste if possible.
1116
1117 \subsubsection faq_MIA_communication_time How can I get the *real* communication time?  
1118
1119 Communications are synchronous and thus if you simply get the time
1120 before and after a communication, you'll only get the transmission
1121 time and the time spent to really communicate (it will also take into
1122 account the time spent waiting for the other party to be
1123 ready). However, getting the *real* communication time is not really
1124 hard either. The following solution is a good starting point.
1125
1126 \verbatim
1127 int sender()
1128 {
1129   m_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size, 
1130                                   calloc(1,sizeof(double)));
1131   *((double*) task->data) = MSG_get_clock();
1132   MSG_task_put(task, slaves[i % slaves_count], PORT_22);
1133   INFO0("Send completed");
1134   return 0;
1135 }
1136 int receiver()
1137 {
1138   m_task_t task = NULL;
1139   double time1,time2;
1140
1141   time1 = MSG_get_clock();
1142   a = MSG_task_get(&(task), PORT_22);
1143   time2 = MSG_get_clock();
1144   if(time1<*((double *)task->data))
1145      time1 = *((double *) task->data);
1146   INFO1("Communication time :  \"%f\" ", time2-time1);
1147   free(task->data);
1148   MSG_task_destroy(task);
1149   return 0;
1150 }
1151 \endverbatim
1152
1153 \subsection faq_MIA_SimDag SimDag related questions
1154
1155 \subsubsection faq_SG_comm Implementing communication delays between tasks.
1156
1157 A classic question of SimDag newcomers is about how to express a
1158 communication delay between tasks. The thing is that in SimDag, both
1159 computation and communication are seen as tasks.  So, if you want to
1160 model a data dependency between two DAG tasks t1 and t2, you have to
1161 create 3 SD_tasks: t1, t2 and c and add dependencies in the following
1162 way:
1163
1164 \verbatim
1165 SD_task_dependency_add(NULL, NULL, t1, c);
1166 SD_task_dependency_add(NULL, NULL, c, t2);
1167 \endverbatim
1168
1169 This way task t2 cannot start before the termination of communication c
1170 which in turn cannot start before t1 ends.
1171
1172 When creating task c, you have to associate an amount of data (in bytes)
1173 corresponding to what has to be sent by t1 to t2.
1174
1175 Finally to schedule the communication task c, you have to build a list
1176 comprising the workstations on which t1 and t2 are scheduled (w1 and w2
1177 for example) and build a communication matrix that should look like
1178 [0;amount ; 0; 0].
1179
1180 \subsubsection faq_SG_DAG How to implement a distributed dynamic scheduler of DAGs.
1181
1182 Distributed is somehow "contagious". If you start making distributed
1183 decisions, there is no way to handle DAGs directly anymore (unless I
1184 am missing something). You have to encode your DAGs in term of
1185 communicating process to make the whole scheduling process
1186 distributed. Here is an example of how you could do that. Assume T1
1187 has to be done before T2.
1188
1189 \verbatim
1190  int your_agent(int argc, char *argv[] {
1191    ...
1192    T1 = MSG_task_create(...);
1193    T2 = MSG_task_create(...);
1194    ...
1195    while(1) {
1196      ...
1197      if(cond) MSG_task_execute(T1);
1198      ...
1199      if((MSG_task_get_remaining_computation(T1)=0.0) && (you_re_in_a_good_mood))
1200         MSG_task_execute(T2)
1201      else {
1202         /* do something else */
1203      }
1204    }
1205  }
1206 \endverbatim
1207  
1208 If you decide that the distributed part is not that much important and that
1209 DAG is really the level of abstraction you want to work with, then you should
1210 give a try to \ref SD_API.
1211
1212 \subsection faq_MIA_generic Generic features
1213
1214 \subsubsection faq_more_processes Increasing the amount of simulated processes
1215
1216 Here are a few tricks you can apply if you want to increase the amount
1217 of processes in your simulations.
1218
1219  - <b>A few thousands of simulated processes</b> (soft tricks)\n
1220    SimGrid can use either pthreads library or the UNIX98 contextes. On
1221    most systems, the number of pthreads is limited and then your
1222    simulation may be limited for a stupid reason. This is especially
1223    true with the current linux pthreads, and I cannot get more than
1224    2000 simulated processes with pthreads on my box. The UNIX98
1225    contexts allow me to raise the limit to 25,000 simulated processes
1226    on my laptop.\n\n
1227    The <tt>--with-context</tt> option of the <tt>./configure</tt>
1228    script allows you to choose between UNIX98 contextes
1229    (<tt>--with-context=ucontext</tt>) and the pthread version
1230    (<tt>--with-context=pthread</tt>). The default value is ucontext
1231    when the script detect a working UNIX98 context implementation. On
1232    Windows boxes, the provided value is discarded and an adapted
1233    version is picked up.\n\n
1234    We experienced some issues with contextes on some rare systems
1235    (solaris 8 and lower or old alpha linuxes comes to mind). The main
1236    problem is that the configure script detect the contextes as being
1237    functional when it's not true. If you happen to use such a system,
1238    switch manually to the pthread version, and provide us with a good
1239    patch for the configure script so that it is done automatically ;)
1240
1241  - <b>Hundred thousands of simulated processes</b> (hard-core tricks)\n 
1242    As explained above, SimGrid can use UNIX98 contextes to represent
1243    and handle the simulated processes. Thanks to this, the main
1244    limitation to the number of simulated processes becomes the
1245    available memory.\n\n
1246    Here are some tricks I had to use in order to run a token ring
1247    between 25,000 processes on my laptop (1Gb memory, 1.5Gb swap).\n
1248    - First of all, make sure your code runs for a few hundreds
1249      processes before trying to push the limit. Make sure it's
1250      valgrind-clean, ie that valgrind does not report neither memory
1251      error nor memory leaks. Indeed, numerous simulated processes
1252      result in *fat* simulation hindering debugging.
1253    - It was really boring to write 25,000 entries in the deployment
1254      file, so I wrote a little script
1255      <tt>examples/gras/mutual_exclusion/simple_token/make_deployment.pl</tt>, which you may
1256      want to adapt to your case. You could also think about hijacking
1257      the SURFXML parser (have look at \ref faq_flexml_bypassing).
1258    - The deployment file became quite big, so I had to do what is in
1259      the FAQ entry \ref faq_flexml_limit
1260    - Each UNIX98 context has its own stack entry. As debugging this is
1261      quite hairly, the default value is a bit overestimated so that
1262      user don't get into trouble about this. You want to tune this
1263      size to increse the number of processes. This is the
1264      <tt>STACK_SIZE</tt> define in 
1265      <tt>src/xbt/xbt_context_sysv.c</tt>, which is 128kb by default.
1266      Reduce this as much as you can, but be warned that if this value
1267      is too low, you'll get a segfault. The token ring example, which
1268      is quite simple, runs with 40kb stacks.     
1269    - You may tweak the logs to reduce the stack size further.  When
1270      logging something, we try to build the string to display in a
1271      char array on the stack. The size of this array is constant (and
1272      equal to XBT_LOG_BUFF_SIZE, defined in include/xbt/log/h). If the
1273      string is too large to fit this buffer, we move to a dynamically
1274      sized buffer. In which case, we have to traverse one time the log
1275      event arguments to compute the size we need for the buffer,
1276      malloc it, and traverse the argument list again to do the actual
1277      job.\n     
1278      The idea here is to move XBT_LOG_BUFF_SIZE to 1, forcing the logs
1279      to use a dynamic array each time. This allows us to lower further
1280      the stack size at the price of some performance loss...\n
1281      This allowed me to run the reduce the stack size to ... 4k. Ie,
1282      on my 1Gb laptop, I can run more than 250,000 processes!
1283
1284 \subsubsection faq_MIA_batch_scheduler Is there a native support for batch schedulers in SimGrid?
1285
1286 No, there is no native support for batch schedulers and none is
1287 planned because this is a very specific need (and doing it in a
1288 generic way is thus very hard). However some people have implemented
1289 their own batch schedulers. Vincent Garonne wrote one during his PhD
1290 and put his code in the contrib directory of our SVN so that other can
1291 keep working on it. You may find inspiring ideas in it.
1292
1293 \subsubsection faq_MIA_checkpointing I need a checkpointing thing
1294
1295 Actually, it depends on whether you want to checkpoint the simulation, or to
1296 simulate checkpoints. 
1297
1298 The first one could help if your simulation is a long standing process you
1299 want to keep running even on hardware issues. It could also help to
1300 <i>rewind</i> the simulation by jumping sometimes on an old checkpoint to
1301 cancel recent calculations.\n 
1302 Unfortunately, such thing will probably never exist in SG. One would have to
1303 duplicate all data structures because doing a rewind at the simulator level
1304 is very very hard (not talking about the malloc free operations that might
1305 have been done in between). Instead, you may be interested in the Libckpt
1306 library (http://www.cs.utk.edu/~plank/plank/www/libckpt.html). This is the
1307 checkpointing solution used in the condor project, for example. It makes it
1308 easy to create checkpoints (at the OS level, creating something like core
1309 files), and rerunning them on need.
1310
1311 If you want to simulate checkpoints instead, it means that you want the
1312 state of an executing task (in particular, the progress made towards
1313 completion) to be saved somewhere.  So if a host (and the task executing on
1314 it) fails (cf. #MSG_HOST_FAILURE), then the task can be restarted
1315 from the last checkpoint.\n
1316
1317 Actually, such a thing does not exists in SimGrid either, but it's just
1318 because we don't think it is fundamental and it may be done in the user code
1319 at relatively low cost. You could for example use a watcher that
1320 periodically get the remaining amount of things to do (using
1321 MSG_task_get_remaining_computation()), or fragment the task in smaller
1322 subtasks.
1323
1324 \subsection faq_platform Platform building and Dynamic resources
1325
1326 \subsubsection faq_platform_example Where can I find SimGrid platform files?
1327
1328 There is several little examples in the archive, in the examples/msg
1329 directory. From time to time, we are asked for other files, but we
1330 don't have much at hand right now. 
1331
1332 You should refer to the Platform Description Archive
1333 (http://pda.gforge.inria.fr) project to see the other platform file we
1334 have available, as well as the Simulacrum simulator, meant to generate
1335 SimGrid platforms using all classical generation algorithms.
1336
1337 \subsubsection faq_platform_alnem How can I automatically map an existing platform?
1338
1339 We are working on a project called ALNeM (Application-Level Network
1340 Mapper) which goal is to automatically discover the topology of an
1341 existing network. Its output will be a platform description file
1342 following the SimGrid syntax, so everybody will get the ability to map
1343 their own lab network (and contribute them to the catalog project).
1344 This tool is not ready yet, but it move quite fast forward. Just stay
1345 tuned.
1346
1347 \subsubsection faq_platform_synthetic Generating synthetic but realistic platforms
1348
1349 The third possibility to get a platform file (after manual or
1350 automatic mapping of real platforms) is to generate synthetic
1351 platforms. Getting a realistic result is not a trivial task, and
1352 moreover, nobody is really able to define what "realistic" means when
1353 speaking of topology files. You can find some more thoughts on this
1354 topic in these
1355 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">slides</a>.
1356
1357 If you are looking for an actual tool, there we have a little tool to
1358 annotate Tiers-generated topologies. This perl-script is in
1359 <tt>tools/platform_generation/</tt> directory of the SVN. Dinda et Al.
1360 released a very comparable tool, and called it GridG.
1361
1362 \subsubsection faq_SURF_dynamic Expressing dynamic resource availability in platform files
1363
1364 A nice feature of SimGrid is that it enables you to seamlessly have
1365 resources whose availability change over time. When you build a
1366 platform, you generally declare hosts like that:
1367
1368 \verbatim
1369   <host id="host A" power="100.00"/>
1370 \endverbatim 
1371
1372 If you want the availability of "host A" to change over time, the only
1373 thing you have to do is change this definition like that:
1374
1375 \verbatim
1376   <host id="host A" power="100.00" availability_file="trace_A.txt" state_file="trace_A_failure.txt"/>
1377 \endverbatim
1378
1379 For hosts, availability files are expressed in fraction of available
1380 power. Let's have a look at what "trace_A.txt" may look like:
1381
1382 \verbatim
1383 PERIODICITY 1.0
1384 0.0 1.0
1385 11.0 0.5
1386 20.0 0.9
1387 \endverbatim
1388
1389 At time 0, our host will deliver 100 flop/s. At time 11.0, it will
1390 deliver only 50 flop/s until time 20.0 where it will will start
1391 delivering 90 flop/s. Last at time 21.0 (20.0 plus the periodicity
1392 1.0), we'll be back to the beginning and it will deliver 100 flop/s.
1393
1394 Now let's look at the state file:
1395 \verbatim
1396 PERIODICITY 10.0
1397 1.0 -1.0
1398 2.0 1.0
1399 \endverbatim
1400
1401 A negative value means "off" while a positive one means "on". At time
1402 1.0, the host is on. At time 1.0, it is turned off and at time 2.0, it
1403 is turned on again until time 12 (2.0 plus the periodicity 10.0). It
1404 will be turned on again at time 13.0 until time 23.0, and so on.
1405
1406 Now, let's look how the same kind of thing can be done for network
1407 links. A usual declaration looks like:
1408
1409 \verbatim
1410   <link id="LinkA" bandwidth="10.0" latency="0.2"/>
1411 \endverbatim
1412
1413 You have at your disposal the following options: bandwidth_file,
1414 latency_file and state_file. The only difference with hosts is that
1415 bandwidth_file and latency_file do not express fraction of available
1416 power but are expressed directly in bytes per seconds and seconds.
1417
1418 \subsubsection faq_platform_multipath How to express multipath routing in platform files?
1419
1420 It is unfortunately impossible to express the fact that there is more
1421 than one routing path between two given hosts. Let's consider the
1422 following platform file:
1423
1424 \verbatim
1425 <route src="A" dst="B">
1426    <link:ctn id="1"/>
1427 </route>
1428 <route src="B" dst="C">
1429   <link:ctn id="2"/>
1430 </route>
1431 <route src="A" dst="C">
1432   <link:ctn id="3"/>
1433 </route>
1434 \endverbatim
1435
1436 Although it is perfectly valid, it does not mean that data traveling
1437 from A to C can either go directly (using link 3) or through B (using
1438 links 1 and 2). It simply means that the routing on the graph is not
1439 trivial, and that data do not following the shortest path in number of
1440 hops on this graph. Another way to say it is that there is no implicit
1441 in these routing descriptions. The system will only use the routes you
1442 declare (such as &lt;route src="A" dst="C"&gt;&lt;link:ctn
1443 id="3"/&gt;&lt;/route&gt;), without trying to build new routes by aggregating
1444 the provided ones.
1445   
1446 You are also free to declare platform where the routing is not
1447 symmetric. For example, add the following to the previous file:
1448
1449 \verbatim
1450 <route src="C" dst="A">
1451   <link:ctn id="2"/>
1452   <link:ctn id="1"/>
1453 </route>
1454 \endverbatim
1455
1456 This makes sure that data from C to A go through B where data from A
1457 to C go directly. Don't worry about realism of such settings since
1458 we've seen ways more weird situation in real settings (in fact, that's
1459 the realism of very regular platforms which is questionable, but
1460 that's another story).
1461
1462 \subsubsection faq_flexml_bypassing Bypassing the XML parser with your own C functions
1463
1464 So you want to bypass the XML files parser, uh? Maybe doing some parameter
1465 sweep experiments on your simulations or so? This is possible, and
1466 it's not even really difficult (well. Such a brutal idea could be
1467 harder to implement). Here is how it goes.
1468
1469 For this, you have to first remember that the XML parsing in SimGrid is done
1470 using a tool called FleXML. Given a DTD, this gives a flex-based parser. If
1471 you want to bypass the parser, you need to provide some code mimicking what
1472 it does and replacing it in its interactions with the SURF code. So, let's
1473 have a look at these interactions.
1474
1475 FleXML parser are close to classical SAX parsers. It means that a
1476 well-formed SimGrid platform XML file might result in the following
1477 "events":
1478
1479   - start "platform_description" with attribute version="2"
1480   - start "host" with attributes id="host1" power="1.0"
1481   - end "host"
1482   - start "host" with attributes id="host2" power="2.0"
1483   - end "host"
1484   - start "link" with ...
1485   - end "link"
1486   - start "route" with ...
1487   - start "link:ctn" with ...
1488   - end "link:ctn"
1489   - end "route"
1490   - end "platform_description"
1491
1492 The communication from the parser to the SURF code uses two means:
1493 Attributes get copied into some global variables, and a surf-provided
1494 function gets called by the parser for each event. For example, the event
1495   - start "host" with attributes id="host1" power="1.0"
1496
1497 let the parser do something roughly equivalent to:
1498 \verbatim
1499   strcpy(A_host_id,"host1");
1500   A_host_power = 1.0;
1501   STag_host();
1502 \endverbatim
1503
1504 In SURF, we attach callbacks to the different events by initializing the
1505 pointer functions to some the right surf functions. Since there can be
1506 more than one callback attached to the same event (if more than one
1507 model is in use, for example), they are stored in a dynar. Example in
1508 workstation_ptask_L07.c:
1509 \verbatim
1510   /* Adding callback functions */
1511   surf_parse_reset_parser();
1512   surfxml_add_callback(STag_surfxml_host_cb_list, &parse_cpu_init);
1513   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
1514   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
1515   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
1516   surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
1517   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
1518                 
1519   /* Parse the file */
1520   surf_parse_open(file);
1521   xbt_assert1((!surf_parse()), "Parse error in %s", file);
1522   surf_parse_close();
1523 \endverbatim
1524     
1525 So, to bypass the FleXML parser, you need to write your own version of the
1526 surf_parse function, which should do the following:
1527    - Fill the A_<tag>_<attribute> variables with the wanted values
1528    - Call the corresponding STag_<tag>_fun function to simulate tag start
1529    - Call the corresponding ETag_<tag>_fun function to simulate tag end
1530    - (do the same for the next set of values, and loop)
1531
1532 Then, tell SimGrid that you want to use your own "parser" instead of the stock one:
1533 \verbatim
1534   surf_parse = surf_parse_bypass_environment;
1535   MSG_create_environment(NULL);
1536   surf_parse = surf_parse_bypass_application;
1537   MSG_launch_application(NULL);
1538 \endverbatim
1539
1540 A set of macros are provided at the end of
1541 include/surf/surfxml_parse.h to ease the writing of the bypass
1542 functions. An example of this trick is distributed in the file
1543 examples/msg/masterslave/masterslave_bypass.c
1544
1545 \subsection faq_simgrid_configuration Changing SimGrid's behavior
1546
1547 A number of options can be given at runtime to change the default
1548 SimGrid behavior. In particular, you can change the default cpu and
1549 network models...
1550
1551 \subsubsection faq_simgrid_configuration_gtnets Using GTNetS
1552
1553 It is possible to use a packet-level network simulator
1554 instead of the default flow-based simulation. You may want to use such
1555 an approach if you have doubts about the validity of the default model
1556 or if you want to perform some validation experiments. At the moment,
1557 we support the GTNetS simulator (it is still rather experimental
1558 though, so leave us a message if you play with it). 
1559
1560
1561 <i>
1562 To enable GTNetS model inside SimGrid it is needed to patch the GTNetS simulator source code 
1563 and build/install it from scratch
1564 </i>
1565
1566  - <b>Download and enter the recent downloaded GTNetS directory</b>
1567
1568  \verbatim
1569  svn checkout svn://scm.gforge.inria.fr/svn/simgrid/contrib/trunk/GTNetS/
1570  cd GTNetS
1571  \endverbatim
1572
1573
1574  - <b>Use the following commands to unzip and patch GTNetS package to work within SimGrid.</b>
1575
1576  \verbatim
1577  unzip gtnets-current.zip
1578  tar zxvf gtnets-current-patch.tgz 
1579  cd gtnets-current
1580  cat ../00*.patch | patch -p1
1581  \endverbatim
1582
1583   - <b>OPTIONALLY</b> you can use a patch for itanium 64bit processor family.
1584
1585   \verbatim
1586   cat ../AMD64-FATAL-Removed-DUL_SIZE_DIFF-Added-fPIC-compillin.patch | patch -p1
1587   \endverbatim
1588
1589  - <b>Compile GTNetS</b>
1590
1591    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. 
1592
1593
1594  \verbatim
1595  ln -sf Makefile.linux Makefile
1596  make depend
1597  make debug
1598  \endverbatim
1599
1600
1601  - <b>NOTE</b> A lot of warnings are expected but the application should compile
1602  just fine. If the makefile insists in compiling some QT libraries
1603  please try a make clean before asking for help.
1604
1605
1606  - <b>To compile optimized version</b>
1607
1608  \verbatim
1609  make opt
1610  \endverbatim
1611
1612
1613  - <b>Installing GTNetS</b>
1614
1615  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.
1616
1617  \verbatim
1618  ln -sf /<absolute_path>/gtnets_current/libgtsim-debug.so /<userhome>/usr/lib/libgtnets.so
1619  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/<userhome>/usr/lib/libgtnets.so
1620  mkdir /<userhome>/usr/include/gtnets
1621  cp -fr SRC/*.h /<userhome>/usr/include/gtnets
1622  \endverbatim
1623
1624
1625  - <b>Enable GTNetS support in SimGrid</b>
1626
1627    \verbatim
1628    ./configure --with-gtnets=/<userhome>/usr
1629    \endverbatim
1630
1631  - <b>Once you have followed all the instructions for compiling and
1632    installing successfully you can activate this feature at 
1633    runntime with the following options:</b>
1634
1635    \verbatim
1636    cd simgrid/example/msg/
1637    make
1638    make check
1639    \endverbatim
1640
1641
1642  - <b>Or try the GTNetS model dogbone example with</b>
1643
1644  \verbatim
1645  gtnets/gtnets gtnets/onelink-p.xml gtnets/onelink-d.xml --cfg=network_model:GTNets
1646  \endverbatim
1647
1648  
1649  A long version of this <a href="http://gforge.inria.fr/docman/view.php/12/6283/GTNetS HowTo.html">HowTo</a>  it is available 
1650
1651
1652  More about GTNetS simulator at <a href="http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/index.html">GTNetS Website</a>
1653
1654
1655  - <b>DISCLAIMER</b>
1656  The patches provided by us worked successfully with GTNetS found 
1657  <a href="http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/software/gtnets-current.zip">here</a>, 
1658  dated from 12th June 2008. Due to the discontinuing development of
1659  GTNetS it is impossible to precise a version number. We STRONGLY recommend you
1660  to download and install the GTNetS version found in SimGrid repository as explained above.
1661  
1662
1663
1664
1665 \subsubsection faq_simgrid_configuration_alternate_network Using alternative flow models
1666
1667 The default simgrid network model uses a max-min based approach as
1668 explained in the research report
1669 <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>.
1670 Other models have been proposed and implemented since then (see for example 
1671 <a href="http://mescal.imag.fr/membres/arnaud.legrand/articles/simutools09.pdf">Accuracy Study and Improvement of Network Simulation in the SimGrid Framework</a>)
1672 and can be activated at runtime. For example:
1673 \verbatim
1674 ./mycode platform.xml deployment.xml --cfg=workstation_model:compound --cfg=network_model:LV08 -cfg=cpu_model:Cas01
1675 \endverbatim
1676
1677 Possible models for the network are currently "Constant", "CM02",
1678 "LegrandVelho", "GTNets", Reno", "Reno2", "Vegas". Others will
1679 probably be added in the future and many of the previous ones are
1680 experimental and are likely to disappear without notice...
1681
1682 \subsection faq_tracing Tracing Simulations for Visualization
1683
1684 The trace visualization is widely used to observe and understand the behavior
1685 of parallel applications and distributed algorithms. Usually, this is done in a
1686 two-step fashion: the user instruments the application and the traces are
1687 analyzed after the end of the execution. The visualization itself can highlights
1688 unexpected behaviors, bottlenecks and sometimes can be used to correct
1689 distributed algorithms. The SimGrid team is currently instrumenting the library
1690 in order to let users trace their simulations and analyze them. This part of the
1691 user manual explains how the tracing-related features can be enabled and used
1692 during the development of simulators using the SimGrid library.
1693
1694 \subsubsection faq_tracing_howitworks How it works
1695
1696 For now, the SimGrid library is instrumented so users can trace the <b>platform
1697 utilization</b> using the MSG interface. This means that the tracing will
1698 register how much power is used for each host and how much bandwidth is used for
1699 each link of the platform. The idea with this type of tracing is to observe the
1700 overall view of resources utilization in the first place, especially the
1701 identification of bottlenecks, load-balancing among hosts, and so on.
1702
1703 The idea of the instrumentation is to classify the MSG tasks by category,
1704 and trace
1705 the platform utilization (hosts and links) for each of the categories. For that,
1706 the tracing interface enables the declaration of categories and a function to
1707 mark a task with a previously declared category. <em>The tasks that are not
1708 classified according to a category are not traced</em>.
1709
1710 \subsubsection faq_tracing_enabling Enabling using CMake
1711
1712 With the sources of SimGrid, it is possible to enable the tracing 
1713 using the parameter <b>-Dtracing=on</b> when the cmake is executed.
1714 The section \ref faq_tracing_functions describes all the functions available
1715 when this Cmake options is activated. These functions will have no effect
1716 if SimGrid is configured without this option (they are wiped-out by the
1717 C-preprocessor).
1718
1719 \verbatim
1720 $ cmake -Dtracing=on .
1721 $ make
1722 \endverbatim
1723
1724 \subsubsection faq_tracing_functions Tracing Functions
1725
1726 \subsubsubsection Mandatory Functions
1727
1728 \li <b>\c TRACE_start (const char *filename)</b>: This is the first function to
1729 be called. It receives a single argument as parameter that contains the name of
1730 the file that will hold the trace in the end of the simulation. It returns 0 if
1731 everything was properly initialized, 1 otherwise. All trace functions called
1732 before TRACE_start do nothing.
1733
1734 \li <b>\c TRACE_category (const char *category)</b>: This function should be used
1735 to define a user category. The category can be used to differentiate the tasks
1736 that are created during the simulation (for example, tasks from server1,
1737 server2, or request tasks, computation tasks, communication tasks).
1738 All resource utilization (host power and link bandwidth) will be
1739 classified according to the task category. Tasks that do not belong to a
1740 category are not traced.
1741
1742 \li <b>\c TRACE_msg_set_task_category (m_task_t task, const char *category)</b>:
1743 This function should be called after the creation of a task, to define the
1744 category of that task. The first parameter \c task must contain a task that was
1745 created with the function \c MSG_task_create. The second parameter
1746 \c category must contain a category that was previously defined by the function
1747 \c TRACE_category.
1748
1749 \li <b>\c TRACE_end ()</b>: This is the last function to be called. It closes
1750 the trace file and stops the tracing of the simulation. All tracing will be
1751 completely disabled after the calling this function. Although we recommend
1752 the use of this function somewhere in the end of program, it can be used
1753 anywhere in the code. This function returns 0 if everything is ok, 1 otherwise.
1754
1755 \subsubsubsection Optional Functions
1756
1757 \li <b>\c TRACE_host_variable_declare (const char *variable)</b>:
1758 Declare a user variable that will be associated to hosts. A variable can
1759 be used to trace user variables such as the number of tasks in a server,
1760 the number of clients in an application, and so on.
1761
1762 \li <b>\c TRACE_host_variable_[set|add|sub] (const char *variable, double
1763 value)</b>:
1764 Set the value of a given user variable. It is important to remind that
1765 the value of this variable is always associated to the host. The host
1766 that will be used when these functions are called is the one returned by
1767 the function \c MSG_host_self().
1768
1769 \subsubsection faq_tracing_example Example of Instrumentation
1770
1771 A simplified example using the tracing mandatory functions.
1772
1773 \verbatim
1774 int main (int argc, char **argv)
1775 {
1776   TRACE_start ("traced_simulation.trace");
1777   TRACE_category ("request");
1778   TRACE_category ("computation");
1779   TRACE_category ("finalize");
1780   
1781   MSG_global_init (&argc, &argv);
1782
1783   //(... after deployment ...)
1784
1785   m_task_t req1 = MSG_task_create("1st_request_task", 10, 10, NULL);
1786   m_task_t req2 = MSG_task_create("2nd_request_task", 10, 10, NULL);
1787   m_task_t req3 = MSG_task_create("3rd_request_task", 10, 10, NULL);
1788   m_task_t req4 = MSG_task_create("4th_request_task", 10, 10, NULL);
1789   TRACE_msg_set_task_category (req1, "request");
1790   TRACE_msg_set_task_category (req2, "request");
1791   TRACE_msg_set_task_category (req3, "request");
1792   TRACE_msg_set_task_category (req4, "request");
1793
1794   m_task_t comp = MSG_task_create ("comp_task", 100, 100, NULL);
1795   TRACE_msg_set_task_category (comp, "computation");
1796
1797   m_task_t finalize = MSG_task_create ("finalize", 0, 0, NULL);
1798   TRACE_msg_set_task_category (finalize, "finalize");
1799
1800   //(...)
1801
1802   MSG_clean();
1803  
1804   TRACE_end();
1805   return 0;
1806 }
1807 \endverbatim
1808
1809 \subsubsection faq_tracing_analyzing Analyzing the SimGrid Traces
1810
1811 The SimGrid library, during an instrumented simulation, creates a trace file in
1812 the Paje file format that contains the platform utilization for the simulation
1813 that was executed. The visualization analysis of this file is performed with the
1814 visualization tool <a href="http://triva.gforge.inria.fr">Triva</a>, with
1815 special configurations tunned to SimGrid needs. This part of the documentation
1816 explains how to configure and use Triva to analyse a SimGrid trace file.
1817
1818 - <b>Installing Triva</b>: the tool is available in the INRIAGforge, 
1819 at <a href="http://triva.gforge.inria.fr">http://triva.gforge.inria.fr</a>.
1820 Use the following command to get the sources, and then check the file
1821 <i>INSTALL.simplified</i>. This file contains instructions to install
1822 the tool's dependencies in a Ubuntu/Debian Linux.
1823 \verbatim
1824 $ svn checkout svn://scm.gforge.inria.fr/svn/triva
1825 $ cd triva
1826 $ cat INSTALL.simplified
1827 \endverbatim
1828
1829 - <b>Executing Triva</b>: a binary called <i>Triva</i> is available after the
1830   installation (you can execute it passing <em>--help</em> to check its
1831 options). If the triva binary is not available after following the
1832 installation instructions, you may want to execute the following command to
1833 initialize the GNUstep environment variables (note that the location of the
1834 <i>GNUstep.sh</i> file may vary depending on your GNUstep installation - the
1835 command is known to work in Ubuntu and Debian Linux):
1836 \verbatim
1837 $ source /usr/share/GNUstep/Makefiles/GNUstep.sh
1838 \endverbatim
1839 You should be able to see this output after the installation of triva:
1840 \verbatim
1841 $ ./Triva.app/Triva --help
1842 Usage: Triva [OPTION...] TRACEFILE
1843 Trace Analysis through Visualization
1844
1845  You need to use one of the following options:
1846   -g, --graph                Graph Analysis
1847   -t, --treemap              Treemap Analysis
1848
1849  Other auxiliary options to check the trace file:
1850   -c, --check                Check the integrity of trace file
1851   -h, --hierarchy            Export the trace type hierarchy
1852   -l, --list                 List entity types
1853
1854   -?, --help                 Give this help list
1855       --usage                Give a short usage message
1856 \endverbatim
1857 Triva expects that the user choose one of the available options 
1858 (currently <em>--graph</em> or <em>--treemap</em> for a visualization analysis)
1859 and the trace file from the simulation.
1860
1861 - <b>Understanding Triva - time-slice</b>: the analysis of a trace file using
1862   the tool always takes into account the concept of the <em>time-slice</em>.
1863 This concept means that what is being visualized in the screen is always
1864 calculated considering a specific time frame, with its beggining and end
1865 timestamp. The time-slice is configured by the user and can be changed
1866 dynamically through the window called <em>Time Interval</em> that is opened
1867 whenever a trace file is being analyzed. The next figure depicts the time-slice
1868 configuration window.
1869 In the top of the window, in the space named <i>Trace Time</i>,
1870 the two fields show the beggining of the trace (which usually starts in 0) and
1871 the end (that depends on the time simulated by SimGrid). The middle of the
1872 window, in the square named <i>Time Slice Configuration</i>, contains the
1873 aspects related to the time-slice, including its <i>start</i> and its
1874 <i>size</i>. The gray rectangle in the bottom of this part indicates the 
1875 <i>current time-slice</i> that is considered for the drawings. If the checkbox 
1876 <i>Update Drawings on Sliders Change</i> is not selected, the button
1877 <i>Apply</i> must be clicked in order to inform triva that the
1878 new time-slice must be considered. The bottom part of the window, in the space
1879 indicated by the square <i>Time Slice Animation</i> can be used to advance
1880 the time-frame automatically. The user configures the amount of time that the
1881 time-frame will forward and how frequent this update will happen. Once this is
1882 configured, the user clicks the <i>Play</i> button in order to see the dynamic
1883 changes on the drawings.
1884 <center>
1885 \htmlonly
1886 <a href="triva-time_interval.png" border=0><img src="triva-time_interval.png" width="50%" border=0></a>
1887 \endhtmlonly
1888 </center>
1889 <b>Remarks:</b> when the trace has too many hosts or links, the computation to
1890 take into account a new time-slice can be expensive. When this happens, the
1891 <i>Frequency</i> parameter, but also updates caused by change on configurations
1892 when the checkbox <i>Update Drawings on Sliders
1893 Change</i> is selected will not be followed.
1894
1895 - <b>Understanding Triva - graph</b>: this part of the documention explains how
1896   to analyze the traces using the graph view of Triva, when the user executes
1897 the tool passing <em>--graph</em> as parameter. Triva opens three windows when
1898 this parameter is used: the <i>Time Interval</i> window (previously described),
1899 the <i>Graph Representation</i> window, and the <em>Graph Configuration</em>
1900 window. The Graph Representation is the window where drawings take place.
1901 Initially, it is completely white waiting for a proper graph configuration input
1902 by the user. We start the description of this type of analysis by describing the
1903 <i>Graph Configuration</i> window (depicted below). By using a particular
1904 configuration, triva
1905 can be used to customize the graph drawing according to
1906 the SimGrid trace that was created with user-specific categories. Before delving
1907 into the details of this customization, let us first explain the major parts of
1908 the graph configuration window. The buttons located in the top-right corner can
1909 be used to delete, copy and create a new configuration. The checkbox in the
1910 top-middle part of the window indicates if the configuration typed in the
1911 textfield is syntactically correct (we are using the non-XML 
1912 <a href="http://en.wikipedia.org/wiki/Property_list">Property List Format</a> to
1913 describe the configuration). The pop-up button located on the top-left corner 
1914 indicates the selected configuration (the user can have multiple graph
1915 configurations). The bottom-left text field contains the name of the current
1916 configuration (updates on this field must be followed by typing enter on the
1917 keyboard to take into account the name change). The bottom-right <em>Apply</em>
1918 button activates the current configuration, resulting on an update on the graph
1919 drawings.
1920 <center>
1921 \htmlonly
1922 <a href="triva-graph_configuration.png" border=0><img src="triva-graph_configuration.png" width="50%" border=0></a>
1923 \endhtmlonly
1924 </center>
1925 <b>Basic SimGrid Configuration</b>: The figure shows in the big textfield the
1926 basic configuration that should be used during the analysis of a SimGrid trace
1927 file. The basic logic of the configuration is as follows:
1928 \verbatim
1929 {
1930   node = (HOST);
1931   edge = (LINK);
1932 \endverbatim
1933 The nodes of the graph will be created based on the <i>node</i> parameter, which
1934 in this case is the different <em>"HOST"</em>s of the platform 
1935 used to simulate. The <i>edge</i> parameter indicates that the edges of the
1936 graph will be created based on the <em>"LINK"</em>s of the platform. After the
1937 definition of these two parameters, the configuration must detail how
1938 <em>HOST</em>s and <em>LINK</em>s should be drawn. For that, the configuration
1939 must have an entry for each of the types used. For <em>HOST</em>, as basic
1940 configuration, we have:
1941 \verbatim
1942   HOST = {
1943     size = power;
1944     scale = global;
1945   };
1946 \endverbatim
1947 The parameter <em>size</em> indicates which variable from the trace file will be
1948 used to define the size of the node HOST in the visualization. If the simulation
1949 was executed with availability traces, the size of the nodes will be changed
1950 according to these traces. The parameter <em>scale</em> indicates if the value
1951 of the variable is <em>global</em> or <em>local</em>. If it is global, the value
1952 will be relative to the power of all other hosts, if it is local, the value will
1953 be relative locally.
1954 For <em>LINK</em> we have:
1955 \verbatim
1956   LINK = {
1957     src = SrcHost;
1958     dst = DstHost;
1959     
1960     size = bandwidth;
1961     scale = global;
1962   };
1963 \endverbatim
1964 For the types specified in the <em>edge</em> parameter (such as <em>LINK</em>),
1965 the configuration must contain two additional parameters: <em>src</em> and
1966 <em>dst</em> that are used to properly identify which nodes this edge is
1967 connecting. The values <em>SrcHost</em> and <em>DstHost</em> are always present
1968 in the SimGrid trace file and should not be changed in the configuration. The
1969 parameter <em>size</em> for the LINK, in this case, is configured as the
1970 variable <em>bandwidth</em>, with a <em>global</em> scale. The scale meaning
1971 here is exactly the same used for nodes. The last parameter is the GraphViz
1972 algorithm used to calculate the position of the nodes in the graph
1973 representation.
1974 \verbatim
1975   graphviz-algorithm = neato;
1976 }
1977 \endverbatim
1978 <b>Customizing the Graph Representation</b>: triva is capable to handle
1979 a customized graph representation based on the variables present in the trace
1980 file. In the case of SimGrid, every time a category is created for tasks, two
1981 variables in the trace file are defined: one to indicate node utilization (how
1982 much power was used by that task category), and another to indicate link
1983 utilization (how much bandwidth was used by that category). For instance, if the
1984 user declares a category named <i>request</i>, there will be variables named
1985 <b>p</b><i>request</i> and a <b>b</b><i>request</i> (<b>p</b> for power and
1986 <b>b</b> for bandwidth). It is important to notice that the variable
1987 <i>prequest</i> in this case is only available for HOST, and
1988 <i>brequest</i> is only available for LINK. <b>Example</b>: suppose there are
1989 two categories for tasks: request and compute. To create a customized graph
1990 representation with a proportional separation of host and link utilization, use
1991 as configuration for HOST and LINK this:
1992 \verbatim
1993   HOST = {
1994     size = power;
1995     scale = global;
1996   
1997     sep_host = {
1998       type = separation;
1999       size = power;
2000       values = (prequest, pcomputation);
2001     };
2002   };
2003
2004   LINK = {
2005     src = SrcHost;
2006     dst = DstHost;
2007     size = bandwidth;
2008     scale = global;
2009
2010     sep_link = {
2011       type = separation;
2012       size = bandwidth;
2013       values = (brequest, bcomputation);
2014     };
2015   };
2016 \endverbatim
2017 Where <i>sep_host</i> contains a composition of type <i>separation</i> where
2018 its max size is the <i>power</i> of the host and the variables <i>prequest</i>
2019 and <i>pcomputation</i> are drawn proportionally to the size of the HOST. And
2020 <i>sep_link</i> is also a separation where max is defined as the
2021 <i>bandwidth</i> of the link, and the variables <i>brequest</i> and
2022 <i>bcomputation</i> are drawn proportionally within a LINK.
2023 <i>This configuration enables the analysis of resource utilization by MSG tasks,
2024 and the identification of load-balancing issues, network bottlenecks, for
2025 instance.</i> \n
2026 <b>Other compositions</b>: besides <i>separation</i>, it is possible to use
2027 other types of compositions, such as gradients, and colors, like this:
2028 \verbatim
2029     gra_host = {
2030       type = gradient;
2031       scale = global;
2032       values = (numberOfTasks);
2033     };
2034     color_host = {
2035       type = color;
2036       values = (is_server);
2037     };
2038 \endverbatim
2039 Where <i>gra_host</i> creates a gradient within a node of the graph, using a
2040 global scale and using as value a variable called <i>numberOfTasks</i>, that
2041 could be declared by the user using the optional tracing functions of SimGrid.
2042 If scale is global, the max and min value for the gradient will be equal to the
2043 max and min numberOfTasks among all hosts, and if scale is local, the max and
2044 min value based on the value of numberOfTasks locally in each host.
2045 And <i>color_host</i> composition draws a square based on a positive value of
2046 the variable <i>is_server</i>, that could also be defined by the user using the
2047 SimGrid tracing functions. \n
2048 <b>The Graph Visualization</b>: The next figure shows a graph visualization of a
2049 given time-slice of the masterslave_forwarder example (present in the SimGrid
2050 sources). The red color indicates tasks from the <i>compute</i> category. This
2051 visualization was generated with the following configuration:
2052 \verbatim
2053 {
2054   node = (HOST);
2055   edge = (LINK);
2056
2057   HOST = {
2058     size = power;
2059     scale = global;
2060   
2061     sep_host = {
2062       type = separation;
2063       size = power;
2064       values = (pcompute, pfinalize);
2065     };
2066   };
2067   LINK = {
2068     src = SrcHost;
2069     dst = DstHost;
2070     size = bandwidth;
2071     scale = global;
2072
2073     sep_link = {
2074       type = separation;
2075       size = bandwidth;
2076       values = (bcompute, bfinalize);
2077     };
2078   };
2079   graphviz-algorithm = neato;
2080 }
2081 \endverbatim
2082 <center>
2083 \htmlonly
2084 <a href="triva-graph_visualization.png" border=0><img src="triva-graph_visualization.png" width="50%" border=0></a>
2085 \endhtmlonly
2086 </center>
2087
2088 - <b>Understading Triva - colors</b>: An important issue when using Triva is how
2089   to define colors. To do that, we have to know which variables are defined in
2090 the trace file generated by the SimGrid library. The parameter <em>--list</em> 
2091 lists the variables for a given trace file:
2092 \verbatim
2093 $ Triva -l masterslave_forwarder.trace
2094 iFile
2095 c  platform
2096 c    HOST
2097 v     power
2098 v     is_slave
2099 v     is_master
2100 v     task_creation
2101 v     task_computation
2102 v     pcompute
2103 v     pfinalize
2104 c    LINK
2105 v     bandwidth
2106 v     latency
2107 v     bcompute
2108 v     bfinalize
2109 c  user_type
2110 \endverbatim
2111 We can see that HOST has seven variables (from power to pfinalize) and LINK has
2112 four (from bandwidth to bfinalize). To define a red color for the
2113 <i>pcompute</i> and <i>bcompute</i> (which are defined based on user category
2114 <i>compute</i>), execute:
2115 \verbatim
2116 $ defaults write Triva 'pcompute Color' '1 0 0'
2117 $ defaults write Triva 'bcompute Color' '1 0 0'
2118 \endverbatim
2119 Where the three numbers in each line are the RGB color with values from 0 to 1.
2120
2121 \section faq_troubleshooting Troubleshooting
2122
2123 \subsection faq_trouble_lib_compil SimGrid compilation and installation problems
2124
2125 \subsubsection faq_trouble_lib_config ./configure fails!
2126
2127 We know only one reason for the configure to fail:
2128
2129  - <b>You are using a broken build environment</b>\n
2130    If symptom is that configure complains about gcc not being able to build
2131    executables, you are probably missing the libc6-dev package. Damn Ubuntu.
2132
2133 If you experience other kind of issue, please get in touch with us. We are
2134 always interested in improving our portability to new systems.
2135
2136 \subsubsection faq_trouble_distcheck Dude! "make check" fails on my machine!
2137
2138 Don't assume we never run this target, because we do. Check
2139 http://bob.loria.fr:8010 if you don't believe us.
2140
2141 There is several reasons which may cause the make check to fail on your
2142 machine:
2143
2144  - <b>You are using a broken libc (probably concerning the contextes)</b>.\n
2145    The symptom is that the "make check" fails within the examples/msg directory.\n
2146    By default, SimGrid uses something called ucontexts. This is part of the
2147    libc, but it's quite undertested. For example, some (old) versions of the
2148    glibc on alpha do not implement these functions, but provide the stubs
2149    (which return ENOSYS: not implemented). It may fool our detection mechanism
2150    and leads to segfaults. There is not much we can do to fix the bug.
2151    A workaround is to compile with --with-context=pthread to avoid
2152    ucontext completely. You'll be a bit more limited in the number
2153    of simulated processes you can start concurrently, but 5000
2154    processes is still enough for most purposes, isn't it?\n
2155    This limitation is the reason why we insist on using this piece of ...
2156    software even if it's so troublesome.\n
2157    <b>=> use --with-pthread on AMD64 architecture that do not have an 
2158    ultra-recent libc.</b>
2159    
2160  - <b>There is a bug in SimGrid we aren't aware of</b>.\n
2161    If none of the above apply, please drop us a mail on the mailing list so
2162    that we can check it out. Make sure to read \ref faq_bugrepport
2163    before you do so.
2164
2165 \subsection faq_trouble_compil User code compilation problems
2166
2167 \subsubsection faq_trouble_err_logcat "gcc: _simgrid_this_log_category_does_not_exist__??? undeclared (first use in this function)"
2168
2169 This is because you are using the log mecanism, but you didn't created
2170 any default category in this file. You should refer to \ref XBT_log
2171 for all the details, but you simply forgot to call one of
2172 XBT_LOG_NEW_DEFAULT_CATEGORY() or XBT_LOG_NEW_DEFAULT_SUBCATEGORY().
2173
2174 \subsubsection faq_trouble_pthreadstatic "gcc: undefined reference to pthread_key_create"
2175
2176 This indicates that one of the library SimGrid depends on (libpthread
2177 here) was missing on the linking command line. Dependencies of
2178 libsimgrid are expressed directly in the dynamic library, so it's
2179 quite impossible that you see this message when doing dynamic linking. 
2180
2181 If you compile your code statically (and if you use a pthread version
2182 of SimGrid -- see \ref faq_more_processes), you must absolutely
2183 specify <tt>-lpthread</tt> on the linker command line. As usual, this should
2184 come after <tt>-lsimgrid</tt> on this command line.
2185
2186 \subsection faq_trouble_errors Runtime error messages
2187
2188 \subsubsection faq_flexml_limit "surf_parse_lex: Assertion `next limit' failed."
2189
2190 This is because your platform file is too big for the parser. 
2191
2192 Actually, the message comes directly from FleXML, the technology on top of
2193 which the parser is built. FleXML has the bad idea of fetching the whole
2194 document in memory before parsing it. And moreover, the memory buffer size
2195 must be determined at compilation time.
2196
2197 We use a value which seems big enough for our need without bloating the
2198 simulators footprints. But of course your mileage may vary. In this case,
2199 just edit src/surf/surfxml.l modify the definition of
2200 FLEXML_BUFFERSTACKSIZE. E.g.
2201
2202 \verbatim
2203 #define FLEXML_BUFFERSTACKSIZE 1000000000
2204 \endverbatim
2205
2206 Then recompile and everything should be fine, provided that your version of
2207 Flex is recent enough (>= 2.5.31). If not the compilation process should
2208 warn you.
2209
2210 A while ago, we worked on FleXML to reduce a bit its memory consumption, but
2211 these issues remain. There is two things we should do:
2212
2213   - use a dynamic buffer instead of a static one so that the only limit
2214     becomes your memory, not a stupid constant fixed at compilation time
2215     (maybe not so difficult).
2216   - change the parser so that it does not need to get the whole file in
2217     memory before parsing
2218     (seems quite difficult, but I'm a complete newbe wrt flex stuff).
2219
2220 These are changes to FleXML itself, not SimGrid. But since we kinda hijacked
2221 the development of FleXML, I can grant you that any patches would be really
2222 welcome and quickly integrated.
2223
2224 <b>Update:</b> A new version of FleXML (1.7) was released. Most of the work
2225 was done by William Dowling, who use it in his own work. The good point is
2226 that it now use a dynamic buffer, and that the memory usage was greatly
2227 improved. The downside is that William also changed some things internally,
2228 and it breaks the hack we devised to bypass the parser, as explained in 
2229 \ref faq_flexml_bypassing. Indeed, this is not a classical usage of the
2230 parser, and Will didn't imagine that we may have used (and even documented)
2231 such a crude usage of FleXML. So, we now have to repair the bypassing
2232 functionality to use the lastest FleXML version and fix the memory usage in
2233 SimGrid.
2234
2235 \subsubsection faq_trouble_gras_transport GRAS spits networking error messages
2236
2237 Gras, on real platforms, naturally use regular sockets to communicate. They
2238 are deeply hidden in the gras abstraction, but when things go wrong, you may
2239 get some weird error messages. Here are some example, with the probable
2240 reason:
2241
2242  - <b>Transport endpoint is not connected</b>: several processes try to open
2243    a server socket on the same port number of the same machine. This is
2244    naturally bad and each process should pick its own port number for this.\n
2245    Maybe, you just have some processes remaining from a previous experiment 
2246    on your machine.\n
2247    Killing them may help, but again if you kill -KILL them, you'll have to
2248    wait for a while: they didn't close there sockets properly and the system
2249    needs a while to notice that this port is free again.
2250
2251  - <b>Socket closed by remote side</b>: if the remote process is not
2252    supposed to close the socket at this point, it may be dead.
2253    
2254  - <b>Connection reset by peer</b>: I found this on Internet about this
2255    error. I think it's what's happening here, too:\n   
2256    <i>This basically means that a network error occurred while the client was
2257    receiving data from the server. But what is really happening is that the
2258    server actually accepts the connection, processes the request, and sends
2259    a reply to the client. However, when the server closes the socket, the
2260    client believes that the connection has been terminated abnormally
2261    because the socket implementation sends a TCP reset segment telling the
2262    client to throw away the data and report an error.\n
2263    Sometimes, this problem is caused by not properly closing the
2264    input/output streams and the socket connection. Make sure you close the
2265    input/output streams and socket connection properly. If everything is
2266    closed properly, however, and the problem persists, you can work around
2267    it by adding a one-second sleep before closing the streams and the
2268    socket. This technique, however, is not reliable and may not work on all
2269    systems.</i>\n
2270    Since GRAS sockets are closed properly (repeat after me: there is no bug
2271    in GRAS), it is either that you are closing your sockets on server side
2272    before the client get a chance to read them (use gras_os_sleep() to delay
2273    the server), or the server died awfully before the client got the data.
2274
2275 \subsubsection faq_trouble_errors_big_fat_warning I'm told that my XML files are too old.
2276
2277 The format of the XML platform description files is sometimes
2278 improved. For example, we decided to change the units used in SimGrid
2279 from MBytes, MFlops and seconds to Bytes, Flops and seconds to ease
2280 people exchanging small messages. We also reworked the route
2281 descriptions to allow more compact descriptions.
2282
2283 That is why the XML files are versionned using the 'version' attribute
2284 of the root tag. Currently, it should read:
2285 \verbatim
2286   <platform version="2">
2287 \endverbatim
2288
2289 If your files are too old, you can use the simgrid_update_xml.pl
2290 script which can be found in the tools directory of the archive.
2291
2292 \subsection faq_trouble_valgrind Valgrind-related and other debugger issues
2293
2294 If you don't, you really should use valgrind to debug your code, it's
2295 almost magic.
2296
2297 \subsubsection faq_trouble_vg_longjmp longjmp madness in valgrind
2298
2299 This is when valgrind starts complaining about longjmp things, just like:
2300
2301 \verbatim ==21434== Conditional jump or move depends on uninitialised value(s)
2302 ==21434==    at 0x420DBE5: longjmp (longjmp.c:33)
2303 ==21434==
2304 ==21434== Use of uninitialised value of size 4
2305 ==21434==    at 0x420DC3A: __longjmp (__longjmp.S:48)
2306 \endverbatim
2307
2308 This is the sign that you didn't used the exception mecanism well. Most
2309 probably, you have a <tt>return;</tt> somewhere within a <tt>TRY{}</tt>
2310 block. This is <b>evil</b>, and you must not do this. Did you read the section
2311 about \ref XBT_ex??
2312
2313 \subsubsection faq_trouble_vg_libc Valgrind spits tons of errors about backtraces!
2314
2315 It may happen that valgrind, the memory debugger beloved by any decent C
2316 programmer, spits tons of warnings like the following :
2317 \verbatim ==8414== Conditional jump or move depends on uninitialised value(s)
2318 ==8414==    at 0x400882D: (within /lib/ld-2.3.6.so)
2319 ==8414==    by 0x414EDE9: (within /lib/tls/i686/cmov/libc-2.3.6.so)
2320 ==8414==    by 0x400B105: (within /lib/ld-2.3.6.so)
2321 ==8414==    by 0x414F937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
2322 ==8414==    by 0x4150F4C: (within /lib/tls/i686/cmov/libc-2.3.6.so)
2323 ==8414==    by 0x400B105: (within /lib/ld-2.3.6.so)
2324 ==8414==    by 0x415102D: __libc_dlopen_mode (in /lib/tls/i686/cmov/libc-2.3.6.so)
2325 ==8414==    by 0x412D6B9: backtrace (in /lib/tls/i686/cmov/libc-2.3.6.so)
2326 ==8414==    by 0x8076446: xbt_dictelm_get_ext (dict_elm.c:714)
2327 ==8414==    by 0x80764C1: xbt_dictelm_get (dict_elm.c:732)
2328 ==8414==    by 0x8079010: xbt_cfg_register (config.c:208)
2329 ==8414==    by 0x806821B: MSG_config (msg_config.c:42)
2330 \endverbatim
2331
2332 This problem is somewhere in the libc when using the backtraces and there is
2333 very few things we can do ourselves to fix it. Instead, here is how to tell
2334 valgrind to ignore the error. Add the following to your ~/.valgrind.supp (or
2335 create this file on need). Make sure to change the obj line according to
2336 your personnal mileage (change 2.3.6 to the actual version you are using,
2337 which you can retrieve with a simple "ls /lib/ld*.so").
2338
2339 \verbatim {
2340    name: Backtrace madness
2341    Memcheck:Cond
2342    obj:/lib/ld-2.3.6.so
2343    fun:dl_open_worker
2344    fun:_dl_open
2345    fun:do_dlopen
2346    fun:dlerror_run
2347    fun:__libc_dlopen_mode
2348 }\endverbatim
2349
2350 Then, you have to specify valgrind to use this suppression file by passing
2351 the <tt>--suppressions=$HOME/.valgrind.supp</tt> option on the command line.
2352 You can also add the following to your ~/.bashrc so that it gets passed
2353 automatically. Actually, it passes a bit more options to valgrind, and this
2354 happen to be my personnal settings. Check the valgrind documentation for
2355 more information.
2356
2357 \verbatim export VALGRIND_OPTS="--leak-check=yes --leak-resolution=high --num-callers=40 --tool=memcheck --suppressions=$HOME/.valgrind.supp" \endverbatim
2358
2359 \subsubsection faq_trouble_backtraces Truncated backtraces
2360
2361 When debugging SimGrid, it's easier to pass the
2362 --disable-compiler-optimization flag to the configure if valgrind or
2363 gdb get fooled by the optimization done by the compiler. But you
2364 should remove these flag when everything works before going in
2365 production (before launching your 1252135 experiments), or everything
2366 will run only one half of the true SimGrid potential.
2367
2368 \subsection faq_deadlock There is a deadlock in my code!!!
2369
2370 Unfortunately, we cannot debug every code written in SimGrid.  We
2371 furthermore believe that the framework provides ways enough
2372 information to debug such informations yourself. If the textual output
2373 is not enough, Make sure to check the \ref faq_visualization FAQ entry to see
2374 how to get a graphical one.
2375
2376 Now, if you come up with a really simple example that deadlocks and
2377 you're absolutely convinced that it should not, you can ask on the
2378 list. Just be aware that you'll be severely punished if the mistake is
2379 on your side... We have plenty of FAQ entries to redact and new
2380 features to implement for the impenitents! ;)
2381
2382 \subsection faq_surf_network_latency I get weird timings when I play with the latencies.
2383
2384 OK, first of all, remember that units should be Bytes, Flops and
2385 Seconds. If you don't use such units, some SimGrid constants (e.g. the
2386 SG_TCP_CTE_GAMMA constant used in most network models) won't have the
2387 right unit and you'll end up with weird results.
2388
2389 Here is what happens with a single transfer of size L on a link
2390 (bw,lat) when nothing else happens.
2391
2392 \verbatim
2393 0-----lat--------------------------------------------------t
2394 |-----|**** real_bw =min(bw,SG_TCP_CTE_GAMMA/(2*lat)) *****|
2395 \endverbatim
2396
2397 In more complex situations, this min is the solution of a complex
2398 max-min linear system.  Have a look 
2399 <a href="http://lists.gforge.inria.fr/pipermail/simgrid-devel/2006-April/thread.html">here</a>
2400 and read the two threads "Bug in SURF?" and "Surf bug not
2401 fixed?". You'll have a few other examples of such computations. You
2402 can also read "A Network Model for Simulation of Grid Application" by
2403 Henri Casanova and Loris Marchal to have all the details. The fact
2404 that the real_bw is smaller than bw is easy to understand. The fact
2405 that real_bw is smaller than SG_TCP_CTE_GAMMA/(2*lat) is due to the
2406 window-based congestion mechanism of TCP. With TCP, you can't exploit
2407 your huge network capacity if you don't have a good round-trip-time
2408 because of the acks...
2409
2410 Anyway, what you get is t=lat + L/min(bw,SG_TCP_CTE_GAMMA/(2*lat)).
2411
2412   * if I you set (bw,lat)=(100 000 000, 0.00001), you get t =  1.00001 (you fully
2413 use your link)
2414   * if I you set (bw,lat)=(100 000 000, 0.0001),  you get t =  1.0001 (you're on the
2415 limit)
2416   * if I you set (bw,lat)=(100 000 000, 0.001),   you get t = 10.001  (ouch!)
2417
2418 This bound on the effective bandwidth of a flow is not the only thing
2419 that may make your result be unexpected. For example, two flows
2420 competing on a saturated link receive an amount of bandwidth inversely
2421 proportional to their round trip time.
2422
2423 \subsection faq_bugrepport So I've found a bug in SimGrid. How to report it?
2424
2425 We do our best to make sure to hammer away any bugs of SimGrid, but this is
2426 still an academic project so please be patient if/when you find bugs in it.
2427 If you do, the best solution is to drop an email either on the simgrid-user
2428 or the simgrid-devel mailing list and explain us about the issue.  You can
2429 also decide to open a formal bug report using the
2430 <a href="https://gforge.inria.fr/tracker/?atid=165&group_id=12&func=browse">relevant
2431 interface</a>. You need to login on the server to get the ability to submit
2432 bugs. 
2433
2434 We will do our best to solve any problem repported, but you need to help us
2435 finding the issue. Just telling "it segfault" isn't enough. Telling "It
2436 segfaults when running the attached simulator" doesn't really help either.
2437 You may find the following article interesting to see how to repport
2438 informative bug repports:
2439 http://www.chiark.greenend.org.uk/~sgtatham/bugs.html (it is not SimGrid
2440 specific at all, but it's full of good advices).
2441
2442 \author Arnaud Legrand (arnaud.legrand::imag.fr)
2443 \author Martin Quinson (martin.quinson::loria.fr)
2444
2445
2446 */
2447
2448 ******************************************************************
2449 *              OLD CRUFT NOT USED ANYMORE                        *
2450 ******************************************************************
2451
2452
2453 \subsection faq_crosscompile Cross-compiling a Windows DLL of SimGrid from linux
2454
2455 At the moment, we do not distribute Windows pre-compiled version of SimGrid
2456 because the support for this platform is still experimental. We know that
2457 some parts of the GRAS environment do not work, and we think that the others
2458 environments (MSG and SD) have good chances to work, but we didn't test
2459 ourselves. This section explains how we generate the SimGrid DLL so that you
2460 can build it for yourself. First of all, you need to have a version more
2461 recent than 3.1 (ie, a SVN version as time of writting).
2462
2463 In order to cross-compile the package to windows from linux, you need to
2464 install mingw32 (minimalist gnu win32). On Debian, you can do so by
2465 installing the packages mingw32 (compiler), mingw32-binutils (linker and
2466 so), mingw32-runtime.
2467
2468 You can use the VPATH support of configure to compile at the same time for
2469 linux and windows without dupplicating the source nor cleaning the tree
2470 between each. Just run bootstrap (if you use the SVN) to run the autotools.
2471 Then, create a linux and a win directories. Then, type:
2472 \verbatim  cd linux; ../configure --srcdir=.. <usual configure flags>; make; cd ..
2473 cd win;  ../configure --srcdir=.. --host=i586-mingw32msvc <flags>; make; cd ..
2474 \endverbatim
2475 The trick to VPATH builds is to call configure from another directory,
2476 passing it an extra --srcdir argument to tell it where all the sources are.
2477 It will understand you want to use VPATH. Then, the trick to cross-compile
2478 is simply to add a --host argument specifying the target you want to build
2479 for. The i586-mingw32msvc string is what you have to pass to use the mingw32
2480 environment as distributed in Debian.
2481
2482 After that, you can run all make targets from both directories, and test
2483 easily that what you change for one arch does not break the other one. 
2484
2485 It is possible that this VPATH build thing breaks from time to time in the
2486 SVN since it's quite fragile, but it's granted to work in any released
2487 version. If you experience problems, drop us a mail. 
2488
2489 Another possible source of issue is that at the moment, building the
2490 examples request to use the gras_stub_generator tool, which is a compiled
2491 program, not a script. In cross-compilation, you need to cross-execute with
2492 wine for example, which is not really pleasant. We are working on this, but
2493 in the meanwhile, simply don't build the examples in cross-compilation
2494 (<tt>cd src</tt> before running make).
2495     
2496 Program (cross-)compiled with mingw32 do request an extra DLL at run-time to be
2497 usable. For example, if you want to test your build with wine, you should do
2498 the following to put this library where wine looks for DLLs.
2499 \verbatim 
2500 cp /usr/share/doc/mingw32-runtime/mingwm10.dll.gz ~/.wine/c/windows/system/
2501 gunzip ~/.wine/c/windows/system/mingwm10.dll.gz
2502 \endverbatim
2503
2504 The DLL is built in src/.libs, and installed in the <i>prefix</i>/bin directory
2505 when you run make install. 
2506
2507 If you want to use it in a native project on windows, you need to use 
2508 simgrid.dll and mingwm10.dll. For each DLL, you need to build .def file
2509 under linux (listing the defined symbols), and convert it into a .lib file
2510 under windows (specifying this in a way that windows compilers like). To
2511 generate the def files, run (under linux):
2512 \verbatim echo "LIBRARY libsimgrid-0.dll" > simgrid.def
2513 echo EXPORTS >> simgrid.def
2514 nm libsimgrid-0.dll | grep ' T _' | sed 's/.* T _//' >> simgrid.def
2515 nm libsimgrid-0.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> simgrid.def
2516
2517 echo "LIBRARY mingwm10.dll" > mingwm10.def
2518 echo EXPORTS >> mingwm10.def
2519 nm mingwm10.dll | grep ' T _' | sed 's/.* T _//' >> mingwm10.def
2520 nm mingwm10.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> mingwm10.def
2521 \endverbatim
2522
2523 To create the import .lib files, use the <tt>lib</tt> windows tool (from
2524 MSVC) the following way to produce simgrid.lib and mingwm10.lib
2525 \verbatim lib /def:simgrid.def
2526 lib /def:mingwm10.def
2527 \endverbatim
2528
2529 If you happen to use Borland C Builder, the right command line is the
2530 following (note that you don't need any file.def to get this working).
2531 \verbatim implib simgrid.lib libsimgrid-0.dll
2532 implib mingwm10.lib mingwm10.dll
2533 \endverbatim
2534
2535 Then, set the following parameters in Visual C++ 2005:
2536 Linker -> Input -> Additional dependencies = simgrid.lib mingwm10.lib
2537
2538 Just in case you wonder how to generate a DLL from libtool in another
2539 project, we added -no-undefined to any lib*_la_LDFLAGS variables so that
2540 libtool accepts to generate a dynamic library under windows. Then, to make
2541 it true, we pass any dependencies (such as -lws2 under windows or -lpthread
2542 on need) on the linking line. Passing such deps is a good idea anyway so
2543 that they get noted in the library itself, avoiding the users to know about
2544 our dependencies and put them manually on their compilation line. Then we
2545 added the AC_LIBTOOL_WIN32_DLL macro just before AC_PROG_LIBTOOL in the
2546 configure.ac. It means that we exported any symbols which need to be.
2547 Nowadays, functions get automatically exported, so we don't need to load our
2548 header files with tons of __declspec(dllexport) cruft. We only need to do so
2549 for data, but there is no public data in SimGrid so we are good.
2550