Logo AND Algorithmique Numérique Distribuée

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