Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Boob jobs. ;)
[simgrid.git] / doc / FAQ.doc
1 /*! \page faq Frequently Asked Questions
2
3 \htmlinclude FAQ.toc
4
5 \section faq_installation Installing the SimGrid library
6
7 Many people have been asking me questions on how to use SimGrid. Quite
8 often, the questions were not really about SimGrid but on the
9 installation process. This section is intended to help people that are
10 not familiar with compiling C files under UNIX. If you follow these
11 instructions and still have some troubles, drop an e-mail to
12 <simgrid-user@lists.gforge.inria.fr>.
13
14 \subsection faq_compiling Compiling SimGrid
15
16 Suppose you have uncompressed SimGrid in some temporary location of
17 your home directory (say <tt>/home/joe/tmp/simgrid-3.0.1 </tt>). The
18 simplest way to use SimGrid is to install it in your home
19 directory. Change your directory to
20 <tt>/home/joe/tmp/simgrid-3.0.1</tt> and type
21
22 \verbatim./configure --prefix=$HOME
23 make
24 make install
25 \endverbatim
26
27 If at some point, something fails, you can report me this problem but,
28 please, avoid sending a laconic mail like "There is a problem. Is it
29 normal?". Send me the config.log file which is automatically
30 generated by configure. Try to capture both the standard output and
31 the error output of the <tt>make</tt> command. There is no way for me
32 to help you if you do not give me a little bit of information.
33
34 Now, the following directory should have been created : 
35
36       \li <tt>/home/joe/doc/simgrid/html/</tt>
37       \li <tt>/home/joe/lib/</tt>
38       \li <tt>/home/joe/include/</tt>
39
40 SimGrid is not a binary, it is a library. Both a static and a dynamic
41 version are available. Here is what you can find if you try a <tt>ls
42 /home/joe/lib</tt>:
43
44 \verbatim libsimgrid.a  libsimgrid.la  libsimgrid.so  libsimgrid.so.0 libsimgrid.so.0.0.1
45 \endverbatim
46
47 Thus, there is two ways to link your program with SimGrid:
48       \li Either you use the static version, e.g 
49 \verbatim gcc libsimgrid.a -o MainProgram MainProgram.c
50 \endverbatim
51           In this case, all the SimGrid functions are directly
52           included in <tt>MainProgram</tt> (hence a bigger binary).
53       \li Either you use the dynamic version (the preferred method)
54 \verbatim gcc -lsimgrid -o MainProgram MainProgram.c
55 \endverbatim
56           In this case, the SimGrid functions are not included in
57           <tt>MainProgram</tt> and you need to set your environment
58           variable in such a way that <tt>libsimgrid.so</tt> will be
59           found at runtime. This can be done by adding the following
60           line in your .bashrc (if you use bash and if you have
61           installed the SimGrid libraries in your home directory):
62 \verbatim export LD_LIBRARY_PATH=$HOME/lib/:$LD_LIBRARY_PATH
63 \endverbatim
64
65 \subsection faq_setting Setting up your own code
66
67 Do not build your simulator by modifying the SimGrid examples.  Go
68 outside the SimGrid source tree and create your own working directory
69 (say <tt>/home/joe/SimGrid/MyFirstScheduler/</tt>).
70
71 Suppose your simulation has the following structure (remember it is
72 just an example to illustrate a possible way to compile everything;
73 feel free to organize it as you want).
74
75       \li <tt>sched.h</tt>: a description of the core of the
76           scheduler (i.e. which functions are can be used by the
77           agents). For example we could find the following functions
78           (master, forwarder, slave).
79
80       \li <tt>sched.c</tt>: a C file including <tt>sched.h</tt> and
81           implementing the core of the scheduler. Most of these
82           functions use the MSG functions defined in section \ref
83           msg_gos_functions.
84
85       \li <tt>masterslave.c</tt>: a C file with the main function, i.e.
86           the MSG initialization (MSG_global_init()), the platform
87           creation (e.g. with MSG_create_environment()), the
88           deployment phase (e.g. with MSG_function_register() and
89           MSG_launch_application()) and the call to
90           MSG_main()).
91
92 To compile such a program, we suggest to use the following
93 Makefile. It is a generic Makefile that we have used many times with
94 our students when we teach the C language.
95
96 \verbatim
97 all: masterslave 
98 masterslave: masterslave.o sched.o
99
100 INSTALL_PATH = $$HOME
101 CC = gcc
102 PEDANTIC_PARANOID_FREAK =       -O0 -Wshadow -Wcast-align \
103                                 -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
104                                 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
105                                 -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
106                                 -Wpointer-arith -Wwrite-strings -finline-functions
107 REASONABLY_CAREFUL_DUDE =       -Wall
108 NO_PRAYER_FOR_THE_WICKED =      -w -O2 
109 WARNINGS =                      $(REASONABLY_CAREFUL_DUDE)
110 CFLAGS = -g $(WARNINGS)
111
112 INCLUDES = -I$(INSTALL_PATH)/include
113 DEFS = -L$(INSTALL_PATH)/lib/
114 LDADD = -lm -lsimgrid 
115 LIBS = 
116
117 %: %.o
118         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ 
119
120 %.o: %.c
121         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
122
123 clean:
124         rm -f $(BIN_FILES) *.o *~
125 .SUFFIXES:
126 .PHONY : clean
127
128 \endverbatim
129
130 The first two lines indicates what should be build when typing make
131 (<tt>masterslave</tt>) and of which files it is to be made of
132 (<tt>masterslave.o</tt> and <tt>sched.o</tt>). This makefile assumes
133 that you have set up correctly your <tt>LD_LIBRARY_PATH</tt> variable
134 (look, there is a <tt>LDADD = -lm -lsimgrid</tt>). If you prefer using
135 the static version, remove the <tt>-lsimgrid</tt> and add a
136 <tt>$(INSTALL_PATH)/lib/libsimgrid.a</tt> on the next line, right
137 after the <tt>LIBS = </tt>.
138
139 More generally, if you have never written a Makefile by yourself, type
140 in a terminal : <tt>info make</tt> and read the introduction. The
141 previous example should be enough for a first try but you may want to
142 perform some more complex compilations...
143
144 \section faq_simgrid I'm new to SimGrid. I have some questions. Where should I start?
145
146 You are at the right place... Having a look to these
147 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">slides</a>
148 may give you some insights on what SimGrid can help you to do and what
149 are its limitations. Then you definitely should read the \ref
150 MSG_examples. There is also a mailing list: <simgrid-user@lists.gforge.inria.fr>.
151
152 \subsection faq_generic Building a generic simulator
153
154 Please read carefully the \ref MSG_examples. You'll find in \ref
155 MSG_ex_master_slave a very simple consisting of a master (that owns a bunch of
156 tasks and distributes them) , some slaves (that process tasks whenever
157 they receive one) and some forwarder agents (that simply pass the
158 tasks they receive to some slaves).
159
160 \subsection faq_visualization Visualizing the schedule
161
162 It is sometime convenient to "see" how the agents are behaving. If you
163 like colors, you can use <tt>tools/MSG_visualization/colorize.pl </tt>
164 as a filter to your MSG outputs. It works directly with INFO. Beware,
165 INFO() prints on stderr. Do not forget to redirect if you want to
166 filter (e.g. with bash): 
167 \verbatim 
168 ./msg_test small_platform.xml small_deployment.xml 2>&1 | ../../tools/MSG_visualization/colorize.pl
169 \endverbatim
170
171 We also have a more graphical output. Have a look at MSG_paje_output(). It 
172 generates an input to <a href="http://www-id.imag.fr/Logiciels/paje/">Paje</a>.
173 <center>
174 \htmlonly
175  <a href="Paje_MSG_screenshot.jpg"><img src="Paje_MSG_screenshot_thn.jpg"></a>
176 \endhtmlonly
177 </center>
178
179 \subsection faq_postmortem_analysis Online/postmortem analysis
180
181 Vizualization with Paje can be seen as a kind of postmortem
182 analysis. However, as soon as you start playing with big simulations,
183 you'll realize that processing such output is kind of tricky. There is
184 so much generic informations that it is hard to find the information
185 you are looking for.
186
187 As a matter of fact, loging really depends on simulations (e.g. what
188 kind of events is important...). That is why we do not propose a big
189 dump of your whole simulation (it would slow everything down) but give
190 you neat tools to structure you logs. Have a look at \ref XBT_log. In
191 fact, rather than a post-mortem analysis, you may want to do it on the
192 fly. The process you are running can do whatever you want. Have you
193 thought about adding a global structure where you directly compute the
194 informations that are really important rather than writing everything
195 down and then processing huge files ?
196
197 \subsection faq_C Argh! Do I really have to code in C ?
198
199 Up until now, there is no binding for other languages. If you use C++,
200 you should be able to use the SimGrid library as a standard C library
201 and everything should work fine (simply <i>link</i> against this
202 library; recompiling SimGrid with a C++ compiler won't work and it
203 wouldn't help if you could).
204
205 In fact, the bindings needed to allow one to use SimGrid from Perl,
206 Python, Java, etc. are double-layered.  The first layer would allow
207 you to call for example the MSG_task_get_name(task) function while
208 what you really want is a proper object wrapping allowing you to call
209 task->name(). That's the purpose of the second layer.  The first one
210 is granted with C++ but can be done with tools like 
211 <a href="www.swig.org/">swig</a> for other languages like Perl, Ruby,
212 Python, CAML. None of us really need the second one (which is a bit
213 more demanding and cannot be automatically generated) yet and there is
214 no real point in doing the first one without the second. :)
215
216 As usual, you're welcome to participate.
217
218 \section faq_questions How to ....? Is there a function in the API to simply ....?
219
220 Here is the deal. The whole SimGrid project (MSG, SURF, GRAS, ...) is
221 meant to be kept as simple and generic as possible. We cannot add
222 functions for everybody's need when these functions can easily be
223 built from the ones already in the API. Most of the time, it is
224 possible and when it was not possible we always have upgraded the API
225 accordingly. When somebody asks us a question like "How to do that ?
226 Is there a function in the API to simply do this ?", we're always glad
227 to answer and help. However if we don't need this code for our own
228 need, there is no chance we're going to write it... it's your job! :)
229 The counterpart to our answers is that once you come up with a neat
230 implementation of this feature (task duplication, RPC, thread
231 synchronization, ...), you should send it to us and we will be glad to
232 add it to the distribution. Thus, other people will take advantage of
233 it (and we don't have to answer this question again and again ;).
234
235 You'll find in this section a few "Missing In Action" features. Many
236 people have asked about it and we have given hints on how to simply do
237 it with MSG. Feel free to contribute...
238
239 \subsection faq_examples I want some more complex examples!
240
241 Many people have come to ask me a more complex example and each time,
242 they have realized afterward that the basics were in the previous three
243 examples. 
244
245 Of course they have often been needing more complex functions like
246 MSG_process_suspend(), MSG_process_resume() and
247 MSG_process_isSuspended() (to perform synchronization), or
248 MSG_task_Iprobe() and MSG_process_sleep() (to avoid blocking
249 receptions), or even MSG_process_create() (to design asynchronous
250 communications or computations). But the examples are sufficient to
251 start.
252
253 We know. We should add some more examples, but not really some more
254 complex ones... We should add some examples that illustrate some other
255 functionalities (like how to simply encode asynchronous
256 communications, RPC, process migrations, thread synchronization, ...)
257 and we will do it when we will have a little bit more time. We have
258 tried to document the examples so that they are understandable. Tell
259 us if something is not clear and once again feel free to participate!
260 :)
261
262 \subsection faq_examples_MIA_taskdup Missing in action: Task duplication/replication
263
264 There is no task duplication in MSG. When you create a task, you can
265 process it or send it somewhere else. As soon as a process has sent
266 this task, he doesn't have this task anymore. It's gone. The receiver
267 process has got the task. However, you could decide upon receiving to
268 create a "copy" of a task but you have to handle by yourself the
269 semantic associated to this "duplication".
270
271 As we already told, we prefer keeping the API as simple as
272 possible. This kind of feature is rather easy to implement by users
273 and the semantic you associate really depends on people. Having a
274 *generic* task duplication mechanism is not that trivial (in
275 particular because of the data field). That is why I would recommand
276 that you write it by yourself even if I can give you advice on how to
277 do it.
278
279 You have the following functions to get informations about a task:
280 MSG_task_get_name(), MSG_task_get_compute_duration(),
281 MSG_task_get_remaining_computation(), MSG_task_get_data_size(),
282 and MSG_task_get_data().
283
284 You could use a dictionnary (#xbt_dict_t) of dynars (#xbt_dict_t). If
285 you still don't see how to do it, please come back to us...
286
287 \subsection faq_examples_MIA_asynchronous I want to do asynchronous communications.
288
289 Up until now, there is no asynchronous communications in MSG. However,
290 you can create as many process as you want so you should be able to do
291 whatever you want... I've written a queue module to help implementing
292 some asynchronous communications at low cost (creating thousands of
293 process only to handle communications may be problematic in term of
294 performance at some point). I'll add it in the distribution asap.
295
296 \subsection faq_examples_MIA_thread_synchronization I need to synchronize my process
297
298 You obviously cannot use pthread_mutexes of pthread_conds. The best
299 thing would be to propose similar structures. Unfortunately, we
300 haven't found time to do it yet. However you can try to play with
301 MSG_process_suspend() and MSG_process_resume(). You can even do some
302 synchronization with fake communications (using MSG_task_get(),
303 MSG_task_put() and MSG_task_Iprobe()).
304
305 \subsection faq_examples_MIA_host_load Where is the get_host_load function hidden in MSG?
306
307 There is no such thing because its semantic wouldn't be really
308 clear. Of course, it is something about the amount of host throughput,
309 but there is as many definition of "host load" as people asking for
310 this function. First, you have to remember that resource availability
311 may vary over time, which make any load notion harder to define.
312
313 It may be instantaneous value or an average one. Moreover it may be only the
314 power of the computer, or may take the background load into account, or may
315 even take the currently running tasks into account. In some SURF models,
316 communications have an influence on computational power. Should it be taken
317 into account too?
318
319 So, we decided not to include such a function into MSG and let people do it
320 thereselves so that they get the value matching exactly what they mean. One
321 possibility is to run active measurement as in next code snippet. It is very
322 close from what you would have to do out of the simulator, and thus gives
323 you information that you could also get in real settings to not hinder the
324 realism of your simulation. 
325
326 \verbatim
327 double get_host_load() {
328    m_task_t task = MSG_task_create("test", 0.001, 0, NULL);
329    double date = MSG_get_clock();
330
331    MSG_task_execute(task);
332    date = MSG_get_clock() - date;
333    MSG_task_destroy(task);
334    return (0.001/date);
335 }
336 \endverbatim
337
338 Of course, it may not match your personal definition of "host load". In this
339 case, please detail what you mean on the mailing list, and we will extend
340 this FAQ section to fit your taste if possible.
341
342 \subsection faq_examples_MIA_batch_scheduler Is there a native support for batch schedulers in SimGrid ?
343
344 No, there is no native support for batch schedulers and none is
345 planned because this is a very specific need (and doing it in a
346 generic way is thus very hard). However some people have implemented
347 their own batch schedulers. Vincent Garonne wrote one during his PhD
348 and put his code in the contrib directory of our CVS so that other can
349 keep working on it. You may find inspinring ideas in it.
350
351 \section faq_SG Where has SG disappeared?!?
352
353 OK, it's time to explain what's happening to the SimGrid project. Let's
354 start with a little bit of history.
355
356 * Historically, SimGrid was a low-level toolkit for scheduling with
357 classical models such as DAGs. That was SimGrid v.1.* aka SG, written
358 by Henri Casanova. I (Arnaud) had been using it in its earliest
359 versions during an internship at UCSD.
360
361 Then we have realized that encoding distributed algorithm in SG was a
362 real pain.
363
364 * So we have built MSG on top of SG and have released SimGrid v.2.*. MSG
365 offered a very basic API to encode a distributed application easily.
366 However encoding MSG on top of SG was not really convenient and did not
367 use the DAG part since the control of the task synchronization was done
368 on top of MSG and no more in SG. We have been playing a little bit with
369 MSG. We have realized that:
370
371    \li 1) the platform modeling was quite flexible and could be "almost"
372        automated (e.g. using random generator and post-annotations);
373
374    \li 2) SG was the bottleneck because of the way we were using
375        it. We needed to simulate concurrent transfers, complex load
376        sharing mechanisms. Many optimizations (e.g. trace integration)
377        were totally inefficient when combined with MSG and made extending SG
378        to implement new sharing policies, parallel tasks models, or failures
379        (many people were asking for these kind of features) a real pain;
380
381    \li 3) the application modeling was not really easy. Even though the
382        application modeling depends on people's applications, we thought
383        we could improve things here. One of our target here was realistic
384 distributed applications ranging from computer sensor networks like
385 the NWS to peer-to-peer applications;
386
387 * So we have been planning mainly two things for SimGrid 3:
388
389    \li 1) I have proposed to get rid of SG and to re-implement a new kernel
390        that would be faster and more flexible. That is what I did in the
391 end of 2004: SURF. SURF is based on a fast max-min linear solver
392 using O(1) data-structures. I have quickly replaced SG by SURF in
393 MSG and the result has been that on the MSG example, the new
394 version was more than 10 times faster while we had gain a lot of
395 flexibility. I think I could still easily make MSG faster but I
396 have to work on MSG now (e.g. using some of the O(1)
397 data-structures I've been using to build SURF) since it has become
398 the bottleneck. Some MSG functions have been removed from the API
399 but they were mainly intended to build the platform by hand (they
400 had appeared in the earliest versions of MSG) and were therefore
401 not useful anymore since we are providing a complete mechanism to
402 automatically build the platform and deploy the agents on it.;
403
404    \li 2) GRAS is a new project Martin and I have come up with. The idea is
405 to have a programming environment that let you program real
406 distributed applications while letting you the ability to run it in
407 the simulator without having to change the slightest line of your
408 code. From the simulation point of view, GRAS performs the
409 application modeling automatically... Up until now, GRAS works on
410 top MSG for historical reasons but I'm going to make it work
411 directly on top of SURF so that it can use all the flex and the
412 speed provided by SURF.
413
414 Those two things are working, but we want to make everything as clean as
415 possible before releasing SimGrid v.3.
416
417 So what about those nice DAGs we used to have in SimGrid v.1.? They're not
418 anymore in SimGrid v.3. Let me recall you the way SimGrid 3 is organized:
419
420 \verbatim
421 ________________
422 |   User code  |
423 |______________|
424 | | MSG | GRAS |
425 | -------------|
426 | |   SURF     |
427 | -------------|
428 |     XBT      |
429 ----------------
430 \endverbatim
431
432 XBT is our tool box and now, you should have an idea of what the other ones
433 are. As you can see, the primitive SG is not here anymore. However it could
434 still be brought back if people really need it. Here is how it would fit.
435
436 \verbatim
437 ______________________
438 |    User code       |
439 |____________________|
440 | | MSG | GRAS | SG  |
441 | -------------------|
442 | |      SURF        |
443 | -------------------|
444 |        XBT         |
445 ----------------------
446 \endverbatim
447
448 Re-implementing SG on top of SURF is really straightforward (it only
449 requires a little bit of time that I really don't have right now)
450 since the only thing that lacks to SURF is the DAG part. But adding it
451 to SURF would slow it down and therefore slow MSG and GRAS which is
452 not a good thing.  However it is really not on the top of our TODO
453 list because we have to work on GRAS, and its MPI counterpart, and a
454 parallel task model, and ... Anyway, we finally have migrated our CVS
455 to gforge so people that are interested by helping on this part will
456 have the possibility to do it.
457
458 \subsection faq_SG_DAG How to implement a distributed dynamic scheduler of DAGs without the SG module?
459
460 Distributed is somehow "contagious". If you start making distributed
461 decisions, there is no way to handle DAGs directly anymore (unless I am
462 missing something). You have to encode your DAGs in term of communicating
463 process to make the whole scheduling process distributed. Believe me, it is
464 worth the effort since you'll then be able to try your algorithms in a very
465 wide variety of conditions.
466
467 If you decide that the distributed part is not that much important and that
468 DAG is really the level of abstraction you want to work with (but it
469 prevents you from having "realistic" platform modeling), then you should
470 keep using the 2.18.5 versions until somebody has ported SG on top of SURF.
471 Note however that SURF will be slower than the old SG to handle traces with
472 a lots of variations (there is no trace integration anymore).
473
474 \section faq_dynamic Dynamic resources and platform building
475
476 \subsection faq_platform Building a realistic platform
477
478 We can speak more than an hour on this subject and we still do not have
479 the right answer, just some ideas. You can read the following
480 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">slides</a>.
481 It may give you some hints. You can also have a look at the
482 <tt>tools/platform_generation/</tt> directory. There is a perl-script
483 we use to annotate a Tiers generated platform.
484
485 \subsection faq_SURF_dynamic How can I have variable resource availability?
486
487 A nice feature of SimGrid is that it enables you to seamlessly have
488 resources whose availability change over time. When you build a
489 platform, you generally declare CPUs like that:
490
491 \verbatim
492   <cpu name="Cpu A" power="100.00"/>
493 \endverbatim 
494
495 If you want the availability of "CPU A" to change over time, the only
496 thing you have to do is change this definition like that:
497
498 \verbatim
499   <cpu name="Cpu A" power="100.00" availability_file="trace_A.txt" state_file="trace_A_failure.txt"/>
500 \endverbatim
501
502 For CPUs, availability files are expressed in fraction of available
503 power. Let's have a look at what "trace_A.txt" may look like:
504
505 \verbatim
506 PERIODICITY 1.0
507 0.0 1.0
508 11.0 0.5
509 20.0 0.9
510 \endverbatim
511
512 At time 0, our CPU will deliver 100 Mflop/s. At time 11.0, it will
513 deliver only 50 Mflop/s until time 20.0 where it will will start
514 delivering 90 Mflop/s. Last at time 21.0 (20.0 plus the periodicity
515 1.0), we'll be back to the beginning and it will deliver 100Mflop/s.
516
517 Now let's look at the state file:
518 \verbatim
519 PERIODICITY 10.0
520 1.0 -1.0
521 2.0 1.0
522 \endverbatim
523
524 A negative value means "off" while a positive one means "on". At time
525 1.0, the CPU is on. At time 1.0, it is turned off and at time 2.0, it
526 is turned on again until time 12 (2.0 plus the periodicity 10.0). It
527 will be turned on again at time 13.0 until time 23.0, and so on.
528
529 Now, let's look how the same kind of thing can be done for network
530 links. A usual declaration looks like:
531
532 \verbatim
533   <network_link name="LinkA" bandwidth="10.0" latency="0.2"/>
534 \endverbatim
535
536 You have at your disposal the following options: bandwidth_file,
537 latency_file and state_file. The only difference with CPUs is that
538 bandwidth_file and latency_file do not express fraction of available
539 power but are expressed directly in Mb/s and seconds.
540
541 \subsection faq_flexml_bypassing How could I have some C functions do what the platform and deployment files do?
542
543 So you want to bypass the XML files parser, uh? Maybe doin some parameter
544 sweep experiments on your simulations or so? This is possible, but it's not
545 really easy. Here is how it goes.
546
547 For this, you have to first remember that the XML parsing in SimGrid is done
548 using a tool called FleXML. Given a DTD, this gives a flex-based parser. If
549 you want to bypass the parser, you need to provide some code mimicking what
550 it does and replacing it in its interactions with the SURF code. So, let's
551 have a look at these interactions.
552
553 FleXML parser are close to classical SAX parsers. It means that a
554 well-formed SimGrid platform XML file might result in the following
555 "events":
556
557   - start "platform_description"
558   - start "cpu" with attributes name="host1" power="1.0"
559   - end "cpu"
560   - start "cpu" with attributes name="host2" power="2.0"
561   - end "cpu"
562   - start "network_link" with ...
563   - end "network_link"
564   - start "route" with ...
565   - end "route"
566   - start "route" with ...
567   - end "route"
568   - end "platform_description"
569
570 The communication from the parser to the SURF code uses two means:
571 Attributes get copied into some global variables, and a surf-provided
572 function gets called by the parser for each event. For example, the event
573   - start "cpu" with attributes name="host1" power="1.0"
574
575 let the parser do the equivalent of:
576 \verbatim
577   strcpy("host1",A_cpu_name);
578   A_cpu_power = 1.0;
579   (*STag_cpu_fun)();
580 \endverbatim
581
582 In SURF, we attach callbacks to the different events by initializing the
583 pointer functions to some the right surf functions. Example in
584 workstation_KCCFLN05.c (surf_parse_open() ends up calling surf_parse()):
585 \verbatim
586   // Building the routes
587   surf_parse_reset_parser();
588   STag_route_fun=parse_route_set_endpoints;
589   ETag_route_element_fun=parse_route_elem;
590   ETag_route_fun=parse_route_set_route;
591   surf_parse_open(file);
592   xbt_assert1((!surf_parse()),"Parse error in %s",file);
593   surf_parse_close();
594 \endverbatim
595     
596 So, to bypass the FleXML parser, you need to write your own version of the
597 surf_parse function, which should do the following:
598    - Call the corresponding STag_<tag>_fun function to simulate tag start
599    - Fill the A_<tag>_<attribute> variables with the wanted values
600    - Call the corresponding ETag_<tag>_fun function to simulate tag end
601    - (do the same for the next set of values, and loop)
602
603 Then, tell SimGrid that you want to use your own "parser" instead of the stock one:
604 \verbatim
605   surf_parse = surf_parse_bypass;
606   MSG_create_environment(NULL);
607 \endverbatim
608
609 An example of this trick is distributed in the file examples/msg/msg_test_surfxml_bypassed.c
610
611 \section faq_troubleshooting Troubleshooting
612
613 \subsection faq_context_1000 I want thousands of simulated processes
614
615 SimGrid can use either pthreads library or the UNIX98 contextes. On most
616 systems, the number of pthreads is limited and then your simulation may be
617 limited for a stupid reason. This is especially true with the current linux
618 pthreads, and I cannot get more than 2000 simulated processes with pthreads
619 on my box. The UNIX98 contexts allow me to raise the limit to 25,000
620 simulated processes on my laptop.
621
622 The <tt>--with-context</tt> option of the <tt>./configure</tt> script allows
623 you to choose between UNIX98 contextes (<tt>--with-context=ucontext</tt>)
624 and the pthread version ( (<tt>--with-context=pthread</tt>). The default
625 value is ucontext when the script detect a working UNIX98 context
626 implementation. On Windows boxes, the provided value is discarded and an
627 adapted version is picked up.
628
629 We experienced some issues with contextes on some rare systems (solaris 8
630 and lower comes to mind). The main problem is that the configure script
631 detect the contextes as being functional when it's not true. If you happen
632 to use such a system, switch manually to the pthread version, and provide us
633 with a good patch for the configure script so that it is done automatically ;)
634
635 \subsection faq_context_10000 I want hundred thousands of simulated processes
636
637 As explained above, SimGrid can use UNIX98 contextes to represent and handle
638 the simulated processes. Thanks to this, the main limitation to the number
639 of simulated processes becomes the available memory. 
640
641 Here are some tricks I had to use in order to run a token ring between
642 25,000 processes on my laptop (1Gb memory, 1.5Gb swap).
643
644  - First of all, make sure your code runs for a few hundreds processes
645    before trying to push the limit. Make sure it's valgrind-clean, ie that
646    valgrind does not report neither memory error nor memory leaks. Indeed,
647    numerous simulated processes result in *fat* simulation hindering debugging.
648
649  - It was really boring to write 25,000 entries in the deployment file, so I wrote 
650    a little script <tt>examples/gras/tokenS/make_deployment.pl</tt>, which you may
651    want to adapt to your case.
652
653  - The deployment file became quite big, so I had to do what is in the FAQ
654    entry \ref faq_flexml_limit
655
656  - Each UNIX98 context has its own stack entry. As debugging this is quite 
657    hairly, the default value is a bit overestimated so that user don't get 
658    into trouble about this. You want to tune this size to increse the number 
659    of processes. This is the <tt>STACK_SIZE</tt> define in 
660    <tt>src/xbt/context_private.h</tt>, which is 128kb by default.
661    Reduce this as much as you can, but be warned that if this value is too 
662    low, you'll get a segfault. The token ring example, which is quite simple, 
663    runs with 40kb stacks.
664
665 \subsection faq_flexml_limit I get the message "surf_parse_lex: Assertion `next&lt;limit' failed."
666
667 This is because your platform file is too big for the parser. 
668
669 Actually, the message comes directly from FleXML, the technology on top of
670 which the parser is built. FleXML has the bad idea of fetching the whole
671 document in memory before parsing it. And moreover, the memory buffer size
672 must be determinded at compilation time.
673
674 We use a value which seems big enough for our need without bloating the
675 simulators footprints. But of course your mileage may vary. In this case,
676 just edit src/surf/surfxml.l modify the definition of
677 FLEXML_BUFFERSTACKSIZE. E.g.
678
679 \verbatim
680 #define FLEXML_BUFFERSTACKSIZE 1000000000
681 \endverbatim
682
683 Then recompile and everything should be fine, provided that your version of
684 Flex is recent enough (>= 2.5.31). If not the compilation process should
685 warn you.
686
687 A while ago, we worked on FleXML to reduce a bit its memory consumtion, but
688 these issues remain. There is two things we should do:
689
690   - use a dynamic buffer instead of a static one so that the only limit
691     becomes your memory, not a stupid constant fixed at compilation time
692     (maybe not so difficult).
693   - change the parser so that it does not need to get the whole file in
694     memory before parsing
695     (seems quite difficult, but I'm a complete newbe wrt flex stuff).
696
697 These are changes to FleXML itself, not SimGrid. But since we kinda hijacked
698 the development of FleXML, I can grant you that any patches would be really
699 welcome and quickly integrated.
700
701 \subsection faq_deadlock There is a deadlock !!!
702
703 Unfortunately, we cannot debug every code written in SimGrid.  We
704 furthermore believe that the framework provides ways enough
705 information to debug such informations yourself. If the textual output
706 is not enough, Make sure to check the \ref faq_paje FAQ entry to see
707 how to get a graphical one.
708
709 Now, if you come up with a really simple example that deadlocks and
710 you're absolutely convinced that it should not, you can ask on the
711 list. Just be aware that you'll be severely punished if the mistake is
712 on your side... We have plenty of FAQ entries to redact and new
713 features to implement for the impenitents! ;)
714
715 \author Arnaud Legrand (arnaud.legran::imag.fr)
716 \author Martin Quinson (martin.quinson::loria.fr)
717
718
719 */
720