Logo AND Algorithmique Numérique Distribuée

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