Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update doc for windows
[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/blog/2010/06/28/Tutorial_at_HPCS/">the slides of the HPCS'10 tutorial</a>
9 (or to these <a href="http://graal.ens-lyon.fr/~alegrand/articles/slides_g5k_simul.pdf">ancient
10 slides</a>, 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 section \ref faq_tracing.
76
77 \subsection faq_C Argh! Do I really have to code in C?
78
79 Up until now, there is no binding for other languages. If you use C++,
80 you should be able to use the SimGrid library as a standard C library
81 and everything should work fine (simply <i>link</i> against this
82 library; recompiling SimGrid with a C++ compiler won't work and it
83 wouldn't help if you could).
84
85 In fact, we are currently working on Java bindings of MSG to allow
86 all the undergrad students of the world to use this tool. This is a
87 little more tricky than I would have expected, but the work is moving
88 fast forward [2006/05/13]. More languages are evaluated, but for now,
89 we do not feel a real demand for any other language. Please speak up!
90
91 \section faq_cmake Installing the SimGrid library with Cmake (since V3.4)
92
93 \subsection faq_intro Some generalitty
94
95 \subsubsection faq_intro1 What is Cmake?
96
97 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>.
98
99 \subsubsection faq_intro2 Why cmake?
100
101 CMake permits to developers to compil projects on different plateforms. Then many tools are embedded like ctest for making test, a link to cdash for vizualise results but also test coverage and bug reports. 
102
103 \subsubsection faq_intro3 What cmake need?
104
105 CMake needs some prerequists like :
106
107 For Unix and MacOS:
108   \li make
109   \li perl and libpcre
110   \li c, c++ and java compiler regards to developers
111   \li ccmake for graphical used of CMake
112   \li cmake <a href="http://www.cmake.org/cmake/resources/software.html">(download page)</a>
113
114 For Windows :
115   \li cmake 2.8 <a href="http://www.cmake.org/cmake/resources/software.html">(download page)</a>
116   \li perl strawberry <a href="http://www.strawberryperl.com/download/5.12.2.0/strawberry-perl-5.12.2.0.msi">(download page)</a>
117   \li pcre-7.0 <a href="http://sourceforge.net/projects/gnuwin32/files/pcre/7.0/pcre-7.0.exe/download">(download page)</a>
118   \li git <a href="http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe">(download page)</a>
119   
120 \subsubsection faq_cmakeoption1 Liste of options
121
122 \verbatim
123 "cmake -D[name]=[value] ... ./"
124
125 [name]  enable_gtnets           [value] ON/OFF or TRUE/FALSE or 1/0
126         enable_lua                      ON/OFF or TRUE/FALSE or 1/0
127         enable_compile_optimizations    ON/OFF or TRUE/FALSE or 1/0
128         enable_compile_warnings         ON/OFF or TRUE/FALSE or 1/0
129         enable_smpi                     ON/OFF or TRUE/FALSE or 1/0
130         enable_maintainer_mode          ON/OFF or TRUE/FALSE or 1/0
131         enable_supernovae               ON/OFF or TRUE/FALSE or 1/0
132         enable_tracing                  ON/OFF or TRUE/FALSE or 1/0
133         enable_coverage                 ON/OFF or TRUE/FALSE or 1/0
134         enable_memcheck                 ON/OFF or TRUE/FALSE or 1/0
135         enable_model-checking           ON/OFF or TRUE/FALSE or 1/0
136         enable_debug                    ON/OFF or TRUE/FALSE or 1/0
137         enable_jedule                   ON/OFF or TRUE/FALSE or 1/0
138         enable_latency_bound_tracking   ON/OFF or TRUE/FALSE or 1/0
139         enable_lib_static               ON/OFF or TRUE/FALSE or 1/0
140         enable_pcre                     ON/OFF or TRUE/FALSE or 1/0
141         custom_flags                    <flags>
142         gtnets_path                     <path_to_gtnets_directory>
143         CMAKE_INSTALL_PREFIX            <path_to_install_directory>
144         pipol_user                      <pipol_username>
145 \endverbatim
146                                                                                                                                                           
147 \subsubsection faq_cmakeoption2 Options explaination
148
149   \li enable_gtnets : set to true implie that user wants to use gtnets.
150
151   \li enable_lua : set to true implie that user wants to add lua langage into simgrid compilation.
152
153   \li enable_compile_optimizations : add flags "-O3 -finline-functions -funroll-loops -fno-strict-aliasing"
154
155   \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"
156
157   \li enable_smpi : Set to true if you want to use smpi lib. Actually on simgrid v3.4.1 Mac doesn't support lib smpi.
158
159   \li enable_maintainer_mode : set to true it remakes some files. 
160
161   \li enable_supernovae : set to true make one file for each lib and compile with those generated files.
162
163   \li enable_tracing : To enable the generation of simulation traces for visualization.
164
165   \li enable_coverage : When set to true this option enable code coverage by setting -fprofile-arcs -ftest-coverage flags.
166
167   \li enable_memcheck : When set to true this option enable tests for memcheck.
168
169   \li enable_model-checking : Enable the model checking when set to true.
170
171   \li enable_debug : If enable_debug is set to 'off' Simgrid compil flag has '-DNDEBUG' option.
172   
173   \li enable_jedule : To enable jedule mode, which creates visualizations of task schedules with Simdag. 
174   
175   \li enable_latency_bound_tracking : Set to on if you want to be warned when communications are limited by round trip time.
176   
177   \li enable_lib_static : Enable generated Simgrid and smpi static libraries.
178   
179   \li enable_pcre : Use or not the pcre lib for memory optimization.    
180   
181   \li custom_flags : If user wants to use a specific flag during compilation, give here.
182
183   \li gtnets_path : Path to gtnets install directory (ex /usr)
184
185   \li CMAKE_INSTALL_PREFIX : Path where are installed lib/ doc/ and include/ directories (ex /usr/local)
186   
187   \li pipol_user : specify your pipol username if you want to use the pipol-remote command.
188
189 \subsubsection faq_cmakeoption3 Initialisation
190
191 Those options are initialized the first time you launch "cmake ." whithout specified option.
192
193 \verbatim
194 enable_gtnets                   on
195 enable_lua                      on
196 enable_smpi                     on
197 enable_supernovae               on
198 enable_tracing                  on
199 enable_compile_optimizations    on
200 enable_debug                    on
201 enable_pcre                     on
202 enable_compile_warnings         off
203 enable_maintainer_mode          off
204 enable_coverage                 off
205 enable_memcheck                 off
206 enable_model-checking           off
207 enable_jedule                   off
208 enable_latency_bound_tracking   off 
209 enable_lib_static               off
210 CMAKE_INSTALL_PREFIX            /usr/local
211 custom_flags                    null
212 gtnets_path                     null
213 pipol_user                      null
214 \endverbatim
215
216 \subsubsection faq_cmakeoption4 Option's cache and how to reset?
217
218 When options have been set they are keep into a cache file named "CMakeCache.txt". So if you want 
219 reset values you just delete this file located to the project directory.
220
221 \subsection faq_cmakecompilation Cmake compilation
222
223 \subsubsection faq_cmakecompilation1 With command line.
224
225 \verbatim
226 cmake -D[name]=[value] ... ./
227 make
228 \endverbatim
229
230 On Windows
231
232 Open the "Git Bash" window.
233 \verbatim
234 cmake -G"Unix Makefiles" -D[name]=[value] ... ./
235 gmake
236 \endverbatim
237
238 \subsubsection faq_cmakecompilation2 With ccmake tool.
239
240 \verbatim
241 "ccmake ./"
242 \endverbatim
243 Then follow instructions.
244
245 \subsubsection faq_cmakecompilation2bis Build out of source.
246
247 As cmake generate many files used for compilation, we recommand to make a build directory.
248 For examples you can make :
249
250 \verbatim
251 "navarrop@caraja:~/Developments$ cd simgrid/"
252 "navarrop@caraja:~/Developments/simgrid$ mkdir build_directory"
253 "navarrop@caraja:~/Developments/simgrid$ cd build_directory/"
254 "navarrop@caraja:~/Developments/simgrid/build_directory$ cmake ../"
255 "navarrop@caraja:~/Developments/simgrid/build_directory$ make"
256 \endverbatim
257
258 Or complety out of sources :
259
260 \verbatim
261 "navarrop@caraja:~/Developments$ mkdir build_dir"
262 "navarrop@caraja:~/Developments$ cd build_dir/"
263 "navarrop@caraja:~/Developments/build_dir$ cmake ../simgrid/"
264 "navarrop@caraja:~/Developments/build_dir$ make"
265 \endverbatim
266
267 Those two kind of compilation permit to delete files created by compilation easier.
268
269 \subsubsection faq_cmakecompilation3 Resume of command line
270
271  \li CMake
272 \verbatim
273 cmake <path>                    configure the project
274 make                            build all targets
275 make VERBOSE=1                  build all targets and print build command lines
276 make check                      test all targets and summarize
277 make dist                       make the distrib
278 make distcheck                  check the dist (make + make dist + make check) 
279 make install                    install the project (doc/ bin/ lib/ include/)
280 make uninstall                  uninstall the project (doc/ bin/ lib/ include/)
281 make clean                      clean all targets
282 make simgrid_documentation      Create simgrid documentation
283 \endverbatim
284
285 When the project have been succesfully compiling and build you can make tests.
286
287  \li CTest
288 \verbatim
289 ctest                   launch only tests
290 ctest -D Continuous
291 ctest -D Continuous(Start|Update|Configure|Build)
292 ctest -D Continuous(Test|Coverage|MemCheck|Submit)
293 ctest -D Experimental
294 ctest -D Experimental(Start|Update|Configure|Build)
295 ctest -D Experimental(Test|Coverage|MemCheck|Submit)
296 ctest -D Nightly                                
297 ctest -D Nightly(Start|Update|Configure|Build)
298 ctest -D Nightly(Test|Coverage|MemCheck|Submit)
299 ctest -D NightlyMemoryCheck
300 \endverbatim
301
302 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>.
303
304 \subsection faq_cmakeinstall How to install with cmake?
305
306 \subsubsection faq_cmakeinstall1 From svn. 
307
308 For Unix and MacOS:
309 \verbatim
310 cmake -Denable_maintainer_mode=on -DCMAKE_INSTALL_PREFIX=/home/navarrop/Bureau/install_simgrid ./
311 make 
312 make install
313 \endverbatim
314
315 For Windows:
316
317 \verbatim
318 cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=C:\simgrid_install ./
319 gmake
320 gmake install
321 \endverbatim
322
323 \subsubsection faq_cmakeinstall2 From a distrib
324
325 \verbatim
326 For version 3.4.1 and 3.4
327         cmake -Dprefix=/home/navarrop/Bureau/install_simgrid ./
328         make
329         make install-simgrid
330 Since version 3.5
331         cmake -DCMAKE_INSTALL_PREFIX=/home/navarrop/Bureau/install_simgrid ./
332         make
333         make install
334 \endverbatim
335
336 \subsection faq_cmakeWHATisInstall What is installed by cmake?
337
338 \subsubsection faq_cmakeWHATisInstallBIN CMAKE_INSTALL_PREFIX/bin
339 \verbatim
340 tesh
341 graphicator
342 gras_stub_generator
343 simgrid_update_xml
344 simgrid-colorizer
345 smpicc
346 smpiff
347 smpif2c
348 smpirun
349 \endverbatim
350 \subsubsection faq_cmakeWHATisInstallDOC CMAKE_INSTALL_PREFIX/doc 
351 \verbatim
352 simgrid/examples/
353 simgrid/html/
354 \endverbatim
355 \subsubsection faq_cmakeWHATisInstallINCLUDE CMAKE_INSTALL_PREFIX/include
356 \verbatim
357 amok/
358 gras/
359 instr/
360 mc/
361 msg/
362 simdag/
363 simix/
364 smpi/
365 surf/
366 xbt/
367 gras.h
368 simgrid_config.h
369 xbt.h
370 \endverbatim
371 \subsubsection faq_cmakeWHATisInstallLIB CMAKE_INSTALL_PREFIX/lib
372 \verbatim
373 libgras.so.3.5
374 libsimgrid.so.3.5
375 libsmpi.so.3.5
376 libsimgrid.so -> libsimgrid.so.3.5
377 libgras.so -> libgras.so.3.5
378 libsmpi.so -> libsmpi.so.3.5
379 lua/5.1/simgrid.so -> ../../libsimgrid.so
380 ruby/1.9.0/x86_64-linux/libsimgrid.so -> ../../../libsimgrid.so
381 ruby/1.9.0/x86_64-linux/simgrid.rb
382 \endverbatim
383 \subsection faq_cmakehowto How to modified sources files for developers
384
385 \subsubsection faq_cmakehowto1 Add an executable or examples.
386
387 If you want make an executable you have to create a CMakeList.txt to the src directory. 
388 You must specified where to create the executable, source list, dependencies and the name of the binary.
389
390 \verbatim
391 cmake_minimum_required(VERSION 2.6)
392
393 set(EXECUTABLE_OUTPUT_PATH "./")                        
394 set(LIBRARY_OUTPUT_PATH "${CMAKE_HOME_DIRECTORY}/lib")
395
396 add_executable(get_sender get_sender.c)                                 #add_executable(<name_of_target> <src list>)
397
398 ### Add definitions for compile
399 target_link_libraries(get_sender simgrid m pthread)     #target_link_libraries(<name_of_targe> <dependencies>)
400 \endverbatim
401
402 Then you have to modified <project/directory>/buildtools/Cmake/MakeExeLib.cmake and add 
403 this line :
404 \verbatim
405 add_subdirectory(${CMAKE_HOME_DIRECTORY}/<path_where_is_CMakeList.txt>)
406 \endverbatim
407
408 \subsubsection faq_cmakehowto2 Delete/add sources to lib.
409
410 If you want modified, add or delete source files from a library you have to edit <project/directory>/buildtools/Cmake/DefinePackages.cmake
411
412 \verbatim
413 set(JMSG_JAVA_SRC
414         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/MsgException.java
415         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/JniException.java
416         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/NativeException.java
417         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/HostNotFoundException.java
418         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/ProcessNotFoundException.java
419         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Msg.java
420         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Process.java
421         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Host.java
422         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Task.java
423         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/MsgNative.java
424         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/ApplicationHandler.java
425         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Sem.java
426 )
427 \endverbatim
428
429 \subsubsection faq_cmakehowto3 Add test
430
431 If you want modified, add or delete tests you have to edit <project/directory>/buildtools/Cmake/AddTests.cmake 
432 with this function : ADD_TEST(<name> <bin> <ARGS>)
433
434 \verbatim
435 add_test(test-simdag-1 ${CMAKE_HOME_DIRECTORY}/testsuite/simdag/sd_test --cfg=path:${CMAKE_HOME_DIRECTORY}/testsuite/simdag small_platform_variable.xml)
436 \endverbatim
437
438 \subsection faq_PIPOL Pipol-remote
439
440 Now we offer the possibility to test your local sources on pipol platforms before a commit. Of course you have to be user of pipol <a href="https://pipol.inria.fr/users/">(Account request)</a> cause you need to give your pipol_username to cmake. Here is a list of available systems :
441 \verbatim
442     amd64_kvm-linux-debian-lenny
443     amd64_kvm-linux-debian-testing
444     amd64_kvm-windows-7
445     amd64-linux-centos-5.dd.gz
446     amd64-linux-debian-etch.dd.gz
447     amd64-linux-debian-lenny.dd.gz
448     amd64-linux-debian-testing.dd.gz
449     amd64-linux-fedora-core10.dd.gz
450     amd64-linux-fedora-core11.dd.gz
451     amd64-linux-fedora-core12.dd.gz
452     amd64-linux-fedora-core13.dd.gz
453     amd64-linux-fedora-core7.dd.gz
454     amd64-linux-fedora-core8.dd.gz
455     amd64-linux-fedora-core9.dd.gz
456     amd64-linux-mandriva-2007_springs_powerpack.dd.gz
457     amd64-linux-mandriva-2009_powerpack.dd.gz
458     amd64-linux-opensuse-11.dd.gz
459     amd64-linux-redhatEL-5.0.dd.gz
460     amd64-linux-suse-LES10.dd.gz
461     amd64-linux-ubuntu-feisty.dd.gz
462     amd64-linux-ubuntu-hardy.dd.gz
463     amd64-linux-ubuntu-intrepid.dd.gz
464     amd64-linux-ubuntu-jaunty.dd.gz
465     amd64-linux-ubuntu-karmic.dd.gz
466     amd64-linux-ubuntu-lucid.dd.gz
467     amd64-unix-freebsd-7.dd.gz
468     amd64-windows-server-2003-64bits.dd.gz
469     amd64-windows-server-2008-64bits.dd.gz
470     i386_kvm-linux-debian-lenny
471     i386_kvm-linux-debian-testing
472     i386_kvm-linux-fedora-core13
473     i386_kvm-windows-xp-pro-sp3
474     i386-linux-centos-5.dd.gz
475     i386-linux-debian-etch.dd.gz
476     i386-linux-debian-lenny.dd.gz
477     i386-linux-debian-testing.dd.gz
478     i386-linux-fedora-core10.dd.gz
479     i386-linux-fedora-core11.dd.gz
480     i386-linux-fedora-core12.dd.gz
481     i386-linux-fedora-core13.dd.gz
482     i386-linux-fedora-core7.dd.gz
483     i386-linux-fedora-core8.dd.gz
484     i386-linux-fedora-core9.dd.gz
485     i386-linux-mandriva-2007_springs_powerpack.dd.gz
486     i386-linux-mandriva-2009_powerpack.dd.gz
487     i386-linux-opensuse-11.dd.gz
488     i386-linux-redhatEL-5.0.dd.gz
489     i386-linux-suse-LES10.dd.gz
490     i386-linux-ubuntu-feisty.dd.gz
491     i386-linux-ubuntu-hardy.dd.gz
492     i386-linux-ubuntu-intrepid.dd.gz
493     i386-linux-ubuntu-jaunty.dd.gz
494     i386-linux-ubuntu-karmic.dd.gz
495     i386-linux-ubuntu-lucid.dd.gz
496     i386_mac-mac-osx-server-leopard.dd.gz
497     i386-unix-freebsd-7.dd.gz
498     i386-unix-opensolaris-10.dd.gz
499     i386-unix-opensolaris-11.dd.gz
500     i386-unix-solaris-10.dd.gz
501     ia64-linux-debian-lenny.dd
502     ia64-linux-fedora-core9.dd
503     ia64-linux-redhatEL-5.0.dd
504     x86_64_mac-mac-osx-server-snow-leopard.dd.gz
505     x86_mac-mac-osx-server-snow-leopard.dd.gz
506 \endverbatim
507
508 Two kind of uses are possible : 
509 \verbatim
510 This command copy your source and execute a configure then a build and finish with tests.
511         bob@caraja:~/Developments/simgrid/tmp_build$ make <name_of_image> 
512
513 This command copy your source and execute a \"ctest -D Experimental\" and submit the result to cdash.
514         bob@caraja:~/Developments/simgrid/tmp_build$ make <name_of_image>_experimental 
515 \endverbatim    
516 All commands are resumed with :
517 \verbatim
518 bob@caraja:~/Developments/simgrid/tmp_build$ make pipol_experimental_list_images
519 bob@caraja:~/Developments/simgrid/tmp_build$ make pipol_test_list_images
520 \endverbatim
521
522 \section faq_installation Installing the SimGrid library with Autotools (valid until V3.3.4)
523
524 Many people have been asking me questions on how to use SimGrid. Quite
525 often, the questions were not really about SimGrid but on the
526 installation process. This section is intended to help people that are
527 not familiar with compiling C files under UNIX. If you follow these
528 instructions and still have some troubles, drop an e-mail to
529 <simgrid-user@lists.gforge.inria.fr>.
530
531 \subsection faq_compiling Compiling SimGrid from a stable archive
532
533 First of all, you need to download the latest version of SimGrid from 
534 <a href="http://gforge.inria.fr/frs/?group_id=12">here</a>.
535 Suppose you have uncompressed SimGrid in some temporary location of
536 your home directory (say <tt>/home/joe/tmp/simgrid-3.0.1 </tt>). The
537 simplest way to use SimGrid is to install it in your home
538 directory. Change your directory to
539 <tt>/home/joe/tmp/simgrid-3.0.1</tt> and type
540
541 \verbatim
542 ./configure --prefix=$HOME
543 make
544 make install
545 \endverbatim
546
547 If at some point, something fails, check the section \ref faq_trouble_compil .
548 If it does not help, you can report this problem to the
549 list but, please, avoid sending a laconic mail like "There is a problem. Is it
550 okay?". Send the config.log file which is automatically generated by
551 configure. Try to capture both the standard output and the error output of the
552 <tt>make</tt> command with <tt>script</tt>. There is no way for us to help you
553 without the relevant bits of information.
554
555 Now, the following directory should have been created : 
556
557       \li <tt>/home/joe/doc/simgrid/html/</tt>
558       \li <tt>/home/joe/lib/</tt>
559       \li <tt>/home/joe/include/</tt>
560
561 SimGrid is not a binary, it is a library. Both a static and a dynamic
562 version are available. Here is what you can find if you try a <tt>ls
563 /home/joe/lib</tt>:
564
565 \verbatim libsimgrid.a libsimgrid.la libsimgrid.so libsimgrid.so.0 libsimgrid.so.0.0.1
566 \endverbatim
567
568 Thus, there is two ways to link your program with SimGrid:
569       \li Either you use the static version, e.g 
570 \verbatim gcc libsimgrid.a -o MainProgram MainProgram.c
571 \endverbatim
572           In this case, all the SimGrid functions are directly
573           included in <tt>MainProgram</tt> (hence a bigger binary).
574       \li Either you use the dynamic version (the preferred method)
575 \verbatim gcc -lsimgrid -o MainProgram MainProgram.c
576 \endverbatim
577           In this case, the SimGrid functions are not included in
578           <tt>MainProgram</tt> and you need to set your environment
579           variable in such a way that <tt>libsimgrid.so</tt> will be
580           found at runtime. This can be done by adding the following
581           line in your .bashrc (if you use bash and if you have
582           installed the SimGrid libraries in your home directory):
583 \verbatim export LD_LIBRARY_PATH=$HOME/lib/:$LD_LIBRARY_PATH
584 \endverbatim
585
586 \subsection faq_compiling_java Java bindings don't get compiled
587
588 The configure script detects automatically whether you have the
589 softwares needed to use the Java bindings or not. At the end of the
590 configure, you can see the configuration picked by the script, which
591 should look similar to 
592 \verbatim Configuration of package simgrid' (version 3.3.4-svn) on
593 little64 (=4):
594
595          Compiler:       gcc (version: )
596          
597          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
598          CPPFlags:   
599          LDFlags:        
600                                    
601          Context backend: ucontext
602          Compile Java: no
603                                                          
604          Maintainer mode: no
605          Supernovae mode: yes
606 \endverbatim       
607
608 In this example, Java backends won't be compiled. 
609
610 On Debian-like systems (which includes ubuntu), you need the following
611 packages: sun-java6-jdk libgcj10-dev. If you cannot find the
612 libgcj10-dev, try another version, like libgcj9-dev (on Ubuntu before
613 9.10) or libgcj11-dev (not released yet, but certainly one day).
614 Please note that you need to activate the contrib and non-free
615 repositories in Debian, and the universe ones in Ubuntu. Java comes at
616 this price...
617
618 \subsection faq_compiling_snapshoot SimGrid development snapshots
619
620 We have very high standards on software quality, and we are reluctant releasing
621 a stable release as long as there is still some known bug in the code base. In
622 addition, we added quite an extensive test base, making sure that we correctly
623 test the most important parts of the tool. 
624
625 As an unfortunate conclusion, there may be some time between the stable
626 releases. If you want to benefit from the most recent features we introduced,
627 but don't want to take the risk of an untested version from the SVN, then
628 development snapshots are done for you. 
629
630 These are pre-releases of SimGrid that still fail some tests about features
631 that almost nobody use, or on platforms not being in our core target (which is
632 Linux, Mac, other Unixes and Windows, from the most important to the less
633 one). That means that using this development releases should be safe for most
634 users. 
635
636 These archives can be found on 
637 <a href="http://www.loria.fr/~quinson/Research/SimGrid/">this web page</a>. Once you 
638 got the lastest archive, you can compile it just like any archive (see above).
639
640 \subsection faq_compiling_svn Compiling SimGrid from the SVN
641
642 The project development takes place in the SVN, where all changes are
643 committed when they happen. Then every once in a while, we make sure that the
644 code quality meets our standard and release an archive from the code in the
645 SVN. We afterward go back to the development in the SVN. So, if you need a
646 recently added feature and can afford some little problem with the stability
647 of the lastest features, you may want to use the SVN version instead of a
648 released one.
649
650 For that, you first need to get the "simgrid" module from
651 <a href="http://gforge.inria.fr/scm/?group_id=12">here</a>. 
652
653 You won't find any <tt>configure</tt> and a few other things
654 (<tt>Makefile.in</tt>'s, documentation, ...) will be missing as well. The
655 reason for that is that all these files have to be regenerated using the
656 latest versions of <tt>autoconf</tt>, <tt>libtool</tt>, <tt>automake</tt>
657 (>1.9) and <tt>doxygen</tt> (>1.4). To generate the <tt>configure</tt> and
658 the <tt>Makefile.in</tt>'s, you just have to launch the <tt>bootstrap</tt>
659 command that resides in the top of the source tree. Then just follow the
660 instructions of Section \ref faq_compiling.
661
662 We insist on the fact that you really need the latest versions of
663 autoconf, automake and libtool. Doing this step on exotic architectures/systems
664 (i.e. anything different from a recent linux distribution) may be
665 ... uncertain. If you need to compile the SVN version on a machine where all these
666 dependencies are not met, the easiest is to do <tt>make dist</tt> in the SVN
667 directory of another machine where all dependencies are met. It will create an
668 archive you may deploy on other sites just as a regular stable release.
669
670 In summary, the following commands will checkout the SVN, regenerate the
671 configure script and friends, configure SimGrid and build it.
672
673 \verbatim svn checkout svn://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk simgrid
674 cd simgrid
675 ./bootstrap
676 ./configure --enable-maintainer-mode --prefix=<where to install SimGrid>
677 make \endverbatim
678
679 Then, if you want to install SimGrid on the current box, just do:
680 \verbatim make install \endverbatim
681
682 If you want to build an snapshot of the SVN to deploy it on another box (for
683 example because the other machine don't have the autotools), do:
684 \verbatim make dist \endverbatim
685
686 Moreover, you should never call the autotools manually since you must run
687 them in a specific order with specific arguments. Most of the times, the
688 makefiles will automatically call the tools for you. When it's not possible
689 (such as the first time you checkout the SVN), use the ./bootstrap command
690 to call them explicitly.
691
692
693 \subsection faq_setting_MSG Setting up your own MSG code
694
695 Do not build your simulator by modifying the SimGrid examples.  Go
696 outside the SimGrid source tree and create your own working directory
697 (say <tt>/home/joe/SimGrid/MyFirstScheduler/</tt>).
698
699 Suppose your simulation has the following structure (remember it is
700 just an example to illustrate a possible way to compile everything;
701 feel free to organize it as you want).
702
703       \li <tt>sched.h</tt>: a description of the core of the
704           scheduler (i.e. which functions are can be used by the
705           agents). For example we could find the following functions
706           (master, forwarder, slave).
707
708       \li <tt>sched.c</tt>: a C file including <tt>sched.h</tt> and
709           implementing the core of the scheduler. Most of these
710           functions use the MSG functions defined in section \ref
711           msg_gos_functions.
712
713       \li <tt>masterslave.c</tt>: a C file with the main function, i.e.
714           the MSG initialization (MSG_global_init()), the platform
715           creation (e.g. with MSG_create_environment()), the
716           deployment phase (e.g. with MSG_function_register() and
717           MSG_launch_application()) and the call to
718           MSG_main()).
719
720 To compile such a program, we suggest to use the following
721 Makefile. It is a generic Makefile that we have used many times with
722 our students when we teach the C language.
723
724 \verbatim
725 all: masterslave 
726 masterslave: masterslave.o sched.o
727
728 INSTALL_PATH = $$HOME
729 CC = gcc
730 PEDANTIC_PARANOID_FREAK =       -O0 -Wshadow -Wcast-align \
731                                 -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
732                                 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
733                                 -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
734                                 -Wpointer-arith -Wwrite-strings -finline-functions
735 REASONABLY_CAREFUL_DUDE =       -Wall
736 NO_PRAYER_FOR_THE_WICKED =      -w -O2 
737 WARNINGS =                      $(REASONABLY_CAREFUL_DUDE)
738 CFLAGS = -g $(WARNINGS)
739
740 INCLUDES = -I$(INSTALL_PATH)/include
741 DEFS = -L$(INSTALL_PATH)/lib/
742 LDADD = -lm -lsimgrid 
743 LIBS = 
744
745 %: %.o
746         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ 
747
748 %.o: %.c
749         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
750
751 clean:
752         rm -f $(BIN_FILES) *.o *~
753 .SUFFIXES:
754 .PHONY : clean
755
756 \endverbatim
757
758 The first two lines indicates what should be build when typing make
759 (<tt>masterslave</tt>) and of which files it is to be made of
760 (<tt>masterslave.o</tt> and <tt>sched.o</tt>). This makefile assumes
761 that you have set up correctly your <tt>LD_LIBRARY_PATH</tt> variable
762 (look, there is a <tt>LDADD = -lm -lsimgrid</tt>). If you prefer using
763 the static version, remove the <tt>-lsimgrid</tt> and add a
764 <tt>$(INSTALL_PATH)/lib/libsimgrid.a</tt> on the next line, right
765 after the <tt>LIBS = </tt>.
766
767 More generally, if you have never written a Makefile by yourself, type
768 in a terminal : <tt>info make</tt> and read the introduction. The
769 previous example should be enough for a first try but you may want to
770 perform some more complex compilations...
771
772 \subsection faq_setting_GRAS Setting up your own GRAS code
773
774 If you use the GRAS interface instead of the MSG one, then previous section
775 is not the better source of information. Instead, you should check the GRAS
776 tutorial in general, and the \ref GRAS_tut_tour_setup in particular.
777
778 \section faq_howto Feature related questions
779
780 \subsection faq_MIA "Could you please add (your favorite feature here) to SimGrid?"
781
782 Here is the deal. The whole SimGrid project (MSG, SURF, GRAS, ...) is
783 meant to be kept as simple and generic as possible. We cannot add
784 functions for everybody's needs when these functions can easily be
785 built from the ones already in the API. Most of the time, it is
786 possible and when it was not possible we always have upgraded the API
787 accordingly. When somebody asks us a question like "How to do that?
788 Is there a function in the API to simply do this?", we're always glad
789 to answer and help. However if we don't need this code for our own
790 need, there is no chance we're going to write it... it's your job! :)
791 The counterpart to our answers is that once you come up with a neat
792 implementation of this feature (task duplication, RPC, thread
793 synchronization, ...), you should send it to us and we will be glad to
794 add it to the distribution. Thus, other people will take advantage of
795 it (and we don't have to answer this question again and again ;).
796
797 You'll find in this section a few "Missing In Action" features. Many
798 people have asked about it and we have given hints on how to simply do
799 it with MSG. Feel free to contribute...
800
801 \subsection faq_MIA_MSG MSG features
802
803 \subsubsection faq_MIA_examples I want some more complex MSG examples!
804
805 Many people have come to ask me a more complex example and each time,
806 they have realized afterward that the basics were in the previous three
807 examples. 
808
809 Of course they have often been needing more complex functions like
810 MSG_process_suspend(), MSG_process_resume() and
811 MSG_process_isSuspended() (to perform synchronization), or
812 MSG_task_Iprobe() and MSG_process_sleep() (to avoid blocking
813 receptions), or even MSG_process_create() (to design asynchronous
814 communications or computations). But the examples are sufficient to
815 start.
816
817 We know. We should add some more examples, but not really some more
818 complex ones... We should add some examples that illustrate some other
819 functionalists (like how to simply encode asynchronous
820 communications, RPC, process migrations, thread synchronization, ...)
821 and we will do it when we will have a little bit more time. We have
822 tried to document the examples so that they are understandable. Tell
823 us if something is not clear and once again feel free to participate!
824 :)
825
826 \subsubsection faq_MIA_taskdup Missing in action: MSG Task duplication/replication
827
828 There is no task duplication in MSG. When you create a task, you can
829 process it or send it somewhere else. As soon as a process has sent
830 this task, he doesn't have this task anymore. It's gone. The receiver
831 process has got the task. However, you could decide upon receiving to
832 create a "copy" of a task but you have to handle by yourself the
833 semantic associated to this "duplication".
834
835 As we already told, we prefer keeping the API as simple as
836 possible. This kind of feature is rather easy to implement by users
837 and the semantic you associate really depends on people. Having a
838 *generic* task duplication mechanism is not that trivial (in
839 particular because of the data field). That is why I would recommand
840 that you write it by yourself even if I can give you advice on how to
841 do it.
842
843 You have the following functions to get informations about a task:
844 MSG_task_get_name(), MSG_task_get_compute_duration(),
845 MSG_task_get_remaining_computation(), MSG_task_get_data_size(),
846 and MSG_task_get_data().
847
848 You could use a dictionary (#xbt_dict_t) of dynars (#xbt_dynar_t). If
849 you still don't see how to do it, please come back to us...
850
851 \subsubsection faq_MIA_asynchronous I want to do asynchronous communications in MSG
852
853 In the past (version <= 3.4), there was no function to perform asynchronous communications. 
854 It could easily be implemented by creating new process when needed though. Since version 3.5, 
855 we have introduced the following functions:
856  - MSG_task_isend()
857  - MSG_task_irecv()
858  - MSG_comm_test()
859  - MSG_comm_wait()
860  - MSG_comm_waitall()
861  - MSG_comm_waitany()
862  - MSG_comm_destroy()
863
864 We refer you to the description of these functions for more details on their usage as well 
865 as to the exemple section on \ref MSG_ex_asynchronous_communications.
866
867 \subsubsection faq_MIA_thread_synchronization I need to synchronize my MSG processes
868
869 You obviously cannot use pthread_mutexes of pthread_conds since we handle every 
870 scheduling related decision within SimGrid. 
871
872 In the past (version <=3.3.4) you could do it by playing with
873 MSG_process_suspend() and MSG_process_resume() or with fake communications (using MSG_task_get(),
874 MSG_task_put() and MSG_task_Iprobe()).
875
876 Since version 3.4, you can use classical synchronization structures. See page \ref XBT_synchro or simply check in
877 include/xbt/synchro_core.h.
878
879 \subsubsection faq_MIA_host_load Where is the get_host_load function hidden in MSG?
880
881 There is no such thing because its semantic wouldn't be really
882 clear. Of course, it is something about the amount of host throughput,
883 but there is as many definition of "host load" as people asking for
884 this function. First, you have to remember that resource availability
885 may vary over time, which make any load notion harder to define.
886
887 It may be instantaneous value or an average one. Moreover it may be only the
888 power of the computer, or may take the background load into account, or may
889 even take the currently running tasks into account. In some SURF models,
890 communications have an influence on computational power. Should it be taken
891 into account too?
892
893 First of all, it's near to impossible to predict the load beforehands in the
894 simulator since it depends on too much parameters (background load
895 variation, bandwidth sharing algorithmic complexity) some of them even being
896 not known beforehands (other task starting at the same time). So, getting
897 this information is really hard (just like in real life). It's not just that
898 we want MSG to be as painful as real life. But as it is in some way
899 realistic, we face some of the same problems as we would face in real life.
900
901 How would you do it for real? The most common option is to use something
902 like NWS that performs active probes. The best solution is probably to do
903 the same within MSG, as in next code snippet. It is very close from what you
904 would have to do out of the simulator, and thus gives you information that
905 you could also get in real settings to not hinder the realism of your
906 simulation. 
907
908 \verbatim
909 double get_host_load() {
910    m_task_t task = MSG_task_create("test", 0.001, 0, NULL);
911    double date = MSG_get_clock();
912
913    MSG_task_execute(task);
914    date = MSG_get_clock() - date;
915    MSG_task_destroy(task);
916    return (0.001/date);
917 }
918 \endverbatim
919
920 Of course, it may not match your personal definition of "host load". In this
921 case, please detail what you mean on the mailing list, and we will extend
922 this FAQ section to fit your taste if possible.
923
924 \subsubsection faq_MIA_communication_time How can I get the *real* communication time?  
925
926 Communications are synchronous and thus if you simply get the time
927 before and after a communication, you'll only get the transmission
928 time and the time spent to really communicate (it will also take into
929 account the time spent waiting for the other party to be
930 ready). However, getting the *real* communication time is not really
931 hard either. The following solution is a good starting point.
932
933 \verbatim
934 int sender()
935 {
936   m_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size, 
937                                   calloc(1,sizeof(double)));
938   *((double*) task->data) = MSG_get_clock();
939   MSG_task_put(task, slaves[i % slaves_count], PORT_22);
940   XBT_INFO("Send completed");
941   return 0;
942 }
943 int receiver()
944 {
945   m_task_t task = NULL;
946   double time1,time2;
947
948   time1 = MSG_get_clock();
949   a = MSG_task_get(&(task), PORT_22);
950   time2 = MSG_get_clock();
951   if(time1<*((double *)task->data))
952      time1 = *((double *) task->data);
953   XBT_INFO("Communication time :  \"%f\" ", time2-time1);
954   free(task->data);
955   MSG_task_destroy(task);
956   return 0;
957 }
958 \endverbatim
959
960 \subsection faq_MIA_SimDag SimDag related questions
961
962 \subsubsection faq_SG_comm Implementing communication delays between tasks.
963
964 A classic question of SimDag newcomers is about how to express a
965 communication delay between tasks. The thing is that in SimDag, both
966 computation and communication are seen as tasks.  So, if you want to
967 model a data dependency between two DAG tasks t1 and t2, you have to
968 create 3 SD_tasks: t1, t2 and c and add dependencies in the following
969 way:
970
971 \verbatim
972 SD_task_dependency_add(NULL, NULL, t1, c);
973 SD_task_dependency_add(NULL, NULL, c, t2);
974 \endverbatim
975
976 This way task t2 cannot start before the termination of communication c
977 which in turn cannot start before t1 ends.
978
979 When creating task c, you have to associate an amount of data (in bytes)
980 corresponding to what has to be sent by t1 to t2.
981
982 Finally to schedule the communication task c, you have to build a list
983 comprising the workstations on which t1 and t2 are scheduled (w1 and w2
984 for example) and build a communication matrix that should look like
985 [0;amount ; 0; 0].
986
987 \subsubsection faq_SG_DAG How to implement a distributed dynamic scheduler of DAGs.
988
989 Distributed is somehow "contagious". If you start making distributed
990 decisions, there is no way to handle DAGs directly anymore (unless I
991 am missing something). You have to encode your DAGs in term of
992 communicating process to make the whole scheduling process
993 distributed. Here is an example of how you could do that. Assume T1
994 has to be done before T2.
995
996 \verbatim
997  int your_agent(int argc, char *argv[] {
998    ...
999    T1 = MSG_task_create(...);
1000    T2 = MSG_task_create(...);
1001    ...
1002    while(1) {
1003      ...
1004      if(cond) MSG_task_execute(T1);
1005      ...
1006      if((MSG_task_get_remaining_computation(T1)=0.0) && (you_re_in_a_good_mood))
1007         MSG_task_execute(T2)
1008      else {
1009         /* do something else */
1010      }
1011    }
1012  }
1013 \endverbatim
1014  
1015 If you decide that the distributed part is not that much important and that
1016 DAG is really the level of abstraction you want to work with, then you should
1017 give a try to \ref SD_API.
1018
1019 \subsection faq_MIA_generic Generic features
1020
1021 \subsubsection faq_more_processes Increasing the amount of simulated processes
1022
1023 Here are a few tricks you can apply if you want to increase the amount
1024 of processes in your simulations.
1025
1026  - <b>A few thousands of simulated processes</b> (soft tricks)\n
1027    SimGrid can use either pthreads library or the UNIX98 contextes. On
1028    most systems, the number of pthreads is limited and then your
1029    simulation may be limited for a stupid reason. This is especially
1030    true with the current linux pthreads, and I cannot get more than
1031    2000 simulated processes with pthreads on my box. The UNIX98
1032    contexts allow me to raise the limit to 25,000 simulated processes
1033    on my laptop.\n\n
1034    The <tt>--with-context</tt> option of the <tt>./configure</tt>
1035    script allows you to choose between UNIX98 contextes
1036    (<tt>--with-context=ucontext</tt>) and the pthread version
1037    (<tt>--with-context=pthread</tt>). The default value is ucontext
1038    when the script detect a working UNIX98 context implementation. On
1039    Windows boxes, the provided value is discarded and an adapted
1040    version is picked up.\n\n
1041    We experienced some issues with contextes on some rare systems
1042    (solaris 8 and lower or old alpha linuxes comes to mind). The main
1043    problem is that the configure script detect the contextes as being
1044    functional when it's not true. If you happen to use such a system,
1045    switch manually to the pthread version, and provide us with a good
1046    patch for the configure script so that it is done automatically ;)
1047
1048  - <b>Hundred thousands of simulated processes</b> (hard-core tricks)\n 
1049    As explained above, SimGrid can use UNIX98 contextes to represent
1050    and handle the simulated processes. Thanks to this, the main
1051    limitation to the number of simulated processes becomes the
1052    available memory.\n\n
1053    Here are some tricks I had to use in order to run a token ring
1054    between 25,000 processes on my laptop (1Gb memory, 1.5Gb swap).\n
1055    - First of all, make sure your code runs for a few hundreds
1056      processes before trying to push the limit. Make sure it's
1057      valgrind-clean, ie that valgrind does not report neither memory
1058      error nor memory leaks. Indeed, numerous simulated processes
1059      result in *fat* simulation hindering debugging.
1060    - It was really boring to write 25,000 entries in the deployment
1061      file, so I wrote a little script
1062      <tt>examples/gras/mutual_exclusion/simple_token/make_deployment.pl</tt>, which you may
1063      want to adapt to your case. You could also think about hijacking
1064      the SURFXML parser (have look at \ref faq_flexml_bypassing).
1065    - The deployment file became quite big, so I had to do what is in
1066      the FAQ entry \ref faq_flexml_limit
1067    - Each UNIX98 context has its own stack entry. As debugging this is
1068      quite hairly, the default value is a bit overestimated so that
1069      user don't get into trouble about this. You want to tune this
1070      size to increse the number of processes. This is the
1071      <tt>STACK_SIZE</tt> define in 
1072      <tt>src/xbt/xbt_context_sysv.c</tt>, which is 128kb by default.
1073      Reduce this as much as you can, but be warned that if this value
1074      is too low, you'll get a segfault. The token ring example, which
1075      is quite simple, runs with 40kb stacks.     
1076    - You may tweak the logs to reduce the stack size further.  When
1077      logging something, we try to build the string to display in a
1078      char array on the stack. The size of this array is constant (and
1079      equal to XBT_LOG_BUFF_SIZE, defined in include/xbt/log/h). If the
1080      string is too large to fit this buffer, we move to a dynamically
1081      sized buffer. In which case, we have to traverse one time the log
1082      event arguments to compute the size we need for the buffer,
1083      malloc it, and traverse the argument list again to do the actual
1084      job.\n     
1085      The idea here is to move XBT_LOG_BUFF_SIZE to 1, forcing the logs
1086      to use a dynamic array each time. This allows us to lower further
1087      the stack size at the price of some performance loss...\n
1088      This allowed me to run the reduce the stack size to ... 4k. Ie,
1089      on my 1Gb laptop, I can run more than 250,000 processes!
1090
1091 \subsubsection faq_MIA_batch_scheduler Is there a native support for batch schedulers in SimGrid?
1092
1093 No, there is no native support for batch schedulers and none is
1094 planned because this is a very specific need (and doing it in a
1095 generic way is thus very hard). However some people have implemented
1096 their own batch schedulers. Vincent Garonne wrote one during his PhD
1097 and put his code in the contrib directory of our SVN so that other can
1098 keep working on it. You may find inspiring ideas in it.
1099
1100 \subsubsection faq_MIA_checkpointing I need a checkpointing thing
1101
1102 Actually, it depends on whether you want to checkpoint the simulation, or to
1103 simulate checkpoints. 
1104
1105 The first one could help if your simulation is a long standing process you
1106 want to keep running even on hardware issues. It could also help to
1107 <i>rewind</i> the simulation by jumping sometimes on an old checkpoint to
1108 cancel recent calculations.\n 
1109 Unfortunately, such thing will probably never exist in SG. One would have to
1110 duplicate all data structures because doing a rewind at the simulator level
1111 is very very hard (not talking about the malloc free operations that might
1112 have been done in between). Instead, you may be interested in the Libckpt
1113 library (http://www.cs.utk.edu/~plank/plank/www/libckpt.html). This is the
1114 checkpointing solution used in the condor project, for example. It makes it
1115 easy to create checkpoints (at the OS level, creating something like core
1116 files), and rerunning them on need.
1117
1118 If you want to simulate checkpoints instead, it means that you want the
1119 state of an executing task (in particular, the progress made towards
1120 completion) to be saved somewhere.  So if a host (and the task executing on
1121 it) fails (cf. #MSG_HOST_FAILURE), then the task can be restarted
1122 from the last checkpoint.\n
1123
1124 Actually, such a thing does not exists in SimGrid either, but it's just
1125 because we don't think it is fundamental and it may be done in the user code
1126 at relatively low cost. You could for example use a watcher that
1127 periodically get the remaining amount of things to do (using
1128 MSG_task_get_remaining_computation()), or fragment the task in smaller
1129 subtasks.
1130
1131 \subsection faq_platform Platform building and Dynamic resources
1132
1133 \subsubsection faq_platform_example Where can I find SimGrid platform files?
1134
1135 There is several little examples in the archive, in the examples/msg
1136 directory. From time to time, we are asked for other files, but we
1137 don't have much at hand right now. 
1138
1139 You should refer to the Platform Description Archive
1140 (http://pda.gforge.inria.fr) project to see the other platform file we
1141 have available, as well as the Simulacrum simulator, meant to generate
1142 SimGrid platforms using all classical generation algorithms.
1143
1144 \subsubsection faq_platform_alnem How can I automatically map an existing platform?
1145
1146 We are working on a project called ALNeM (Application-Level Network
1147 Mapper) which goal is to automatically discover the topology of an
1148 existing network. Its output will be a platform description file
1149 following the SimGrid syntax, so everybody will get the ability to map
1150 their own lab network (and contribute them to the catalog project).
1151 This tool is not ready yet, but it move quite fast forward. Just stay
1152 tuned.
1153
1154 \subsubsection faq_platform_synthetic Generating synthetic but realistic platforms
1155
1156 The third possibility to get a platform file (after manual or
1157 automatic mapping of real platforms) is to generate synthetic
1158 platforms. Getting a realistic result is not a trivial task, and
1159 moreover, nobody is really able to define what "realistic" means when
1160 speaking of topology files. You can find some more thoughts on this
1161 topic in these
1162 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">slides</a>.
1163
1164 If you are looking for an actual tool, there we have a little tool to
1165 annotate Tiers-generated topologies. This perl-script is in
1166 <tt>tools/platform_generation/</tt> directory of the SVN. Dinda et Al.
1167 released a very comparable tool, and called it GridG.
1168
1169 \subsubsection faq_SURF_multicore Modeling multi-core resources 
1170
1171 There is currently no native support for multi-core or SMP machines in
1172 SimGrid. We are currently working on it, but coming up with the right
1173 model is very hard: Cores share caches and bus to access memory and
1174 thus interfere with each others. Memory contention is a crucial
1175 component of multi-core modeling.
1176
1177 In the meanwhile, some user-level tricks can reveal sufficient for
1178 you. For example, you may model each core by a CPU and add some very
1179 high speed links between them. This complicates a bit the user code
1180 since you have to remember that when you assign something to a (real)
1181 host, it can be any of the (fake) hosts representing the cores of a
1182 given machine. For that, you can use the prop tag of the XML files as
1183 follows. Your code should then look at the â€˜machine’ property
1184 associated with each workstation, and run parallel tasks over all
1185 cores of the machine.
1186
1187 \verbatim
1188   <host id="machine0/core0" power="91500E6">
1189     <prop id="machine" value="machine0"/>
1190     <prop id="core" value="0"/>
1191   </host>
1192   <host id="machine0/core1" power="91500E6">
1193     <prop id="machine" value="machine0"/>
1194     <prop id="core" value="1"/>
1195 </host>
1196
1197
1198 \endverbatim
1199
1200 \subsubsection faq_SURF_dynamic Modeling dynamic resource availability 
1201
1202 A nice feature of SimGrid is that it enables you to seamlessly have
1203 resources whose availability change over time. When you build a
1204 platform, you generally declare hosts like that:
1205
1206 \verbatim
1207   <host id="host A" power="100.00"/>
1208 \endverbatim 
1209
1210 If you want the availability of "host A" to change over time, the only
1211 thing you have to do is change this definition like that:
1212
1213 \verbatim
1214   <host id="host A" power="100.00" availability_file="trace_A.txt" state_file="trace_A_failure.txt"/>
1215 \endverbatim
1216
1217 For hosts, availability files are expressed in fraction of available
1218 power. Let's have a look at what "trace_A.txt" may look like:
1219
1220 \verbatim
1221 PERIODICITY 1.0
1222 0.0 1.0
1223 11.0 0.5
1224 20.0 0.9
1225 \endverbatim
1226
1227 At time 0, our host will deliver 100 flop/s. At time 11.0, it will
1228 deliver only 50 flop/s until time 20.0 where it will will start
1229 delivering 90 flop/s. Last at time 21.0 (20.0 plus the periodicity
1230 1.0), we'll be back to the beginning and it will deliver 100 flop/s.
1231
1232 Now let's look at the state file:
1233 \verbatim
1234 PERIODICITY 10.0
1235 1.0 -1.0
1236 2.0 1.0
1237 \endverbatim
1238
1239 A negative value means "off" while a positive one means "on". At time
1240 1.0, the host is on. At time 1.0, it is turned off and at time 2.0, it
1241 is turned on again until time 12 (2.0 plus the periodicity 10.0). It
1242 will be turned on again at time 13.0 until time 23.0, and so on.
1243
1244 Now, let's look how the same kind of thing can be done for network
1245 links. A usual declaration looks like:
1246
1247 \verbatim
1248   <link id="LinkA" bandwidth="10.0" latency="0.2"/>
1249 \endverbatim
1250
1251 You have at your disposal the following options: bandwidth_file,
1252 latency_file and state_file. The only difference with hosts is that
1253 bandwidth_file and latency_file do not express fraction of available
1254 power but are expressed directly in bytes per seconds and seconds.
1255
1256 \subsubsection faq_platform_multipath How to express multipath routing in platform files?
1257
1258 It is unfortunately impossible to express the fact that there is more
1259 than one routing path between two given hosts. Let's consider the
1260 following platform file:
1261
1262 \verbatim
1263 <route src="A" dst="B">
1264    <link:ctn id="1"/>
1265 </route>
1266 <route src="B" dst="C">
1267   <link:ctn id="2"/>
1268 </route>
1269 <route src="A" dst="C">
1270   <link:ctn id="3"/>
1271 </route>
1272 \endverbatim
1273
1274 Although it is perfectly valid, it does not mean that data traveling
1275 from A to C can either go directly (using link 3) or through B (using
1276 links 1 and 2). It simply means that the routing on the graph is not
1277 trivial, and that data do not following the shortest path in number of
1278 hops on this graph. Another way to say it is that there is no implicit
1279 in these routing descriptions. The system will only use the routes you
1280 declare (such as &lt;route src="A" dst="C"&gt;&lt;link:ctn
1281 id="3"/&gt;&lt;/route&gt;), without trying to build new routes by aggregating
1282 the provided ones.
1283   
1284 You are also free to declare platform where the routing is not
1285 symmetric. For example, add the following to the previous file:
1286
1287 \verbatim
1288 <route src="C" dst="A">
1289   <link:ctn id="2"/>
1290   <link:ctn id="1"/>
1291 </route>
1292 \endverbatim
1293
1294 This makes sure that data from C to A go through B where data from A
1295 to C go directly. Don't worry about realism of such settings since
1296 we've seen ways more weird situation in real settings (in fact, that's
1297 the realism of very regular platforms which is questionable, but
1298 that's another story).
1299
1300 \subsubsection faq_flexml_bypassing Bypassing the XML parser with your own C functions
1301
1302 So you want to bypass the XML files parser, uh? Maybe doing some parameter
1303 sweep experiments on your simulations or so? This is possible, and
1304 it's not even really difficult (well. Such a brutal idea could be
1305 harder to implement). Here is how it goes.
1306
1307 For this, you have to first remember that the XML parsing in SimGrid is done
1308 using a tool called FleXML. Given a DTD, this gives a flex-based parser. If
1309 you want to bypass the parser, you need to provide some code mimicking what
1310 it does and replacing it in its interactions with the SURF code. So, let's
1311 have a look at these interactions.
1312
1313 FleXML parser are close to classical SAX parsers. It means that a
1314 well-formed SimGrid platform XML file might result in the following
1315 "events":
1316
1317   - start "platform_description" with attribute version="2"
1318   - start "host" with attributes id="host1" power="1.0"
1319   - end "host"
1320   - start "host" with attributes id="host2" power="2.0"
1321   - end "host"
1322   - start "link" with ...
1323   - end "link"
1324   - start "route" with ...
1325   - start "link:ctn" with ...
1326   - end "link:ctn"
1327   - end "route"
1328   - end "platform_description"
1329
1330 The communication from the parser to the SURF code uses two means:
1331 Attributes get copied into some global variables, and a surf-provided
1332 function gets called by the parser for each event. For example, the event
1333   - start "host" with attributes id="host1" power="1.0"
1334
1335 let the parser do something roughly equivalent to:
1336 \verbatim
1337   strcpy(A_host_id,"host1");
1338   A_host_power = 1.0;
1339   STag_host();
1340 \endverbatim
1341
1342 In SURF, we attach callbacks to the different events by initializing the
1343 pointer functions to some the right surf functions. Since there can be
1344 more than one callback attached to the same event (if more than one
1345 model is in use, for example), they are stored in a dynar. Example in
1346 workstation_ptask_L07.c:
1347 \verbatim
1348   /* Adding callback functions */
1349   surf_parse_reset_parser();
1350   surfxml_add_callback(STag_surfxml_host_cb_list, &parse_cpu_init);
1351   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
1352   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
1353   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
1354   surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
1355   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
1356                 
1357   /* Parse the file */
1358   surf_parse_open(file);
1359   xbt_assert(!surf_parse(), "Parse error in %s", file);
1360   surf_parse_close();
1361 \endverbatim
1362     
1363 So, to bypass the FleXML parser, you need to write your own version of the
1364 surf_parse function, which should do the following:
1365    - Fill the A_<tag>_<attribute> variables with the wanted values
1366    - Call the corresponding STag_<tag>_fun function to simulate tag start
1367    - Call the corresponding ETag_<tag>_fun function to simulate tag end
1368    - (do the same for the next set of values, and loop)
1369
1370 Then, tell SimGrid that you want to use your own "parser" instead of the stock one:
1371 \verbatim
1372   surf_parse = surf_parse_bypass_environment;
1373   MSG_create_environment(NULL);
1374   surf_parse = surf_parse_bypass_application;
1375   MSG_launch_application(NULL);
1376 \endverbatim
1377
1378 A set of macros are provided at the end of
1379 include/surf/surfxml_parse.h to ease the writing of the bypass
1380 functions. An example of this trick is distributed in the file
1381 examples/msg/masterslave/masterslave_bypass.c
1382
1383 \subsection faq_simgrid_configuration Changing SimGrid's behavior
1384
1385 A number of options can be given at runtime to change the default
1386 SimGrid behavior. In particular, you can change the default cpu and
1387 network models...
1388
1389 \subsubsection faq_simgrid_configuration_fullduplex Using Fullduplex
1390
1391 Experimental fullduplex support is now available on the svn branch. In order to fullduple to work your platform must have two links for each pair
1392 of interconnected hosts, see an example here:
1393 \verbatim
1394         simgrid_svn_sources/exemples/msg/gtnets/fullduplex-p.xml
1395 \endverbatim
1396
1397 Using fullduplex support ongoing and incoming communication flows are
1398 treated independently for most models. The exception is the LV08 model which 
1399 adds 0.05 of usage on the opposite direction for each new created flow. This 
1400 can be useful to simulate some important TCP phenomena such as ack compression. 
1401
1402 Running a fullduplex example:
1403 \verbatim
1404         cd simgrid_svn_sources/exemples/msg/gtnets
1405         ./gtnets fullduplex-p.xml fullduplex-d.xml --cfg=fullduplex:1
1406 \endverbatim
1407
1408
1409
1410
1411
1412 \subsubsection faq_simgrid_configuration_gtnets Using GTNetS
1413
1414 It is possible to use a packet-level network simulator
1415 instead of the default flow-based simulation. You may want to use such
1416 an approach if you have doubts about the validity of the default model
1417 or if you want to perform some validation experiments. At the moment,
1418 we support the GTNetS simulator (it is still rather experimental
1419 though, so leave us a message if you play with it). 
1420
1421
1422 <i>
1423 To enable GTNetS model inside SimGrid it is needed to patch the GTNetS simulator source code 
1424 and build/install it from scratch
1425 </i>
1426
1427  - <b>Download and enter the recent downloaded GTNetS directory</b>
1428
1429  \verbatim
1430  svn checkout svn://scm.gforge.inria.fr/svn/simgrid/contrib/trunk/GTNetS/
1431  cd GTNetS
1432  \endverbatim
1433
1434
1435  - <b>Use the following commands to unzip and patch GTNetS package to work within SimGrid.</b>
1436
1437  \verbatim
1438  unzip gtnets-current.zip
1439  tar zxvf gtnets-current-patch.tgz 
1440  cd gtnets-current
1441  cat ../00*.patch | patch -p1
1442  \endverbatim
1443
1444   - <b>OPTIONALLY</b> you can use a patch for itanium 64bit processor family.
1445
1446   \verbatim
1447   cat ../AMD64-FATAL-Removed-DUL_SIZE_DIFF-Added-fPIC-compillin.patch | patch -p1
1448   \endverbatim
1449
1450  - <b>Compile GTNetS</b>
1451
1452    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. 
1453
1454
1455  \verbatim
1456  ln -sf Makefile.linux Makefile
1457  make depend
1458  make debug
1459  \endverbatim
1460
1461
1462  - <b>NOTE</b> A lot of warnings are expected but the application should compile
1463  just fine. If the makefile insists in compiling some QT libraries
1464  please try a make clean before asking for help.
1465
1466
1467  - <b>To compile optimized version</b>
1468
1469  \verbatim
1470  make opt
1471  \endverbatim
1472
1473
1474  - <b>Installing GTNetS</b>
1475
1476  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.
1477
1478  \verbatim
1479  ln -sf /<absolute_path>/gtnets_current/libgtsim-debug.so /<userhome>/usr/lib/libgtnets.so
1480  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/<userhome>/usr/lib/libgtnets.so
1481  mkdir /<userhome>/usr/include/gtnets
1482  cp -fr SRC/*.h /<userhome>/usr/include/gtnets
1483  \endverbatim
1484
1485
1486  - <b>Enable GTNetS support in SimGrid</b>
1487  
1488 In order to enable gtnets with simgrid you have to give where is gtnets. (path to \<gtnets_path\>/lib and \<gtnets_path\>/include)
1489
1490    \verbatim
1491    Since v3.4 (with cmake)
1492    cmake . -Dgtnets_path=/<userhome>/usr
1493    
1494    Until v3.4 (with autotools)
1495    ./configure --with-gtnets=/<userhome>/usr
1496    \endverbatim
1497
1498  - <b>Once you have followed all the instructions for compiling and
1499    installing successfully you can activate this feature at 
1500    runntime with the following options:</b>
1501
1502    \verbatim
1503    Since v3.4 (with cmake)
1504    cd simgrid
1505    make
1506    ctest -R gtnets
1507    
1508    Until v3.4 (with autotools)
1509    cd simgrid/example/msg/
1510    make
1511    make check
1512    \endverbatim
1513
1514
1515  - <b>Or try the GTNetS model dogbone example with</b>
1516
1517  \verbatim
1518  gtnets/gtnets gtnets/onelink-p.xml gtnets/onelink-d.xml --cfg=network_model:GTNets
1519  \endverbatim
1520
1521  
1522  A long version of this <a href="http://gforge.inria.fr/docman/view.php/12/6283/GTNetS HowTo.html">HowTo</a>  it is available 
1523
1524
1525  More about GTNetS simulator at <a href="http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/index.html">GTNetS Website</a>
1526
1527
1528  - <b>DISCLAIMER</b>
1529  The patches provided by us worked successfully with GTNetS found 
1530  <a href="http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/software/gtnets-current.zip">here</a>, 
1531  dated from 12th June 2008. Due to the discontinuing development of
1532  GTNetS it is impossible to precise a version number. We STRONGLY recommend you
1533  to download and install the GTNetS version found in SimGrid repository as explained above.
1534  
1535
1536
1537
1538 \subsubsection faq_simgrid_configuration_alternate_network Using alternative flow models
1539
1540 The default simgrid network model uses a max-min based approach as
1541 explained in the research report
1542 <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>.
1543 Other models have been proposed and implemented since then (see for example 
1544 <a href="http://mescal.imag.fr/membres/arnaud.legrand/articles/simutools09.pdf">Accuracy Study and Improvement of Network Simulation in the SimGrid Framework</a>)
1545 and can be activated at runtime. For example:
1546 \verbatim
1547 ./mycode platform.xml deployment.xml --cfg=workstation/model:compound --cfg=network/model:LV08 -cfg=cpu/model:Cas01
1548 \endverbatim
1549
1550 Possible models for the network are currently "Constant", "CM02",
1551 "LegrandVelho", "GTNets", Reno", "Reno2", "Vegas". Others will
1552 probably be added in the future and many of the previous ones are
1553 experimental and are likely to disappear without notice... To know the
1554 list of the currently  implemented models, you should use the
1555 --help-models command line option.
1556
1557 \verbatim
1558 ./masterslave_forwarder ../small_platform.xml deployment_masterslave.xml  --help-models
1559 Long description of the workstation models accepted by this simulator:
1560   CLM03: Default workstation model, using LV08 and CM02 as network and CPU
1561   compound: Workstation model allowing you to use other network and CPU models
1562   ptask_L07: Workstation model with better parallel task modeling
1563 Long description of the CPU models accepted by this simulator:
1564   Cas01_fullupdate: CPU classical model time=size/power
1565   Cas01: Variation of Cas01_fullupdate with partial invalidation optimization of lmm system. Should produce the same values, only faster
1566   CpuTI: Variation of Cas01 with also trace integration. Should produce the same values, only faster if you use availability traces
1567 Long description of the network models accepted by this simulator:
1568   Constant: Simplistic network model where all communication take a constant time (one second)
1569   CM02: Realistic network model with lmm_solve and no correction factors
1570   LV08: Realistic network model with lmm_solve and these correction factors: latency*=10.4, bandwidth*=.92, S=8775
1571   Reno: Model using lagrange_solve instead of lmm_solve (experts only)
1572   Reno2: Model using lagrange_solve instead of lmm_solve (experts only)
1573   Vegas: Model using lagrange_solve instead of lmm_solve (experts only)
1574 \endverbatim
1575
1576 \subsection faq_tracing Tracing Simulations for Visualization
1577
1578 The trace visualization is widely used to observe and understand the behavior
1579 of parallel applications and distributed algorithms. Usually, this is done in a
1580 two-step fashion: the user instruments the application and the traces are
1581 analyzed after the end of the execution. The visualization itself can highlights
1582 unexpected behaviors, bottlenecks and sometimes can be used to correct
1583 distributed algorithms. The SimGrid team has instrumented the library
1584 in order to let users trace their simulations and analyze them. This part of the
1585 user manual explains how the tracing-related features can be enabled and used
1586 during the development of simulators using the SimGrid library.
1587
1588 \subsubsection faq_tracing_howitworks How it works
1589
1590 For now, the SimGrid library is instrumented so users can trace the <b>platform
1591 utilization</b> using the MSG, SimDAG and SMPI interface. This means that the tracing will
1592 register how much power is used for each host and how much bandwidth is used for
1593 each link of the platform. The idea with this type of tracing is to observe the
1594 overall view of resources utilization in the first place, especially the
1595 identification of bottlenecks, load-balancing among hosts, and so on.
1596
1597 The idea of the tracing facilities is to give SimGrid users to possibility to
1598 classify MSG and SimDAG tasks by category, tracing the platform utilization
1599 (hosts and links) for each of the categories. For that,
1600 the tracing interface enables the declaration of categories and a function to
1601 mark a task with a previously declared category. <em>The tasks that are not
1602 classified according to a category are not traced</em>. Even if the user
1603 does not specify any category, the simulations can still be traced in terms
1604 of resource utilization by using a special parameter that is detailed below.
1605
1606 \subsubsection faq_tracing_enabling Enabling using CMake
1607
1608 With the sources of SimGrid, it is possible to enable the tracing 
1609 using the parameter <b>-Denable_tracing=ON</b> when the cmake is executed.
1610 The section \ref faq_tracing_functions describes all the functions available
1611 when this Cmake options is activated. These functions will have no effect
1612 if SimGrid is configured without this option (they are wiped-out by the
1613 C-preprocessor).
1614
1615 \verbatim
1616 $ cmake -Denable_tracing=ON .
1617 $ make
1618 \endverbatim
1619
1620 \subsubsection faq_tracing_functions Tracing Functions
1621
1622 \li <b>\c TRACE_category (const char *category)</b>: This function should be used
1623 to define a user category. The category can be used to differentiate the tasks
1624 that are created during the simulation (for example, tasks from server1,
1625 server2, or request tasks, computation tasks, communication tasks).
1626 All resource utilization (host power and link bandwidth) will be
1627 classified according to the task category. Tasks that do not belong to a
1628 category are not traced. The color for the category that is being declared
1629 is random (use next function to specify a color).
1630
1631 \li <b>\c TRACE_category_with_color (const char *category, const char *color)</b>: Same
1632 as TRACE_category, but let user specify a color encoded as a RGB-like string with
1633 three floats from 0 to 1. So, to specify a red color, the user can pass "1 0 0" as
1634 color parameter. A light-gray color can be specified using "0.7 0.7 0.7" as color.
1635
1636 \li <b>\c TRACE_msg_set_task_category (m_task_t task, const char *category)</b>:
1637 This function should be called after the creation of a MSG task, to define the
1638 category of that task. The first parameter \c task must contain a task that was
1639 created with the function \c MSG_task_create. The second parameter
1640 \c category must contain a category that was previously defined by the function
1641 \c TRACE_category.
1642
1643 \li <b>\c TRACE_sd_set_task_category (SD_task_t task, const char *category)</b>:
1644 This function should be called after the creation of a SimDAG task, to define the
1645 category of that task. The first parameter \c task must contain a task that was
1646 created with the function \c MSG_task_create. The second parameter
1647 \c category must contain a category that was previously defined by the function
1648 \c TRACE_category.
1649
1650 \li <b>\c TRACE_[host|link]_variable_declare (const char *variable)</b>:
1651 Declare a user variable that will be associated to host/link. A variable can
1652 be used to trace user variables such as the number of tasks in a server,
1653 the number of clients in an application (for hosts), and so on.
1654
1655 \li <b>\c TRACE_[host|link]_variable_[set|add|sub] (const char *[host|link], const char *variable, double value)</b>:
1656 Set the value of a given user variable for a given host/link. The value
1657 of this variable is always associated to the host/link. The host/link 
1658 parameters should be its name as the one listed in the platform file.
1659
1660 \li <b>\c TRACE_[host|link]_variable_[set|add|sub]_with_time (double time, const char *[host|link], const char *variable, double value)</b>:
1661 Same as TRACE_[host|link]_variable_[set|add|sub], but let user specify
1662 the time used to trace it. Users can specify a time that is not the 
1663 simulated clock time as defined by the core simulator. This allows
1664 a fine-grain control of time definition, but should be used with 
1665 caution since the trace can be inconsistent if resource utilization
1666 traces are also traced.
1667
1668 \li <b>\c TRACE_link_srcdst_variable_[set|add|sub] (const char *src, const char *dst, const char *variable, double value)</b>:
1669 Same as TRACE_link_variable_[set|add|sub], but now users specify a source and
1670 destination hosts (as the names from the platform file). The tracing library
1671 will get the corresponding route that connects those two hosts (src and dst) and
1672 [set|add|sub] the value's variable for all the links of the route.
1673
1674 \li <b>\c TRACE_link_srcdst_variable_[set|add|sub]_with_time (double time, const char *src, const char *dst, const char *variable, double value)</b>: 
1675 Same as TRACE_link_srcdst_variable_[set|add|sub], but user specify a time different from the simulated time.
1676
1677 \subsubsection faq_tracing_options Tracing configuration Options
1678
1679 These are the options accepted by the tracing system of SimGrid:
1680
1681 \li <b>\c 
1682 tracing
1683 </b>:
1684   Safe switch. It activates (or deactivates) the tracing system.
1685   No other tracing options take effect if this one is not activated.
1686
1687 \li <b>\c
1688 tracing/platform
1689 </b>:
1690   Register the simulation platform in the trace file.
1691
1692 \li <b>\c
1693 tracing/onelink_only
1694 </b>:
1695   By default, the tracing system uses all routes in the platform file
1696   to re-create a "graph" of the platform and register it in the trace file.
1697   This option let the user tell the tracing system to use only the routes
1698   that are composed with just one link.
1699
1700 \li <b>\c 
1701 tracing/categorized
1702 </b>:
1703   It activates the categorized resource utilization tracing. It should
1704   be enabled if tracing categories are used by this simulator.
1705
1706 \li <b>\c 
1707 tracing/uncategorized
1708 </b>:
1709   It activates the uncategorized resource utilization tracing. Use it if
1710   this simulator do not use tracing categories and resource use have to be
1711   traced.
1712
1713 \li <b>\c 
1714 tracing/filename
1715 </b>:
1716   A file with this name will be created to register the simulation. The file
1717   is in the Paje format and can be analyzed using Triva or Paje visualization
1718   tools. More information can be found in these webpages:
1719      <a href="http://triva.gforge.inria.fr/">http://triva.gforge.inria.fr/</a>
1720      <a href="http://paje.sourceforge.net/">http://paje.sourceforge.net/</a>
1721
1722 \li <b>\c 
1723 tracing/smpi
1724 </b>:
1725   This option only has effect if this simulator is SMPI-based. Traces the MPI
1726   interface and generates a trace that can be analyzed using Gantt-like
1727   visualizations. Every MPI function (implemented by SMPI) is transformed in a
1728   state, and point-to-point communications can be analyzed with arrows.
1729
1730 \li <b>\c 
1731 tracing/smpi/group
1732 </b>:
1733   This option only has effect if this simulator is SMPI-based. The processes
1734   are grouped by the hosts where they were executed.
1735
1736 \li <b>\c 
1737 tracing/msg/task
1738 </b>:
1739   This option only has effect if this simulator is MSG-based. It traces the
1740   behavior of all categorized MSG tasks, grouping them by hosts.
1741
1742 \li <b>\c 
1743 tracing/msg/process
1744 </b>:
1745   This option only has effect if this simulator is MSG-based. It traces the
1746   behavior of all categorized MSG processes, grouping them by hosts. This option
1747   can be used to track process location if this simulator has process migration.
1748
1749
1750 \li <b>\c 
1751 triva/categorized:graph_categorized.plist
1752 </b>:
1753   This option generates a graph configuration file for Triva considering
1754   categorized resource utilization.
1755
1756 \li <b>\c 
1757 triva/uncategorized:graph_uncategorized.plist
1758 </b>:
1759   This option generates a graph configuration file for Triva considering
1760   uncategorized resource utilization.
1761
1762 \subsubsection faq_tracing_example Example of Instrumentation
1763
1764 A simplified example using the tracing mandatory functions.
1765
1766 \verbatim
1767 int main (int argc, char **argv)
1768 {
1769   MSG_global_init (&argc, &argv);
1770
1771   //(... after deployment ...)
1772
1773   //note that category declaration must be called after MSG_create_environment
1774   TRACE_category_with_color ("request", "1 0 0");
1775   TRACE_category_with_color ("computation", "0.3 1 0.4");
1776   TRACE_category ("finalize");
1777
1778   m_task_t req1 = MSG_task_create("1st_request_task", 10, 10, NULL);
1779   m_task_t req2 = MSG_task_create("2nd_request_task", 10, 10, NULL);
1780   m_task_t req3 = MSG_task_create("3rd_request_task", 10, 10, NULL);
1781   m_task_t req4 = MSG_task_create("4th_request_task", 10, 10, NULL);
1782   TRACE_msg_set_task_category (req1, "request");
1783   TRACE_msg_set_task_category (req2, "request");
1784   TRACE_msg_set_task_category (req3, "request");
1785   TRACE_msg_set_task_category (req4, "request");
1786
1787   m_task_t comp = MSG_task_create ("comp_task", 100, 100, NULL);
1788   TRACE_msg_set_task_category (comp, "computation");
1789
1790   m_task_t finalize = MSG_task_create ("finalize", 0, 0, NULL);
1791   TRACE_msg_set_task_category (finalize, "finalize");
1792
1793   //(...)
1794
1795   MSG_clean();
1796   return 0;
1797 }
1798 \endverbatim
1799
1800 \subsubsection faq_tracing_analyzing Analyzing the SimGrid Traces
1801
1802 The SimGrid library, during an instrumented simulation, creates a trace file in
1803 the Paje file format that contains the platform utilization for the simulation
1804 that was executed. The visualization analysis of this file is performed with the
1805 visualization tool <a href="http://triva.gforge.inria.fr">Triva</a>, with
1806 special configurations tunned to SimGrid needs. This part of the documentation
1807 explains how to configure and use Triva to analyse a SimGrid trace file.
1808
1809 - <b>Installing Triva</b>: the tool is available in the INRIAGforge, 
1810 at <a href="http://triva.gforge.inria.fr">http://triva.gforge.inria.fr</a>.
1811 Use the following command to get the sources, and then check the file
1812 <i>INSTALL</i>. This file contains instructions to install
1813 the tool's dependencies in a Ubuntu/Debian Linux. The tool can also
1814 be compiled in MacOSes natively, check <i>INSTALL.mac</i> file.
1815 \verbatim
1816 $ svn checkout svn://scm.gforge.inria.fr/svn/triva
1817 $ cd triva
1818 $ cat INSTALL
1819 \endverbatim
1820
1821 - <b>Executing Triva</b>: a binary called <i>Triva</i> is available after the
1822   installation (you can execute it passing <em>--help</em> to check its
1823 options). If the triva binary is not available after following the
1824 installation instructions, you may want to execute the following command to
1825 initialize the GNUstep environment variables. We strongly recommend that you
1826 use the latest GNUstep packages, and not the packages available through apt-get
1827 in Ubuntu/Debian packaging systems. If you install GNUstep using the latest
1828 available packages, you can execute this command:
1829 \verbatim
1830 $ source /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
1831 \endverbatim
1832 You should be able to see this output after the installation of triva:
1833 \verbatim
1834 $ ./Triva.app/Triva --help
1835 Usage: Triva [OPTIONS...] TRACE0 [TRACE1]
1836 Trace Analysis through Visualization
1837
1838 TimeInterval
1839     --ti_frequency {double}    Animation: frequency of updates
1840     --ti_hide                  Hide the TimeInterval window
1841     --ti_forward {double}      Animation: value to move time-slice
1842     --ti_apply                 Apply the configuration
1843     --ti_update                Update on slider change
1844     --ti_animate               Start animation
1845     --ti_start {double}        Start of time slice
1846     --ti_size {double}         Size of time slice
1847 Triva
1848     --comparison               Compare Trace Files (Experimental)
1849     --graph                    Configurable Graph
1850     --list                     Print Trace Type Hierarchy
1851     --hierarchy                Export Trace Type Hierarchy (dot)
1852     --stat                     Trace Statistics and Memory Utilization
1853     --instances                List All Trace Entities
1854     --linkview                 Link View (Experimental)
1855     --treemap                  Squarified Treemap
1856     --merge                    Merge Trace Files (Experimental)
1857     --check                    Check Trace File Integrity
1858 GraphConfiguration
1859     --gc_conf {file}           Graph Configuration in Property List Format
1860     --gc_apply                 Apply the configuration
1861     --gc_hide                  Hide the GraphConfiguration window
1862 \endverbatim
1863 Triva expects that the user choose one of the available options 
1864 (currently <em>--graph</em> or <em>--treemap</em> for a visualization analysis)
1865 and the trace file from the simulation.
1866
1867 - <b>Understanding Triva - time-slice</b>: the analysis of a trace file using
1868   the tool always takes into account the concept of the <em>time-slice</em>.
1869 This concept means that what is being visualized in the screen is always
1870 calculated considering a specific time frame, with its beggining and end
1871 timestamp. The time-slice is configured by the user and can be changed
1872 dynamically through the window called <em>Time Interval</em> that is opened
1873 whenever a trace file is being analyzed. The next figure depicts the time-slice
1874 configuration window.
1875 In the top of the window, in the space named <i>Trace Time</i>,
1876 the two fields show the beggining of the trace (which usually starts in 0) and
1877 the end (that depends on the time simulated by SimGrid). The middle of the
1878 window, in the square named <i>Time Slice Configuration</i>, contains the
1879 aspects related to the time-slice, including its <i>start</i> and its
1880 <i>size</i>. The gray rectangle in the bottom of this part indicates the 
1881 <i>current time-slice</i> that is considered for the drawings. If the checkbox 
1882 <i>Update Drawings on Sliders Change</i> is not selected, the button
1883 <i>Apply</i> must be clicked in order to inform triva that the
1884 new time-slice must be considered. The bottom part of the window, in the space
1885 indicated by the square <i>Time Slice Animation</i> can be used to advance
1886 the time-frame automatically. The user configures the amount of time that the
1887 time-frame will forward and how frequent this update will happen. Once this is
1888 configured, the user clicks the <i>Play</i> button in order to see the dynamic
1889 changes on the drawings.
1890 <center>
1891 \htmlonly
1892 <a href="triva-time_interval.png" border=0><img src="triva-time_interval.png" width="50%" border=0></a>
1893 \endhtmlonly
1894 </center>
1895 <b>Remarks:</b> when the trace has too many hosts or links, the computation to
1896 take into account a new time-slice can be expensive. When this happens, the
1897 <i>Frequency</i> parameter, but also updates caused by change on configurations
1898 when the checkbox <i>Update Drawings on Sliders
1899 Change</i> is selected will not be followed.
1900
1901 - <b>Understanding Triva - graph</b>: this part of the documention explains how
1902   to analyze the traces using the graph view of Triva, when the user executes
1903 the tool passing <em>--graph</em> as parameter. Triva opens three windows when
1904 this parameter is used: the <i>Time Interval</i> window (previously described),
1905 the <i>Graph Representation</i> window, and the <em>Graph Configuration</em>
1906 window. The Graph Representation is the window where drawings take place.
1907 Initially, it is completely white waiting for a proper graph configuration input
1908 by the user. We start the description of this type of analysis by describing the
1909 <i>Graph Configuration</i> window (depicted below). By using a particular
1910 configuration, triva
1911 can be used to customize the graph drawing according to
1912 the SimGrid trace that was created with user-specific categories. Before delving
1913 into the details of this customization, let us first explain the major parts of
1914 the graph configuration window. The buttons located in the top-right corner can
1915 be used to delete, copy and create a new configuration. The checkbox in the
1916 top-middle part of the window indicates if the configuration typed in the
1917 textfield is syntactically correct (we are using the non-XML 
1918 <a href="http://en.wikipedia.org/wiki/Property_list">Property List Format</a> to
1919 describe the configuration). The pop-up button located on the top-left corner 
1920 indicates the selected configuration (the user can have multiple graph
1921 configurations). The bottom-left text field contains the name of the current
1922 configuration (updates on this field must be followed by typing enter on the
1923 keyboard to take into account the name change). The bottom-right <em>Apply</em>
1924 button activates the current configuration, resulting on an update on the graph
1925 drawings.
1926 <center>
1927 \htmlonly
1928 <a href="triva-graph_configuration.png" border=0><img src="triva-graph_configuration.png" width="50%" border=0></a>
1929 \endhtmlonly
1930 </center>
1931 <b>Basic SimGrid Configuration</b>: The figure shows in the big textfield the
1932 basic configuration that should be used during the analysis of a SimGrid trace
1933 file. The basic logic of the configuration is as follows:
1934 \verbatim
1935 {
1936   node = (HOST);
1937   edge = (LINK);
1938 \endverbatim
1939 The nodes of the graph will be created based on the <i>node</i> parameter, which
1940 in this case is the different <em>"HOST"</em>s of the platform 
1941 used to simulate. The <i>edge</i> parameter indicates that the edges of the
1942 graph will be created based on the <em>"LINK"</em>s of the platform. After the
1943 definition of these two parameters, the configuration must detail how
1944 <em>HOST</em>s and <em>LINK</em>s should be drawn. For that, the configuration
1945 must have an entry for each of the types used. For <em>HOST</em>, as basic
1946 configuration, we have:
1947 \verbatim
1948   HOST = {
1949     size = power;
1950     scale = global;
1951   };
1952 \endverbatim
1953 The parameter <em>size</em> indicates which variable from the trace file will be
1954 used to define the size of the node HOST in the visualization. If the simulation
1955 was executed with availability traces, the size of the nodes will be changed
1956 according to these traces. The parameter <em>scale</em> indicates if the value
1957 of the variable is <em>global</em> or <em>local</em>. If it is global, the value
1958 will be relative to the power of all other hosts, if it is local, the value will
1959 be relative locally.
1960 For <em>LINK</em> we have:
1961 \verbatim
1962   LINK = {
1963     src = source;
1964     dst = destination;
1965     
1966     size = bandwidth;
1967     scale = global;
1968   };
1969 \endverbatim
1970 For the types specified in the <em>edge</em> parameter (such as <em>LINK</em>),
1971 the configuration must contain two additional parameters: <em>src</em> and
1972 <em>dst</em> that are used to properly identify which nodes this edge is
1973 connecting. The values <em>source</em> and <em>destination</em> are always present
1974 in the SimGrid trace file and should not be changed in the configuration. The
1975 parameter <em>size</em> for the LINK, in this case, is configured as the
1976 variable <em>bandwidth</em>, with a <em>global</em> scale. The scale meaning
1977 here is exactly the same used for nodes. The last parameter is the GraphViz
1978 algorithm used to calculate the position of the nodes in the graph
1979 representation.
1980 \verbatim
1981   graphviz-algorithm = neato;
1982 }
1983 \endverbatim
1984 <b>Customizing the Graph Representation</b>: triva is capable to handle
1985 a customized graph representation based on the variables present in the trace
1986 file. In the case of SimGrid, every time a category is created for tasks, two
1987 variables in the trace file are defined: one to indicate node utilization (how
1988 much power was used by that task category), and another to indicate link
1989 utilization (how much bandwidth was used by that category). For instance, if the
1990 user declares a category named <i>request</i>, there will be variables named
1991 <b>p</b><i>request</i> and a <b>b</b><i>request</i> (<b>p</b> for power and
1992 <b>b</b> for bandwidth). It is important to notice that the variable
1993 <i>prequest</i> in this case is only available for HOST, and
1994 <i>brequest</i> is only available for LINK. <b>Example</b>: suppose there are
1995 two categories for tasks: request and compute. To create a customized graph
1996 representation with a proportional separation of host and link utilization, use
1997 as configuration for HOST and LINK this:
1998 \verbatim
1999   HOST = {
2000     size = power;
2001     scale = global;
2002   
2003     sep_host = {
2004       type = separation;
2005       size = power;
2006       values = (prequest, pcomputation);
2007     };
2008   };
2009
2010   LINK = {
2011     src = source;
2012     dst = destination;
2013     size = bandwidth;
2014     scale = global;
2015
2016     sep_link = {
2017       type = separation;
2018       size = bandwidth;
2019       values = (brequest, bcomputation);
2020     };
2021   };
2022 \endverbatim
2023 Where <i>sep_host</i> contains a composition of type <i>separation</i> where
2024 its max size is the <i>power</i> of the host and the variables <i>prequest</i>
2025 and <i>pcomputation</i> are drawn proportionally to the size of the HOST. And
2026 <i>sep_link</i> is also a separation where max is defined as the
2027 <i>bandwidth</i> of the link, and the variables <i>brequest</i> and
2028 <i>bcomputation</i> are drawn proportionally within a LINK.
2029 <i>This configuration enables the analysis of resource utilization by MSG tasks,
2030 and the identification of load-balancing issues, network bottlenecks, for
2031 instance.</i> \n
2032 <b>Other compositions</b>: besides <i>separation</i>, it is possible to use
2033 other types of compositions, such as gradients, and colors, like this:
2034 \verbatim
2035     gra_host = {
2036       type = gradient;
2037       scale = global;
2038       values = (numberOfTasks);
2039     };
2040     color_host = {
2041       type = color;
2042       values = (is_server);
2043     };
2044 \endverbatim
2045 Where <i>gra_host</i> creates a gradient within a node of the graph, using a
2046 global scale and using as value a variable called <i>numberOfTasks</i>, that
2047 could be declared by the user using the optional tracing functions of SimGrid.
2048 If scale is global, the max and min value for the gradient will be equal to the
2049 max and min numberOfTasks among all hosts, and if scale is local, the max and
2050 min value based on the value of numberOfTasks locally in each host.
2051 And <i>color_host</i> composition draws a square based on a positive value of
2052 the variable <i>is_server</i>, that could also be defined by the user using the
2053 SimGrid tracing functions. \n
2054 <b>The Graph Visualization</b>: The next figure shows a graph visualization of a
2055 given time-slice of the masterslave_forwarder example (present in the SimGrid
2056 sources). The red color indicates tasks from the <i>compute</i> category. This
2057 visualization was generated with the following configuration:
2058 \verbatim
2059 {
2060   node = (HOST);
2061   edge = (LINK);
2062
2063   HOST = {
2064     size = power;
2065     scale = global;
2066   
2067     sep_host = {
2068       type = separation;
2069       size = power;
2070       values = (pcompute, pfinalize);
2071     };
2072   };
2073   LINK = {
2074     src = source;
2075     dst = destination;
2076     size = bandwidth;
2077     scale = global;
2078
2079     sep_link = {
2080       type = separation;
2081       size = bandwidth;
2082       values = (bcompute, bfinalize);
2083     };
2084   };
2085   graphviz-algorithm = neato;
2086 }
2087 \endverbatim
2088 <center>
2089 \htmlonly
2090 <a href="triva-graph_visualization.png" border=0><img src="triva-graph_visualization.png" width="50%" border=0></a>
2091 \endhtmlonly
2092 </center>
2093
2094 - <b>Understading Triva - colors</b>: An important issue when using Triva is how
2095   to define colors. To do that, we have to know which variables are defined in
2096 the trace file generated by the SimGrid library. The parameter <em>--list</em> 
2097 lists the variables for a given trace file:
2098 \verbatim
2099 $ Triva -l masterslave_forwarder.trace
2100 iFile
2101 c  platform
2102 c    HOST
2103 v     power
2104 v     is_slave
2105 v     is_master
2106 v     task_creation
2107 v     task_computation
2108 v     pcompute
2109 v     pfinalize
2110 c    LINK
2111 v     bandwidth
2112 v     latency
2113 v     bcompute
2114 v     bfinalize
2115 c  user_type
2116 \endverbatim
2117 We can see that HOST has seven variables (from power to pfinalize) and LINK has
2118 four (from bandwidth to bfinalize). To define a red color for the
2119 <i>pcompute</i> and <i>bcompute</i> (which are defined based on user category
2120 <i>compute</i>), execute:
2121 \verbatim
2122 $ defaults write Triva 'pcompute Color' '1 0 0'
2123 $ defaults write Triva 'bcompute Color' '1 0 0'
2124 \endverbatim
2125 Where the three numbers in each line are the RGB color with values from 0 to 1.
2126
2127 \subsection faq_modelchecking Model-Checking
2128 \subsubsection faq_modelchecking_howto How to use it
2129 To enable the experimental SimGrid model-checking support the program should
2130 be executed with the command line argument 
2131 \verbatim
2132 --cfg=model-check:1 
2133 \endverbatim
2134 Properties are expressed as assertions using the function
2135 \verbatim
2136 void MC_assert(int prop);
2137 \endverbatim
2138
2139 \subsection faq_binding_lua Lua Binding
2140 Most of Simgrid modules require a  good level in C programming, since simgrid is used to be as standard C library.
2141  Sometime users prefer using some kind of Â«Â easy scripts Â» or a language easier to code with, for their works,
2142  which avoid dealing with C errors, and sometime an important  gain of time.
2143 Besides Java Binding, Lua  and Ruby bindings are available since version 3.4 of Simgrid
2144 for MSG Module, and we are currenlty working on bindings for other modules.
2145
2146
2147 \subsubsection faq_binding_lua_about What is lua ?
2148 Lua is a lightweight, reflective, imperative and functional programming language,
2149  designed as a scripting language with extensible semantics as a primary goal (see official web site <a href="http://www.lua.org">here</a>).
2150 \subsubsection faq_binding_lua_why Why lua ?
2151 Lua is a fast, portable and powerful script language, quite simple to use for developpers.
2152 it combines procedural features with powerful data description facilities,
2153  by using a simple, yet powerful, mechanism of tables.
2154 Lua has a relatively simple C API compared to other scripting languages,
2155 and accordingly it provides a robust, easy to use it.
2156 \subsubsection faq_binding_lua_simgrid How to use lua in Simgrid ?
2157 Actually, the use of lua in Simgrid is quite simple, you have just to follow the same steps as coding with C in Simgird :
2158   - Coding functions coresponding to each process
2159   - loading the platforme/deployment XML file that describe the environment of simulation
2160   - and â€¦ Running the Simulation.
2161   
2162 \dontinclude lua/masterslave/master.lua
2163 \subsubsection faq_binding_lua_example_master_slave Master/Slave Example
2164
2165  \li Master Code
2166  \until end_of_master
2167 we mainly  use   simgrid.Task.new(task_name,computation_size,communication_size) to create our MSG Task, 
2168          then simgrid.Task.send(task,alias) to send it.
2169 we use also simgrid.Task.name(task), to get the task's name. 
2170
2171 \dontinclude lua/masterslave/slave.lua
2172 \li Slave Code
2173 \until end_of_slave
2174 Here, we see the use of simgrid.Task.recv(alias) to receive a task with a specific alias,
2175 this function return directly the task recevied.
2176
2177 \dontinclude lua/masterslave/master_slave.lua
2178 \li Set Environmenet and run application
2179 \until simgrid.clean()
2180
2181 \subsubsection faq_binding_lua_example_data Exchanging Data
2182 You can also exchange data between Process using lua. for that, you have to deal with lua task as a table,
2183 since lua is based itself on a mechanism of tables,
2184 so you can exchange any kind of data (tables, matrix, strings,…) between process via tasks.
2185
2186 \li Sender process
2187 \verbatim 
2188   task = simgrid.Task.new("data_task",task_comp,task_comm);
2189   task['matrix'] = my_matrix;
2190   task['table'] = my_table;
2191   task['message'] = "Hello from (Lua || Simgrid ) !! "
2192   â€¦
2193   simgrid.Task.send(task,alias)
2194 \endverbatim
2195         After creating task, we associate to it various kind of data with a specific key (string in this case)
2196         to distinguish between data variables. The receiver will use this key to access easily to datas.
2197
2198
2199 \li Receiver processe
2200 \verbatim
2201   task = simgrid.Task.recv(alias);
2202   sender_matrix = task['matrix'];
2203   sender_table = task['table'];
2204   sender_message = task['message']
2205   ...
2206 \endverbatim
2207         Note that in lua, both sender and receiver share the same lua task.
2208         So that the receiver could joint data directly on the received task without sending it back.
2209         You can find  a complet example (matrix multiplication case) in the file example/lua/mult_matrix.lua. 
2210
2211
2212 \subsubsection faq_binding_lua_example_bypass Bypass XML
2213         maybe you wonder if there is a way to bypass the XML files,
2214          and describe your platform directly from the code, with lua bindings it's Possible !! how ?
2215         We provide some additional (tricky?) functions in lua that allows you to set up your own platform without using the XML files
2216      ( this can be useful for large platforms, so a simple for loop will avoid you to deal with an annoying XML File ;) )
2217      
2218
2219 \li set Routing mode
2220 \verbatim
2221    simgrid.AS.new{id="AS0",mode="Full"};
2222 \endverbatim
2223
2224 \li set Hosts
2225 \verbatim
2226   simgrid.Host.new{id="Tremblay",power=98095000};
2227   simgrid.Host.new{id="Jupiter",power=76296000};
2228   simgrid.Host.new{id="Fafard",power=76296000};
2229   simgrid.Host.new{id="Ginette",power=48492000};
2230   simgrid.Host.new{id="Bourassa",power=48492000};
2231 \endverbatim
2232   we use simgrid.Host.new{id=id_host,power=power_host} to instanciate our hosts.
2233
2234 \li set Links
2235 \verbatim
2236   for i=0,11 do
2237     simgrid.Link.new{id=i,bandwidth=252750+ i*768,latency=0.000270544+i*0.087};    --  some crazy values ;)
2238   end
2239 \endverbatim
2240   we used simgrid.Link.new{id=link_id,bandwidth=bw,latency=lat} with a simple for loop to create all links we need (much easier than XML hein ?)
2241
2242 \li set Routes
2243 \verbatim
2244 -- simgrid.Route.new(src_id,des_id,links_nb,links_list)
2245    simgrid.Route.new("Tremblay","Jupiter",1,{"1"});
2246    simgrid.Route.new("Tremblay","Fafard",6,{"0","1","2","3","4","8"});
2247    simgrid.Route.new("Tremblay","Ginette",3,{"3","4","5"});
2248    simgrid.Route.new("Tremblay","Bourassa",7,{"0","1","3","2","4","6","7"});
2249
2250    simgrid.Route.new("Jupiter","Tremblay",1,{"1"});
2251    simgrid.Route.new("Jupiter","Fafard",7,{"0","1","2","3","4","8","9"});
2252    simgrid.Route.new("Jupiter","Ginette",4,{"3","4","5","9"});
2253    simgrid.Route.new("Jupiter","Bourassa",8,{"0","1","2","3","4","6","7","9"});
2254    ...
2255 \endverbatim
2256   for each host you have to specify which route to choose to access to the rest of hosts connected in the grid.
2257   
2258 \li Save platform
2259 \verbatim
2260   simgrid.register_platform();
2261 \endverbatim
2262 Don't forget to register your platform, that SURF callbacks starts their work ;)
2263
2264 \li set application
2265 \verbatim
2266    simgrid.Host.setFunction("Tremblay","Master",4,{"20","550000000","1000000","4"});
2267    simgrid.Host.setFunction("Bourassa","Slave",1,{"0"});
2268    simgrid.Host.setFunction("Jupiter","Slave",1,{"1"});
2269    simgrid.Host.setFunction("Fafard","Slave",1,{"2"});
2270    simgrid.Host.setFunction("Ginette","Slave",1,{"3"});
2271 \endverbatim
2272   you don't  need to use a deployment XML file, thanks to  simgrid.Host.setFunction(host_id,function,args_number,args_list) 
2273   you can associate functions for each host with arguments if needed .
2274
2275 \li
2276 \verbatim
2277    simgrid.register_application();
2278 \endverbatim
2279 Yes, Here too you have to resgiter your application before running the simulation.
2280
2281 the full example is distributed in the file examples/lua/master_slave_bypass.lua
2282
2283 \subsection faq_binding_ruby Ruby Binding
2284
2285
2286 \subsubsection faq_binding_ruby_simgrid Use Ruby in Simgrid
2287 Since v3.4, the use of <a href="http://ruby-lang.org">ruby</a> in simgrid is available for the MSG Module.
2288 you can find almost all MSG functionalities in Ruby code, that allows you to set up your environment, manage tasks between hosts and run the simulation.
2289
2290 \subsubsection faq_binding_ruby_example Master/Slave Ruby Application
2291 for each process method(master and slave in this example), you have to associate a ruby class, that should inherit from <i>MSG::Process</i> ruby class,
2292   with a 'main' function that describe the behaviour of the process during the simulation.
2293 \li required stuff
2294 \verbatim
2295 require 'simgrid'
2296 include MSG
2297 \endverbatim
2298
2299 \li Master code
2300 \verbatim
2301 class Master < MSG::Process 
2302   # main : that function that will be executed when running simulation
2303
2304   def main(args) # args is an array containing arguments for function master
2305    size = args.size
2306    for i in 0..size-1
2307      MSG::info("args["+String(i)+"]="+args[i])
2308    end
2309   
2310    raise "Master needs 3 arguments" if size < 3 
2311    numberOfTask = Integer(args[0]) 
2312    taskComputeSize = Float(args[1])
2313    taskCommunicationSize = Float(args[2])
2314    slaveCount = Integer(args[3]) 
2315    
2316    # Creates and sends the tasks
2317     for i in 0..numberOfTask-1
2318      task = Task.new("Task_"+ i.to_s, taskComputeSize , taskCommunicationSize);
2319      mailbox = "slave " + (i%slaveCount).to_s
2320      MSG::info("Master Sending "+ task.name + " to " + mailbox + " with Comput Size " + 
2321            task.compSize.to_s)
2322      task.send(mailbox)
2323      MSG::info("Master Done Sending " + task.name + " to " + mailbox)
2324     end
2325   
2326    # Sending Finalize MSG::Tasks
2327    MSG::info("Master: All tasks have been dispatched. Let's tell everybody the computation is over.")
2328    for i in 0..slaveCount-1
2329      mailbox = "slave " + i.to_s
2330      finalize_task = Task.new("finalize",0,0)
2331      finalize_task.send(mailbox)
2332    end
2333    MSG::info("Master : Everything's Done")
2334   end    
2335 end
2336 \endverbatim
2337
2338
2339 the class MSG::Task contains methods that allows the management of the native MSG tasks.
2340 in master ruby code we used : 
2341   - <i>MSG::Task.new(task_name,compute_size,communication_size)</i> : to instanciate a new task.
2342   - <i>MSG::Task.send(mailbox)</i> : to send the task via a mailbox alias.
2343   - <i>MSG::Task.name</i> : to get the task's name.
2344
2345 \li Slave code
2346 \verbatim
2347 class Slave < MSG::Process
2348
2349   def main(args)
2350     mailbox = "slave " + args[0]
2351     for i in 0..args.size-1
2352       MSG::debug("args["+String(i)+"]="+args[i])
2353     end
2354
2355     while true
2356        MSG::info("Slave '"+ mailbox +"' waiting for new task");
2357        task = Task.receive(mailbox)
2358        if (task.name == "finalize")
2359                break
2360        end
2361        task.execute
2362        MSG::info("Slave '" + mailbox + "' done executing task "+ task.name + ".")
2363     end
2364     MSG::info("I'm done, see you")
2365   end
2366 end
2367 \enverbatim
2368 to receive a task, we use the method <i>MSG::Task.receive(mailbox)</i> that return a MSG:Task object (received task).
2369
2370 \li Main chunk
2371
2372 \verbatim
2373 require 'simgrid'
2374 include MSG
2375 (...)
2376
2377 if (ARGV.length == 2) 
2378         MSG.createEnvironment(ARGV[0])
2379         MSG.deployApplication(ARGV[1])
2380
2381 else
2382
2383         MSG.createEnvironment("platform.xml")
2384         MSG.deployApplication("deploy.xml")
2385 end
2386 MSG.run
2387 puts "Simulation time : " + MSG.getClock.to_s
2388 MSG.exit
2389 \endverbatim
2390
2391 - <i>MSG.createEnvironment(platform_file)</i> : set up the environment
2392 - <i>MSG.deployApplication(deployment_file)</i> : load the deployment file description.
2393 - <i>MSG.run</i> : run the simulation
2394
2395 \subsubsection faq_binding_ruby_data Exchanging data 
2396 ruby bindings provides two ways to exchange data between ruby processes.
2397 \li MSG::Task.join & MSG::Task.data <br/>
2398
2399   the MSG::Task class contains 2 methods that allows a data exchange between 2 process.
2400   
2401   -<i>MSG::Task.join</i> : makes possible to join any kind of ruby data within a task.
2402   \verbatim
2403    ...
2404    myTable = Array.new
2405    myTable <<1<<-2<<45<<67<<87<<76<<89<<56<<78<<3<<-4<<99
2406    # Creates and send Task With the Table inside
2407    task = MSG::Task.new("quicksort_task",taskComputeSize, taskCommunicationSize);
2408    task.join(myTable);
2409    ...
2410    task.send(mailbox);
2411    \endverbatim
2412    -<i>MSG::Task.data</i> : to access to the data contained into the task.
2413    \verbatim
2414    ...
2415    task = MSG::Task.receive(recv_mailbox.to_s)
2416    table = task.data
2417    quicksort(table,0,table.size-1)
2418    ...
2419    \endverbatim
2420 you can find a complet example illustrating the use of those methods  in file /example/ruby/Quicksort.rb
2421
2422 \li inheritence 
2423  
2424  another 'object-oriented' way to do it, is to make your own 'task' class that inherit from  MSG::Task ,
2425  and contains data you want to deal with, the only 'tricky' thing is that "the initializer" method has no effect ! 
2426  
2427  the use of some getter/setter methods would be the simple way to manage your data :)
2428  \verbatim
2429 class PingPongTask < MSG::Task
2430   # The initialize method has no effect 
2431   @time 
2432   def setTime(t)
2433     @time = t
2434   end
2435   def getTime()
2436     return @time
2437   end
2438 end
2439  \endverbatim
2440  you can find an example of use in file example/ruby/PingPong.rb
2441
2442 \section faq_troubleshooting Troubleshooting
2443
2444 \subsection faq_trouble_lib_compil SimGrid compilation and installation problems
2445
2446 \subsubsection faq_trouble_lib_config cmake fails!
2447
2448 We know only one reason for the configure to fail:
2449
2450  - <b>You are using a broken build environment</b>\n
2451    If symptom is that the configury magic complains about gcc not being able to build
2452    executables, you are probably missing the libc6-dev package. Damn Ubuntu.
2453
2454 If you experience other kind of issue, please get in touch with us. We are
2455 always interested in improving our portability to new systems.
2456
2457 \subsubsection faq_trouble_distcheck Dude! "ctest" fails on my machine!
2458
2459 Don't assume we never run this target, because we do. Check
2460 http://cdash.inria.fr/CDash/index.php?project=Simgrid (click on
2461 previous if there is no result for today: results are produced only by
2462 11am, French time) and
2463 https://buildd.debian.org/status/logs.php?pkg=simgrid if you don't believe us. 
2464
2465 If it's failing on your machine in a way not experienced by the
2466 autobuilders above, please drop us a mail on the mailing list so that
2467 we can check it out. Make sure to read \ref faq_bugrepport before you
2468 do so.
2469
2470 \subsection faq_trouble_compil User code compilation problems
2471
2472 \subsubsection faq_trouble_err_logcat "gcc: _simgrid_this_log_category_does_not_exist__??? undeclared (first use in this function)"
2473
2474 This is because you are using the log mecanism, but you didn't created
2475 any default category in this file. You should refer to \ref XBT_log
2476 for all the details, but you simply forgot to call one of
2477 XBT_LOG_NEW_DEFAULT_CATEGORY() or XBT_LOG_NEW_DEFAULT_SUBCATEGORY().
2478
2479 \subsubsection faq_trouble_pthreadstatic "gcc: undefined reference to pthread_key_create"
2480
2481 This indicates that one of the library SimGrid depends on (libpthread
2482 here) was missing on the linking command line. Dependencies of
2483 libsimgrid are expressed directly in the dynamic library, so it's
2484 quite impossible that you see this message when doing dynamic linking. 
2485
2486 If you compile your code statically (and if you use a pthread version
2487 of SimGrid -- see \ref faq_more_processes), you must absolutely
2488 specify <tt>-lpthread</tt> on the linker command line. As usual, this should
2489 come after <tt>-lsimgrid</tt> on this command line.
2490
2491 \subsection faq_trouble_errors Runtime error messages
2492
2493 \subsubsection faq_flexml_limit "surf_parse_lex: Assertion `next limit' failed."
2494
2495 This is because your platform file is too big for the parser. 
2496
2497 Actually, the message comes directly from FleXML, the technology on top of
2498 which the parser is built. FleXML has the bad idea of fetching the whole
2499 document in memory before parsing it. And moreover, the memory buffer size
2500 must be determined at compilation time.
2501
2502 We use a value which seems big enough for our need without bloating the
2503 simulators footprints. But of course your mileage may vary. In this case,
2504 just edit src/surf/surfxml.l modify the definition of
2505 FLEXML_BUFFERSTACKSIZE. E.g.
2506
2507 \verbatim
2508 #define FLEXML_BUFFERSTACKSIZE 1000000000
2509 \endverbatim
2510
2511 Then recompile and everything should be fine, provided that your version of
2512 Flex is recent enough (>= 2.5.31). If not the compilation process should
2513 warn you.
2514
2515 A while ago, we worked on FleXML to reduce a bit its memory consumption, but
2516 these issues remain. There is two things we should do:
2517
2518   - use a dynamic buffer instead of a static one so that the only limit
2519     becomes your memory, not a stupid constant fixed at compilation time
2520     (maybe not so difficult).
2521   - change the parser so that it does not need to get the whole file in
2522     memory before parsing
2523     (seems quite difficult, but I'm a complete newbe wrt flex stuff).
2524
2525 These are changes to FleXML itself, not SimGrid. But since we kinda hijacked
2526 the development of FleXML, I can grant you that any patches would be really
2527 welcome and quickly integrated.
2528
2529 <b>Update:</b> A new version of FleXML (1.7) was released. Most of the work
2530 was done by William Dowling, who use it in his own work. The good point is
2531 that it now use a dynamic buffer, and that the memory usage was greatly
2532 improved. The downside is that William also changed some things internally,
2533 and it breaks the hack we devised to bypass the parser, as explained in 
2534 \ref faq_flexml_bypassing. Indeed, this is not a classical usage of the
2535 parser, and Will didn't imagine that we may have used (and even documented)
2536 such a crude usage of FleXML. So, we now have to repair the bypassing
2537 functionality to use the lastest FleXML version and fix the memory usage in
2538 SimGrid.
2539
2540 \subsubsection faq_trouble_gras_transport GRAS spits networking error messages
2541
2542 Gras, on real platforms, naturally use regular sockets to communicate. They
2543 are deeply hidden in the gras abstraction, but when things go wrong, you may
2544 get some weird error messages. Here are some example, with the probable
2545 reason:
2546
2547  - <b>Transport endpoint is not connected</b>: several processes try to open
2548    a server socket on the same port number of the same machine. This is
2549    naturally bad and each process should pick its own port number for this.\n
2550    Maybe, you just have some processes remaining from a previous experiment 
2551    on your machine.\n
2552    Killing them may help, but again if you kill -KILL them, you'll have to
2553    wait for a while: they didn't close there sockets properly and the system
2554    needs a while to notice that this port is free again.
2555
2556  - <b>Socket closed by remote side</b>: if the remote process is not
2557    supposed to close the socket at this point, it may be dead.
2558    
2559  - <b>Connection reset by peer</b>: I found this on Internet about this
2560    error. I think it's what's happening here, too:\n   
2561    <i>This basically means that a network error occurred while the client was
2562    receiving data from the server. But what is really happening is that the
2563    server actually accepts the connection, processes the request, and sends
2564    a reply to the client. However, when the server closes the socket, the
2565    client believes that the connection has been terminated abnormally
2566    because the socket implementation sends a TCP reset segment telling the
2567    client to throw away the data and report an error.\n
2568    Sometimes, this problem is caused by not properly closing the
2569    input/output streams and the socket connection. Make sure you close the
2570    input/output streams and socket connection properly. If everything is
2571    closed properly, however, and the problem persists, you can work around
2572    it by adding a one-second sleep before closing the streams and the
2573    socket. This technique, however, is not reliable and may not work on all
2574    systems.</i>\n
2575    Since GRAS sockets are closed properly (repeat after me: there is no bug
2576    in GRAS), it is either that you are closing your sockets on server side
2577    before the client get a chance to read them (use gras_os_sleep() to delay
2578    the server), or the server died awfully before the client got the data.
2579
2580 \subsubsection faq_trouble_errors_big_fat_warning I'm told that my XML files are too old.
2581
2582 The format of the XML platform description files is sometimes
2583 improved. For example, we decided to change the units used in SimGrid
2584 from MBytes, MFlops and seconds to Bytes, Flops and seconds to ease
2585 people exchanging small messages. We also reworked the route
2586 descriptions to allow more compact descriptions.
2587
2588 That is why the XML files are versionned using the 'version' attribute
2589 of the root tag. Currently, it should read:
2590 \verbatim
2591   <platform version="2">
2592 \endverbatim
2593
2594 If your files are too old, you can use the simgrid_update_xml.pl
2595 script which can be found in the tools directory of the archive.
2596
2597 \subsection faq_trouble_valgrind Valgrind-related and other debugger issues
2598
2599 If you don't, you really should use valgrind to debug your code, it's
2600 almost magic.
2601
2602 \subsubsection faq_trouble_vg_longjmp longjmp madness in valgrind
2603
2604 This is when valgrind starts complaining about longjmp things, just like:
2605
2606 \verbatim ==21434== Conditional jump or move depends on uninitialised value(s)
2607 ==21434==    at 0x420DBE5: longjmp (longjmp.c:33)
2608 ==21434==
2609 ==21434== Use of uninitialised value of size 4
2610 ==21434==    at 0x420DC3A: __longjmp (__longjmp.S:48)
2611 \endverbatim
2612
2613 This is the sign that you didn't used the exception mecanism well. Most
2614 probably, you have a <tt>return;</tt> somewhere within a <tt>TRY{}</tt>
2615 block. This is <b>evil</b>, and you must not do this. Did you read the section
2616 about \ref XBT_ex??
2617
2618 \subsubsection faq_trouble_vg_libc Valgrind spits tons of errors about backtraces!
2619
2620 It may happen that valgrind, the memory debugger beloved by any decent C
2621 programmer, spits tons of warnings like the following :
2622 \verbatim ==8414== Conditional jump or move depends on uninitialised value(s)
2623 ==8414==    at 0x400882D: (within /lib/ld-2.3.6.so)
2624 ==8414==    by 0x414EDE9: (within /lib/tls/i686/cmov/libc-2.3.6.so)
2625 ==8414==    by 0x400B105: (within /lib/ld-2.3.6.so)
2626 ==8414==    by 0x414F937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
2627 ==8414==    by 0x4150F4C: (within /lib/tls/i686/cmov/libc-2.3.6.so)
2628 ==8414==    by 0x400B105: (within /lib/ld-2.3.6.so)
2629 ==8414==    by 0x415102D: __libc_dlopen_mode (in /lib/tls/i686/cmov/libc-2.3.6.so)
2630 ==8414==    by 0x412D6B9: backtrace (in /lib/tls/i686/cmov/libc-2.3.6.so)
2631 ==8414==    by 0x8076446: xbt_dictelm_get_ext (dict_elm.c:714)
2632 ==8414==    by 0x80764C1: xbt_dictelm_get (dict_elm.c:732)
2633 ==8414==    by 0x8079010: xbt_cfg_register (config.c:208)
2634 ==8414==    by 0x806821B: MSG_config (msg_config.c:42)
2635 \endverbatim
2636
2637 This problem is somewhere in the libc when using the backtraces and there is
2638 very few things we can do ourselves to fix it. Instead, here is how to tell
2639 valgrind to ignore the error. Add the following to your ~/.valgrind.supp (or
2640 create this file on need). Make sure to change the obj line according to
2641 your personnal mileage (change 2.3.6 to the actual version you are using,
2642 which you can retrieve with a simple "ls /lib/ld*.so").
2643
2644 \verbatim {
2645    name: Backtrace madness
2646    Memcheck:Cond
2647    obj:/lib/ld-2.3.6.so
2648    fun:dl_open_worker
2649    fun:_dl_open
2650    fun:do_dlopen
2651    fun:dlerror_run
2652    fun:__libc_dlopen_mode
2653 }\endverbatim
2654
2655 Then, you have to specify valgrind to use this suppression file by passing
2656 the <tt>--suppressions=$HOME/.valgrind.supp</tt> option on the command line.
2657 You can also add the following to your ~/.bashrc so that it gets passed
2658 automatically. Actually, it passes a bit more options to valgrind, and this
2659 happen to be my personnal settings. Check the valgrind documentation for
2660 more information.
2661
2662 \verbatim export VALGRIND_OPTS="--leak-check=yes --leak-resolution=high --num-callers=40 --tool=memcheck --suppressions=$HOME/.valgrind.supp" \endverbatim
2663
2664 \subsubsection faq_trouble_backtraces Truncated backtraces
2665
2666 When debugging SimGrid, it's easier to pass the
2667 --disable-compiler-optimization flag to the configure if valgrind or
2668 gdb get fooled by the optimization done by the compiler. But you
2669 should remove these flag when everything works before going in
2670 production (before launching your 1252135 experiments), or everything
2671 will run only one half of the true SimGrid potential.
2672
2673 \subsection faq_deadlock There is a deadlock in my code!!!
2674
2675 Unfortunately, we cannot debug every code written in SimGrid.  We
2676 furthermore believe that the framework provides ways enough
2677 information to debug such informations yourself. If the textual output
2678 is not enough, Make sure to check the \ref faq_visualization FAQ entry to see
2679 how to get a graphical one.
2680
2681 Now, if you come up with a really simple example that deadlocks and
2682 you're absolutely convinced that it should not, you can ask on the
2683 list. Just be aware that you'll be severely punished if the mistake is
2684 on your side... We have plenty of FAQ entries to redact and new
2685 features to implement for the impenitents! ;)
2686
2687 \subsection faq_surf_network_latency I get weird timings when I play with the latencies.
2688
2689 OK, first of all, remember that units should be Bytes, Flops and
2690 Seconds. If you don't use such units, some SimGrid constants (e.g. the
2691 SG_TCP_CTE_GAMMA constant used in most network models) won't have the
2692 right unit and you'll end up with weird results.
2693
2694 Here is what happens with a single transfer of size L on a link
2695 (bw,lat) when nothing else happens.
2696
2697 \verbatim
2698 0-----lat--------------------------------------------------t
2699 |-----|**** real_bw =min(bw,SG_TCP_CTE_GAMMA/(2*lat)) *****|
2700 \endverbatim
2701
2702 In more complex situations, this min is the solution of a complex
2703 max-min linear system.  Have a look 
2704 <a href="http://lists.gforge.inria.fr/pipermail/simgrid-devel/2006-April/thread.html">here</a>
2705 and read the two threads "Bug in SURF?" and "Surf bug not
2706 fixed?". You'll have a few other examples of such computations. You
2707 can also read "A Network Model for Simulation of Grid Application" by
2708 Henri Casanova and Loris Marchal to have all the details. The fact
2709 that the real_bw is smaller than bw is easy to understand. The fact
2710 that real_bw is smaller than SG_TCP_CTE_GAMMA/(2*lat) is due to the
2711 window-based congestion mechanism of TCP. With TCP, you can't exploit
2712 your huge network capacity if you don't have a good round-trip-time
2713 because of the acks...
2714
2715 Anyway, what you get is t=lat + L/min(bw,SG_TCP_CTE_GAMMA/(2*lat)).
2716
2717   * if I you set (bw,lat)=(100 000 000, 0.00001), you get t =  1.00001 (you fully
2718 use your link)
2719   * if I you set (bw,lat)=(100 000 000, 0.0001),  you get t =  1.0001 (you're on the
2720 limit)
2721   * if I you set (bw,lat)=(100 000 000, 0.001),   you get t = 10.001  (ouch!)
2722
2723 This bound on the effective bandwidth of a flow is not the only thing
2724 that may make your result be unexpected. For example, two flows
2725 competing on a saturated link receive an amount of bandwidth inversely
2726 proportional to their round trip time.
2727
2728 \subsection faq_bugrepport So I've found a bug in SimGrid. How to report it?
2729
2730 We do our best to make sure to hammer away any bugs of SimGrid, but this is
2731 still an academic project so please be patient if/when you find bugs in it.
2732 If you do, the best solution is to drop an email either on the simgrid-user
2733 or the simgrid-devel mailing list and explain us about the issue.  You can
2734 also decide to open a formal bug report using the
2735 <a href="https://gforge.inria.fr/tracker/?atid=165&group_id=12&func=browse">relevant
2736 interface</a>. You need to login on the server to get the ability to submit
2737 bugs. 
2738
2739 We will do our best to solve any problem repported, but you need to help us
2740 finding the issue. Just telling "it segfault" isn't enough. Telling "It
2741 segfaults when running the attached simulator" doesn't really help either.
2742 You may find the following article interesting to see how to repport
2743 informative bug repports:
2744 http://www.chiark.greenend.org.uk/~sgtatham/bugs.html (it is not SimGrid
2745 specific at all, but it's full of good advices).
2746
2747 \author Arnaud Legrand (arnaud.legrand::imag.fr)
2748 \author Martin Quinson (martin.quinson::loria.fr)
2749
2750
2751 */
2752
2753 ******************************************************************
2754 *              OLD CRUFT NOT USED ANYMORE                        *
2755 ******************************************************************
2756
2757
2758 \subsection faq_crosscompile Cross-compiling a Windows DLL of SimGrid from linux
2759
2760 At the moment, we do not distribute Windows pre-compiled version of SimGrid
2761 because the support for this platform is still experimental. We know that
2762 some parts of the GRAS environment do not work, and we think that the others
2763 environments (MSG and SD) have good chances to work, but we didn't test
2764 ourselves. This section explains how we generate the SimGrid DLL so that you
2765 can build it for yourself. First of all, you need to have a version more
2766 recent than 3.1 (ie, a SVN version as time of writting).
2767
2768 In order to cross-compile the package to windows from linux, you need to
2769 install mingw32 (minimalist gnu win32). On Debian, you can do so by
2770 installing the packages mingw32 (compiler), mingw32-binutils (linker and
2771 so), mingw32-runtime.
2772
2773 You can use the VPATH support of configure to compile at the same time for
2774 linux and windows without dupplicating the source nor cleaning the tree
2775 between each. Just run bootstrap (if you use the SVN) to run the autotools.
2776 Then, create a linux and a win directories. Then, type:
2777 \verbatim  cd linux; ../configure --srcdir=.. <usual configure flags>; make; cd ..
2778 cd win;  ../configure --srcdir=.. --host=i586-mingw32msvc <flags>; make; cd ..
2779 \endverbatim
2780 The trick to VPATH builds is to call configure from another directory,
2781 passing it an extra --srcdir argument to tell it where all the sources are.
2782 It will understand you want to use VPATH. Then, the trick to cross-compile
2783 is simply to add a --host argument specifying the target you want to build
2784 for. The i586-mingw32msvc string is what you have to pass to use the mingw32
2785 environment as distributed in Debian.
2786
2787 After that, you can run all make targets from both directories, and test
2788 easily that what you change for one arch does not break the other one. 
2789
2790 It is possible that this VPATH build thing breaks from time to time in the
2791 SVN since it's quite fragile, but it's granted to work in any released
2792 version. If you experience problems, drop us a mail. 
2793
2794 Another possible source of issue is that at the moment, building the
2795 examples request to use the gras_stub_generator tool, which is a compiled
2796 program, not a script. In cross-compilation, you need to cross-execute with
2797 wine for example, which is not really pleasant. We are working on this, but
2798 in the meanwhile, simply don't build the examples in cross-compilation
2799 (<tt>cd src</tt> before running make).
2800     
2801 Program (cross-)compiled with mingw32 do request an extra DLL at run-time to be
2802 usable. For example, if you want to test your build with wine, you should do
2803 the following to put this library where wine looks for DLLs.
2804 \verbatim 
2805 cp /usr/share/doc/mingw32-runtime/mingwm10.dll.gz ~/.wine/c/windows/system/
2806 gunzip ~/.wine/c/windows/system/mingwm10.dll.gz
2807 \endverbatim
2808
2809 The DLL is built in src/.libs, and installed in the <i>prefix</i>/bin directory
2810 when you run make install. 
2811
2812 If you want to use it in a native project on windows, you need to use 
2813 simgrid.dll and mingwm10.dll. For each DLL, you need to build .def file
2814 under linux (listing the defined symbols), and convert it into a .lib file
2815 under windows (specifying this in a way that windows compilers like). To
2816 generate the def files, run (under linux):
2817 \verbatim echo "LIBRARY libsimgrid-0.dll" > simgrid.def
2818 echo EXPORTS >> simgrid.def
2819 nm libsimgrid-0.dll | grep ' T _' | sed 's/.* T _//' >> simgrid.def
2820 nm libsimgrid-0.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> simgrid.def
2821
2822 echo "LIBRARY mingwm10.dll" > mingwm10.def
2823 echo EXPORTS >> mingwm10.def
2824 nm mingwm10.dll | grep ' T _' | sed 's/.* T _//' >> mingwm10.def
2825 nm mingwm10.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> mingwm10.def
2826 \endverbatim
2827
2828 To create the import .lib files, use the <tt>lib</tt> windows tool (from
2829 MSVC) the following way to produce simgrid.lib and mingwm10.lib
2830 \verbatim lib /def:simgrid.def
2831 lib /def:mingwm10.def
2832 \endverbatim
2833
2834 If you happen to use Borland C Builder, the right command line is the
2835 following (note that you don't need any file.def to get this working).
2836 \verbatim implib simgrid.lib libsimgrid-0.dll
2837 implib mingwm10.lib mingwm10.dll
2838 \endverbatim
2839
2840 Then, set the following parameters in Visual C++ 2005:
2841 Linker -> Input -> Additional dependencies = simgrid.lib mingwm10.lib
2842
2843 Just in case you wonder how to generate a DLL from libtool in another
2844 project, we added -no-undefined to any lib*_la_LDFLAGS variables so that
2845 libtool accepts to generate a dynamic library under windows. Then, to make
2846 it true, we pass any dependencies (such as -lws2 under windows or -lpthread
2847 on need) on the linking line. Passing such deps is a good idea anyway so
2848 that they get noted in the library itself, avoiding the users to know about
2849 our dependencies and put them manually on their compilation line. Then we
2850 added the AC_LIBTOOL_WIN32_DLL macro just before AC_PROG_LIBTOOL in the
2851 configure.ac. It means that we exported any symbols which need to be.
2852 Nowadays, functions get automatically exported, so we don't need to load our
2853 header files with tons of __declspec(dllexport) cruft. We only need to do so
2854 for data, but there is no public data in SimGrid so we are good.
2855
2856