Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add java to bindings page.
[simgrid.git] / doc / FAQ.doc
1 /*! \page faq Frequently Asked Questions
2
3 \htmlinclude .FAQ.doc.toc
4
5 \section faq_simgrid I'm new to SimGrid. I have some questions. Where should I start?
6
7 You are at the right  place... Having a look to these
8 <a href="http://www.loria.fr/~quinson/blog/2010/06/28/Tutorial_at_HPCS/">the slides of the HPCS'10 tutorial</a>
9 (or to these <a href="http://graal.ens-lyon.fr/~alegrand/articles/slides_g5k_simul.pdf">ancient
10 slides</a>, or to these
11 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">"obsolete" slides</a>)
12 may give you some insights on what SimGrid can help you to do and what
13 are its limitations. Then you definitely should read the \ref
14 MSG_examples. The \ref GRAS_tut can also help you.
15
16 If you are stuck at any point and if this FAQ cannot help you, please drop us a
17 mail to the user mailing list: <simgrid-user@lists.gforge.inria.fr>.
18
19 \subsection faq_interfaces What is the difference between MSG, SimDag, and GRAS? Do they serve the same purpose?
20
21 It depend on how you define "purpose", I guess ;)
22
23 They all allow you to build a prototype of application which you can run
24 within the simulator afterward. They all share the same simulation kernel,
25 which is the core of the SimGrid project. They differ by the way you express
26 your application.
27
28 With SimDag, you express your code as a collection of interdependent
29 parallel tasks. So, in this model, applications can be seen as a DAG of
30 tasks. This is the interface of choice for people wanting to port old
31 code designed for SimGrid v1 or v2 to the framework current version.
32
33 With both GRAS and MSG, your application is seen as a set of communicating
34 processes, exchanging data by the way of messages and performing computation
35 on their own.
36
37 The difference between both is that MSG is somehow easier to use, but GRAS
38 is not limited to the simulator. Once you're done writing your GRAS code,
39 you can run your code both in the simulator or on a real platform. For this,
40 there is two implementations of the GRAS interface, one for simulation, one
41 for real execution. So, you just have to relink your code to chose one of
42 both world. 
43
44 \subsection faq_generic First steps with SimGrid
45
46 If you decide to go for the MSG interface, please read carefully the
47 \ref MSG_examples. You'll find in \ref MSG_ex_master_slave a very
48 simple consisting of a master (that owns a bunch of tasks and
49 distributes them) , some slaves (that process tasks whenever they
50 receive one) and some forwarder agents (that simply pass the tasks
51 they receive to some slaves).
52
53 If you decide to go for the GRAS interface, you should definitively
54 read the \ref GRAS_tut. The first section constitutes an introduction
55 to the tool and presents the model we use. The second section
56 constitutes a complete step-by-step tutorial building a distributed
57 application from the beginning and exemplifying most of the GRAS
58 features in the process. The last section groups some HOWTOS
59 highlighting a given feature of the framework in a more concise way.
60
61 If you decide to go for another interface, I'm afraid your only sources
62 of information will be the source code and the mailing lists...
63
64 \subsection faq_visualization Visualizing and analyzing the results
65
66 It is sometime convenient to "see" how the agents are behaving. If you
67 like colors, you can use <tt>tools/MSG_visualization/colorize.pl </tt>
68 as a filter to your MSG outputs. It works directly with INFO. Beware,
69 INFO() prints on stderr. Do not forget to redirect if you want to
70 filter (e.g. with bash): 
71 \verbatim 
72 ./msg_test small_platform.xml small_deployment.xml 2>&1 | ../../tools/MSG_visualization/colorize.pl
73 \endverbatim
74
75 We also have a more graphical output. Have a look at section \ref faq_tracing.
76
77 \subsection faq_C Argh! Do I really have to code in C?
78
79 Up until now, there is no binding for other languages. If you use C++,
80 you should be able to use the SimGrid library as a standard C library
81 and everything should work fine (simply <i>link</i> against this
82 library; recompiling SimGrid with a C++ compiler won't work and it
83 wouldn't help if you could).
84
85 In fact, we are currently working on Java bindings of MSG to allow
86 all the undergrad students of the world to use this tool. This is a
87 little more tricky than I would have expected, but the work is moving
88 fast forward [2006/05/13]. More languages are evaluated, but for now,
89 we do not feel a real demand for any other language. Please speak up!
90
91 \section faq_howto Feature related questions
92
93 \subsection faq_MIA "Could you please add (your favorite feature here) to SimGrid?"
94
95 Here is the deal. The whole SimGrid project (MSG, SURF, GRAS, ...) is
96 meant to be kept as simple and generic as possible. We cannot add
97 functions for everybody's needs when these functions can easily be
98 built from the ones already in the API. Most of the time, it is
99 possible and when it was not possible we always have upgraded the API
100 accordingly. When somebody asks us a question like "How to do that?
101 Is there a function in the API to simply do this?", we're always glad
102 to answer and help. However if we don't need this code for our own
103 need, there is no chance we're going to write it... it's your job! :)
104 The counterpart to our answers is that once you come up with a neat
105 implementation of this feature (task duplication, RPC, thread
106 synchronization, ...), you should send it to us and we will be glad to
107 add it to the distribution. Thus, other people will take advantage of
108 it (and we don't have to answer this question again and again ;).
109
110 You'll find in this section a few "Missing In Action" features. Many
111 people have asked about it and we have given hints on how to simply do
112 it with MSG. Feel free to contribute...
113
114 \subsection faq_MIA_MSG MSG features
115
116 \subsubsection faq_MIA_examples I want some more complex MSG examples!
117
118 Many people have come to ask me a more complex example and each time,
119 they have realized afterward that the basics were in the previous three
120 examples. 
121
122 Of course they have often been needing more complex functions like
123 MSG_process_suspend(), MSG_process_resume() and
124 MSG_process_isSuspended() (to perform synchronization), or
125 MSG_task_Iprobe() and MSG_process_sleep() (to avoid blocking
126 receptions), or even MSG_process_create() (to design asynchronous
127 communications or computations). But the examples are sufficient to
128 start.
129
130 We know. We should add some more examples, but not really some more
131 complex ones... We should add some examples that illustrate some other
132 functionalists (like how to simply encode asynchronous
133 communications, RPC, process migrations, thread synchronization, ...)
134 and we will do it when we will have a little bit more time. We have
135 tried to document the examples so that they are understandable. Tell
136 us if something is not clear and once again feel free to participate!
137 :)
138
139 \subsubsection faq_MIA_taskdup Missing in action: MSG Task duplication/replication
140
141 There is no task duplication in MSG. When you create a task, you can
142 process it or send it somewhere else. As soon as a process has sent
143 this task, he doesn't have this task anymore. It's gone. The receiver
144 process has got the task. However, you could decide upon receiving to
145 create a "copy" of a task but you have to handle by yourself the
146 semantic associated to this "duplication".
147
148 As we already told, we prefer keeping the API as simple as
149 possible. This kind of feature is rather easy to implement by users
150 and the semantic you associate really depends on people. Having a
151 *generic* task duplication mechanism is not that trivial (in
152 particular because of the data field). That is why I would recommand
153 that you write it by yourself even if I can give you advice on how to
154 do it.
155
156 You have the following functions to get informations about a task:
157 MSG_task_get_name(), MSG_task_get_compute_duration(),
158 MSG_task_get_remaining_computation(), MSG_task_get_data_size(),
159 and MSG_task_get_data().
160
161 You could use a dictionary (#xbt_dict_t) of dynars (#xbt_dynar_t). If
162 you still don't see how to do it, please come back to us...
163
164 \subsubsection faq_MIA_asynchronous I want to do asynchronous communications in MSG
165
166 In the past (version <= 3.4), there was no function to perform asynchronous communications. 
167 It could easily be implemented by creating new process when needed though. Since version 3.5, 
168 we have introduced the following functions:
169  - MSG_task_isend()
170  - MSG_task_irecv()
171  - MSG_comm_test()
172  - MSG_comm_wait()
173  - MSG_comm_waitall()
174  - MSG_comm_waitany()
175  - MSG_comm_destroy()
176
177 We refer you to the description of these functions for more details on their usage as well 
178 as to the exemple section on \ref MSG_ex_asynchronous_communications.
179
180 \subsubsection faq_MIA_thread_synchronization I need to synchronize my MSG processes
181
182 You obviously cannot use pthread_mutexes of pthread_conds since we handle every 
183 scheduling related decision within SimGrid. 
184
185 In the past (version <=3.3.4) you could do it by playing with
186 MSG_process_suspend() and MSG_process_resume() or with fake communications (using MSG_task_get(),
187 MSG_task_put() and MSG_task_Iprobe()).
188
189 Since version 3.4, you can use classical synchronization structures. See page \ref XBT_synchro or simply check in
190 include/xbt/synchro_core.h.
191
192 \subsubsection faq_MIA_host_load Where is the get_host_load function hidden in MSG?
193
194 There is no such thing because its semantic wouldn't be really
195 clear. Of course, it is something about the amount of host throughput,
196 but there is as many definition of "host load" as people asking for
197 this function. First, you have to remember that resource availability
198 may vary over time, which make any load notion harder to define.
199
200 It may be instantaneous value or an average one. Moreover it may be only the
201 power of the computer, or may take the background load into account, or may
202 even take the currently running tasks into account. In some SURF models,
203 communications have an influence on computational power. Should it be taken
204 into account too?
205
206 First of all, it's near to impossible to predict the load beforehands in the
207 simulator since it depends on too much parameters (background load
208 variation, bandwidth sharing algorithmic complexity) some of them even being
209 not known beforehands (other task starting at the same time). So, getting
210 this information is really hard (just like in real life). It's not just that
211 we want MSG to be as painful as real life. But as it is in some way
212 realistic, we face some of the same problems as we would face in real life.
213
214 How would you do it for real? The most common option is to use something
215 like NWS that performs active probes. The best solution is probably to do
216 the same within MSG, as in next code snippet. It is very close from what you
217 would have to do out of the simulator, and thus gives you information that
218 you could also get in real settings to not hinder the realism of your
219 simulation. 
220
221 \verbatim
222 double get_host_load() {
223    m_task_t task = MSG_task_create("test", 0.001, 0, NULL);
224    double date = MSG_get_clock();
225
226    MSG_task_execute(task);
227    date = MSG_get_clock() - date;
228    MSG_task_destroy(task);
229    return (0.001/date);
230 }
231 \endverbatim
232
233 Of course, it may not match your personal definition of "host load". In this
234 case, please detail what you mean on the mailing list, and we will extend
235 this FAQ section to fit your taste if possible.
236
237 \subsubsection faq_MIA_communication_time How can I get the *real* communication time?  
238
239 Communications are synchronous and thus if you simply get the time
240 before and after a communication, you'll only get the transmission
241 time and the time spent to really communicate (it will also take into
242 account the time spent waiting for the other party to be
243 ready). However, getting the *real* communication time is not really
244 hard either. The following solution is a good starting point.
245
246 \verbatim
247 int sender()
248 {
249   m_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size, 
250                                   calloc(1,sizeof(double)));
251   *((double*) task->data) = MSG_get_clock();
252   MSG_task_put(task, slaves[i % slaves_count], PORT_22);
253   XBT_INFO("Send completed");
254   return 0;
255 }
256 int receiver()
257 {
258   m_task_t task = NULL;
259   double time1,time2;
260
261   time1 = MSG_get_clock();
262   a = MSG_task_get(&(task), PORT_22);
263   time2 = MSG_get_clock();
264   if(time1<*((double *)task->data))
265      time1 = *((double *) task->data);
266   XBT_INFO("Communication time :  \"%f\" ", time2-time1);
267   free(task->data);
268   MSG_task_destroy(task);
269   return 0;
270 }
271 \endverbatim
272
273 \subsection faq_MIA_SimDag SimDag related questions
274
275 \subsubsection faq_SG_comm Implementing communication delays between tasks.
276
277 A classic question of SimDag newcomers is about how to express a
278 communication delay between tasks. The thing is that in SimDag, both
279 computation and communication are seen as tasks.  So, if you want to
280 model a data dependency between two DAG tasks t1 and t2, you have to
281 create 3 SD_tasks: t1, t2 and c and add dependencies in the following
282 way:
283
284 \verbatim
285 SD_task_dependency_add(NULL, NULL, t1, c);
286 SD_task_dependency_add(NULL, NULL, c, t2);
287 \endverbatim
288
289 This way task t2 cannot start before the termination of communication c
290 which in turn cannot start before t1 ends.
291
292 When creating task c, you have to associate an amount of data (in bytes)
293 corresponding to what has to be sent by t1 to t2.
294
295 Finally to schedule the communication task c, you have to build a list
296 comprising the workstations on which t1 and t2 are scheduled (w1 and w2
297 for example) and build a communication matrix that should look like
298 [0;amount ; 0; 0].
299
300 \subsubsection faq_SG_DAG How to implement a distributed dynamic scheduler of DAGs.
301
302 Distributed is somehow "contagious". If you start making distributed
303 decisions, there is no way to handle DAGs directly anymore (unless I
304 am missing something). You have to encode your DAGs in term of
305 communicating process to make the whole scheduling process
306 distributed. Here is an example of how you could do that. Assume T1
307 has to be done before T2.
308
309 \verbatim
310  int your_agent(int argc, char *argv[] {
311    ...
312    T1 = MSG_task_create(...);
313    T2 = MSG_task_create(...);
314    ...
315    while(1) {
316      ...
317      if(cond) MSG_task_execute(T1);
318      ...
319      if((MSG_task_get_remaining_computation(T1)=0.0) && (you_re_in_a_good_mood))
320         MSG_task_execute(T2)
321      else {
322         /* do something else */
323      }
324    }
325  }
326 \endverbatim
327  
328 If you decide that the distributed part is not that much important and that
329 DAG is really the level of abstraction you want to work with, then you should
330 give a try to \ref SD_API.
331
332 \subsection faq_MIA_generic Generic features
333
334 \subsubsection faq_more_processes Increasing the amount of simulated processes
335
336 Here are a few tricks you can apply if you want to increase the amount
337 of processes in your simulations.
338
339  - <b>A few thousands of simulated processes</b> (soft tricks)\n
340    SimGrid can use either pthreads library or the UNIX98 contextes. On
341    most systems, the number of pthreads is limited and then your
342    simulation may be limited for a stupid reason. This is especially
343    true with the current linux pthreads, and I cannot get more than
344    2000 simulated processes with pthreads on my box. The UNIX98
345    contexts allow me to raise the limit to 25,000 simulated processes
346    on my laptop.\n\n
347    The <tt>--with-context</tt> option of the <tt>./configure</tt>
348    script allows you to choose between UNIX98 contextes
349    (<tt>--with-context=ucontext</tt>) and the pthread version
350    (<tt>--with-context=pthread</tt>). The default value is ucontext
351    when the script detect a working UNIX98 context implementation. On
352    Windows boxes, the provided value is discarded and an adapted
353    version is picked up.\n\n
354    We experienced some issues with contextes on some rare systems
355    (solaris 8 and lower or old alpha linuxes comes to mind). The main
356    problem is that the configure script detect the contextes as being
357    functional when it's not true. If you happen to use such a system,
358    switch manually to the pthread version, and provide us with a good
359    patch for the configure script so that it is done automatically ;)
360
361  - <b>Hundred thousands of simulated processes</b> (hard-core tricks)\n 
362    As explained above, SimGrid can use UNIX98 contextes to represent
363    and handle the simulated processes. Thanks to this, the main
364    limitation to the number of simulated processes becomes the
365    available memory.\n\n
366    Here are some tricks I had to use in order to run a token ring
367    between 25,000 processes on my laptop (1Gb memory, 1.5Gb swap).\n
368    - First of all, make sure your code runs for a few hundreds
369      processes before trying to push the limit. Make sure it's
370      valgrind-clean, ie that valgrind does not report neither memory
371      error nor memory leaks. Indeed, numerous simulated processes
372      result in *fat* simulation hindering debugging.
373    - It was really boring to write 25,000 entries in the deployment
374      file, so I wrote a little script
375      <tt>examples/gras/mutual_exclusion/simple_token/make_deployment.pl</tt>, which you may
376      want to adapt to your case. You could also think about hijacking
377      the SURFXML parser (have look at \ref faq_flexml_bypassing).
378    - The deployment file became quite big, so I had to do what is in
379      the FAQ entry \ref faq_flexml_limit
380    - Each UNIX98 context has its own stack entry. As debugging this is
381      quite hairly, the default value is a bit overestimated so that
382      user don't get into trouble about this. You want to tune this
383      size to increse the number of processes. This is the
384      <tt>STACK_SIZE</tt> define in 
385      <tt>src/xbt/xbt_context_sysv.c</tt>, which is 128kb by default.
386      Reduce this as much as you can, but be warned that if this value
387      is too low, you'll get a segfault. The token ring example, which
388      is quite simple, runs with 40kb stacks.     
389    - You may tweak the logs to reduce the stack size further.  When
390      logging something, we try to build the string to display in a
391      char array on the stack. The size of this array is constant (and
392      equal to XBT_LOG_BUFF_SIZE, defined in include/xbt/log/h). If the
393      string is too large to fit this buffer, we move to a dynamically
394      sized buffer. In which case, we have to traverse one time the log
395      event arguments to compute the size we need for the buffer,
396      malloc it, and traverse the argument list again to do the actual
397      job.\n     
398      The idea here is to move XBT_LOG_BUFF_SIZE to 1, forcing the logs
399      to use a dynamic array each time. This allows us to lower further
400      the stack size at the price of some performance loss...\n
401      This allowed me to run the reduce the stack size to ... 4k. Ie,
402      on my 1Gb laptop, I can run more than 250,000 processes!
403
404 \subsubsection faq_MIA_batch_scheduler Is there a native support for batch schedulers in SimGrid?
405
406 No, there is no native support for batch schedulers and none is
407 planned because this is a very specific need (and doing it in a
408 generic way is thus very hard). However some people have implemented
409 their own batch schedulers. Vincent Garonne wrote one during his PhD
410 and put his code in the contrib directory of our SVN so that other can
411 keep working on it. You may find inspiring ideas in it.
412
413 \subsubsection faq_MIA_checkpointing I need a checkpointing thing
414
415 Actually, it depends on whether you want to checkpoint the simulation, or to
416 simulate checkpoints. 
417
418 The first one could help if your simulation is a long standing process you
419 want to keep running even on hardware issues. It could also help to
420 <i>rewind</i> the simulation by jumping sometimes on an old checkpoint to
421 cancel recent calculations.\n 
422 Unfortunately, such thing will probably never exist in SG. One would have to
423 duplicate all data structures because doing a rewind at the simulator level
424 is very very hard (not talking about the malloc free operations that might
425 have been done in between). Instead, you may be interested in the Libckpt
426 library (http://www.cs.utk.edu/~plank/plank/www/libckpt.html). This is the
427 checkpointing solution used in the condor project, for example. It makes it
428 easy to create checkpoints (at the OS level, creating something like core
429 files), and rerunning them on need.
430
431 If you want to simulate checkpoints instead, it means that you want the
432 state of an executing task (in particular, the progress made towards
433 completion) to be saved somewhere.  So if a host (and the task executing on
434 it) fails (cf. #MSG_HOST_FAILURE), then the task can be restarted
435 from the last checkpoint.\n
436
437 Actually, such a thing does not exists in SimGrid either, but it's just
438 because we don't think it is fundamental and it may be done in the user code
439 at relatively low cost. You could for example use a watcher that
440 periodically get the remaining amount of things to do (using
441 MSG_task_get_remaining_computation()), or fragment the task in smaller
442 subtasks.
443
444 \subsection faq_platform Platform building and Dynamic resources
445
446 \subsubsection faq_platform_example Where can I find SimGrid platform files?
447
448 There is several little examples in the archive, in the examples/msg
449 directory. From time to time, we are asked for other files, but we
450 don't have much at hand right now. 
451
452 You should refer to the Platform Description Archive
453 (http://pda.gforge.inria.fr) project to see the other platform file we
454 have available, as well as the Simulacrum simulator, meant to generate
455 SimGrid platforms using all classical generation algorithms.
456
457 \subsubsection faq_platform_alnem How can I automatically map an existing platform?
458
459 We are working on a project called ALNeM (Application-Level Network
460 Mapper) which goal is to automatically discover the topology of an
461 existing network. Its output will be a platform description file
462 following the SimGrid syntax, so everybody will get the ability to map
463 their own lab network (and contribute them to the catalog project).
464 This tool is not ready yet, but it move quite fast forward. Just stay
465 tuned.
466
467 \subsubsection faq_platform_synthetic Generating synthetic but realistic platforms
468
469 The third possibility to get a platform file (after manual or
470 automatic mapping of real platforms) is to generate synthetic
471 platforms. Getting a realistic result is not a trivial task, and
472 moreover, nobody is really able to define what "realistic" means when
473 speaking of topology files. You can find some more thoughts on this
474 topic in these
475 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">slides</a>.
476
477 If you are looking for an actual tool, there we have a little tool to
478 annotate Tiers-generated topologies. This perl-script is in
479 <tt>tools/platform_generation/</tt> directory of the SVN. Dinda et Al.
480 released a very comparable tool, and called it GridG.
481
482 \subsubsection faq_SURF_multicore Modeling multi-core resources 
483
484 There is currently no native support for multi-core or SMP machines in
485 SimGrid. We are currently working on it, but coming up with the right
486 model is very hard: Cores share caches and bus to access memory and
487 thus interfere with each others. Memory contention is a crucial
488 component of multi-core modeling.
489
490 In the meanwhile, some user-level tricks can reveal sufficient for
491 you. For example, you may model each core by a CPU and add some very
492 high speed links between them. This complicates a bit the user code
493 since you have to remember that when you assign something to a (real)
494 host, it can be any of the (fake) hosts representing the cores of a
495 given machine. For that, you can use the prop tag of the XML files as
496 follows. Your code should then look at the â€˜machine’ property
497 associated with each workstation, and run parallel tasks over all
498 cores of the machine.
499
500 \verbatim
501   <host id="machine0/core0" power="91500E6">
502     <prop id="machine" value="machine0"/>
503     <prop id="core" value="0"/>
504   </host>
505   <host id="machine0/core1" power="91500E6">
506     <prop id="machine" value="machine0"/>
507     <prop id="core" value="1"/>
508 </host>
509
510
511 \endverbatim
512
513 \subsubsection faq_SURF_dynamic Modeling dynamic resource availability 
514
515 A nice feature of SimGrid is that it enables you to seamlessly have
516 resources whose availability change over time. When you build a
517 platform, you generally declare hosts like that:
518
519 \verbatim
520   <host id="host A" power="100.00"/>
521 \endverbatim 
522
523 If you want the availability of "host A" to change over time, the only
524 thing you have to do is change this definition like that:
525
526 \verbatim
527   <host id="host A" power="100.00" availability_file="trace_A.txt" state_file="trace_A_failure.txt"/>
528 \endverbatim
529
530 For hosts, availability files are expressed in fraction of available
531 power. Let's have a look at what "trace_A.txt" may look like:
532
533 \verbatim
534 PERIODICITY 1.0
535 0.0 1.0
536 11.0 0.5
537 20.0 0.9
538 \endverbatim
539
540 At time 0, our host will deliver 100 flop/s. At time 11.0, it will
541 deliver only 50 flop/s until time 20.0 where it will will start
542 delivering 90 flop/s. Last at time 21.0 (20.0 plus the periodicity
543 1.0), we'll be back to the beginning and it will deliver 100 flop/s.
544
545 Now let's look at the state file:
546 \verbatim
547 PERIODICITY 10.0
548 1.0 -1.0
549 2.0 1.0
550 \endverbatim
551
552 A negative value means "off" while a positive one means "on". At time
553 1.0, the host is on. At time 1.0, it is turned off and at time 2.0, it
554 is turned on again until time 12 (2.0 plus the periodicity 10.0). It
555 will be turned on again at time 13.0 until time 23.0, and so on.
556
557 Now, let's look how the same kind of thing can be done for network
558 links. A usual declaration looks like:
559
560 \verbatim
561   <link id="LinkA" bandwidth="10.0" latency="0.2"/>
562 \endverbatim
563
564 You have at your disposal the following options: bandwidth_file,
565 latency_file and state_file. The only difference with hosts is that
566 bandwidth_file and latency_file do not express fraction of available
567 power but are expressed directly in bytes per seconds and seconds.
568
569 \subsubsection faq_platform_multipath How to express multipath routing in platform files?
570
571 It is unfortunately impossible to express the fact that there is more
572 than one routing path between two given hosts. Let's consider the
573 following platform file:
574
575 \verbatim
576 <route src="A" dst="B">
577    <link:ctn id="1"/>
578 </route>
579 <route src="B" dst="C">
580   <link:ctn id="2"/>
581 </route>
582 <route src="A" dst="C">
583   <link:ctn id="3"/>
584 </route>
585 \endverbatim
586
587 Although it is perfectly valid, it does not mean that data traveling
588 from A to C can either go directly (using link 3) or through B (using
589 links 1 and 2). It simply means that the routing on the graph is not
590 trivial, and that data do not following the shortest path in number of
591 hops on this graph. Another way to say it is that there is no implicit
592 in these routing descriptions. The system will only use the routes you
593 declare (such as &lt;route src="A" dst="C"&gt;&lt;link:ctn
594 id="3"/&gt;&lt;/route&gt;), without trying to build new routes by aggregating
595 the provided ones.
596   
597 You are also free to declare platform where the routing is not
598 symmetric. For example, add the following to the previous file:
599
600 \verbatim
601 <route src="C" dst="A">
602   <link:ctn id="2"/>
603   <link:ctn id="1"/>
604 </route>
605 \endverbatim
606
607 This makes sure that data from C to A go through B where data from A
608 to C go directly. Don't worry about realism of such settings since
609 we've seen ways more weird situation in real settings (in fact, that's
610 the realism of very regular platforms which is questionable, but
611 that's another story).
612
613 \subsubsection faq_flexml_bypassing Bypassing the XML parser with your own C functions
614
615 So you want to bypass the XML files parser, uh? Maybe doing some parameter
616 sweep experiments on your simulations or so? This is possible, and
617 it's not even really difficult (well. Such a brutal idea could be
618 harder to implement). Here is how it goes.
619
620 For this, you have to first remember that the XML parsing in SimGrid is done
621 using a tool called FleXML. Given a DTD, this gives a flex-based parser. If
622 you want to bypass the parser, you need to provide some code mimicking what
623 it does and replacing it in its interactions with the SURF code. So, let's
624 have a look at these interactions.
625
626 FleXML parser are close to classical SAX parsers. It means that a
627 well-formed SimGrid platform XML file might result in the following
628 "events":
629
630   - start "platform_description" with attribute version="2"
631   - start "host" with attributes id="host1" power="1.0"
632   - end "host"
633   - start "host" with attributes id="host2" power="2.0"
634   - end "host"
635   - start "link" with ...
636   - end "link"
637   - start "route" with ...
638   - start "link:ctn" with ...
639   - end "link:ctn"
640   - end "route"
641   - end "platform_description"
642
643 The communication from the parser to the SURF code uses two means:
644 Attributes get copied into some global variables, and a surf-provided
645 function gets called by the parser for each event. For example, the event
646   - start "host" with attributes id="host1" power="1.0"
647
648 let the parser do something roughly equivalent to:
649 \verbatim
650   strcpy(A_host_id,"host1");
651   A_host_power = 1.0;
652   STag_host();
653 \endverbatim
654
655 In SURF, we attach callbacks to the different events by initializing the
656 pointer functions to some the right surf functions. Since there can be
657 more than one callback attached to the same event (if more than one
658 model is in use, for example), they are stored in a dynar. Example in
659 workstation_ptask_L07.c:
660 \verbatim
661   /* Adding callback functions */
662   surf_parse_reset_parser();
663   surfxml_add_callback(STag_surfxml_host_cb_list, &parse_cpu_init);
664   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
665   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
666   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
667   surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
668   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
669                 
670   /* Parse the file */
671   surf_parse_open(file);
672   xbt_assert(!surf_parse(), "Parse error in %s", file);
673   surf_parse_close();
674 \endverbatim
675     
676 So, to bypass the FleXML parser, you need to write your own version of the
677 surf_parse function, which should do the following:
678    - Fill the A_<tag>_<attribute> variables with the wanted values
679    - Call the corresponding STag_<tag>_fun function to simulate tag start
680    - Call the corresponding ETag_<tag>_fun function to simulate tag end
681    - (do the same for the next set of values, and loop)
682
683 Then, tell SimGrid that you want to use your own "parser" instead of the stock one:
684 \verbatim
685   surf_parse = surf_parse_bypass_environment;
686   MSG_create_environment(NULL);
687   surf_parse = surf_parse_bypass_application;
688   MSG_launch_application(NULL);
689 \endverbatim
690
691 A set of macros are provided at the end of
692 include/surf/surfxml_parse.h to ease the writing of the bypass
693 functions. An example of this trick is distributed in the file
694 examples/msg/masterslave/masterslave_bypass.c
695
696 \subsection faq_simgrid_configuration Changing SimGrid's behavior
697
698 A number of options can be given at runtime to change the default
699 SimGrid behavior. In particular, you can change the default cpu and
700 network models...
701
702 \subsubsection faq_simgrid_configuration_fullduplex Using Fullduplex
703
704 Experimental fullduplex support is now available on the svn branch. In order to fullduple to work your platform must have two links for each pair
705 of interconnected hosts, see an example here:
706 \verbatim
707         simgrid_svn_sources/exemples/msg/gtnets/fullduplex-p.xml
708 \endverbatim
709
710 Using fullduplex support ongoing and incoming communication flows are
711 treated independently for most models. The exception is the LV08 model which 
712 adds 0.05 of usage on the opposite direction for each new created flow. This 
713 can be useful to simulate some important TCP phenomena such as ack compression. 
714
715 Running a fullduplex example:
716 \verbatim
717         cd simgrid_svn_sources/exemples/msg/gtnets
718         ./gtnets fullduplex-p.xml fullduplex-d.xml --cfg=fullduplex:1
719 \endverbatim
720
721
722
723
724
725 \subsubsection faq_simgrid_configuration_gtnets Using GTNetS
726
727 It is possible to use a packet-level network simulator
728 instead of the default flow-based simulation. You may want to use such
729 an approach if you have doubts about the validity of the default model
730 or if you want to perform some validation experiments. At the moment,
731 we support the GTNetS simulator (it is still rather experimental
732 though, so leave us a message if you play with it). 
733
734
735 <i>
736 To enable GTNetS model inside SimGrid it is needed to patch the GTNetS simulator source code 
737 and build/install it from scratch
738 </i>
739
740  - <b>Download and enter the recent downloaded GTNetS directory</b>
741
742  \verbatim
743  svn checkout svn://scm.gforge.inria.fr/svn/simgrid/contrib/trunk/GTNetS/
744  cd GTNetS
745  \endverbatim
746
747
748  - <b>Use the following commands to unzip and patch GTNetS package to work within SimGrid.</b>
749
750  \verbatim
751  unzip gtnets-current.zip
752  tar zxvf gtnets-current-patch.tgz 
753  cd gtnets-current
754  cat ../00*.patch | patch -p1
755  \endverbatim
756
757   - <b>OPTIONALLY</b> you can use a patch for itanium 64bit processor family.
758
759   \verbatim
760   cat ../AMD64-FATAL-Removed-DUL_SIZE_DIFF-Added-fPIC-compillin.patch | patch -p1
761   \endverbatim
762
763  - <b>Compile GTNetS</b>
764
765    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. 
766
767
768  \verbatim
769  ln -sf Makefile.linux Makefile
770  make depend
771  make debug
772  \endverbatim
773
774
775  - <b>NOTE</b> A lot of warnings are expected but the application should compile
776  just fine. If the makefile insists in compiling some QT libraries
777  please try a make clean before asking for help.
778
779
780  - <b>To compile optimized version</b>
781
782  \verbatim
783  make opt
784  \endverbatim
785
786
787  - <b>Installing GTNetS</b>
788
789  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.
790
791  \verbatim
792  ln -sf /<absolute_path>/gtnets_current/libgtsim-debug.so /<userhome>/usr/lib/libgtnets.so
793  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/<userhome>/usr/lib/libgtnets.so
794  mkdir /<userhome>/usr/include/gtnets
795  cp -fr SRC/*.h /<userhome>/usr/include/gtnets
796  \endverbatim
797
798
799  - <b>Enable GTNetS support in SimGrid</b>
800  
801 In order to enable gtnets with simgrid you have to give where is gtnets. (path to \<gtnets_path\>/lib and \<gtnets_path\>/include)
802
803    \verbatim
804    Since v3.4 (with cmake)
805    cmake . -Dgtnets_path=/<userhome>/usr
806    
807    Until v3.4 (with autotools)
808    ./configure --with-gtnets=/<userhome>/usr
809    \endverbatim
810
811  - <b>Once you have followed all the instructions for compiling and
812    installing successfully you can activate this feature at 
813    runntime with the following options:</b>
814
815    \verbatim
816    Since v3.4 (with cmake)
817    cd simgrid
818    make
819    ctest -R gtnets
820    
821    Until v3.4 (with autotools)
822    cd simgrid/example/msg/
823    make
824    make check
825    \endverbatim
826
827
828  - <b>Or try the GTNetS model dogbone example with</b>
829
830  \verbatim
831  gtnets/gtnets gtnets/onelink-p.xml gtnets/onelink-d.xml --cfg=network_model:GTNets
832  \endverbatim
833
834  
835  A long version of this <a href="http://gforge.inria.fr/docman/view.php/12/6283/GTNetS HowTo.html">HowTo</a>  it is available 
836
837
838  More about GTNetS simulator at <a href="http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/index.html">GTNetS Website</a>
839
840
841  - <b>DISCLAIMER</b>
842  The patches provided by us worked successfully with GTNetS found 
843  <a href="http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/software/gtnets-current.zip">here</a>, 
844  dated from 12th June 2008. Due to the discontinuing development of
845  GTNetS it is impossible to precise a version number. We STRONGLY recommend you
846  to download and install the GTNetS version found in SimGrid repository as explained above.
847  
848
849
850
851 \subsubsection faq_simgrid_configuration_alternate_network Using alternative flow models
852
853 The default simgrid network model uses a max-min based approach as
854 explained in the research report
855 <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>.
856 Other models have been proposed and implemented since then (see for example 
857 <a href="http://mescal.imag.fr/membres/arnaud.legrand/articles/simutools09.pdf">Accuracy Study and Improvement of Network Simulation in the SimGrid Framework</a>)
858 and can be activated at runtime. For example:
859 \verbatim
860 ./mycode platform.xml deployment.xml --cfg=workstation/model:compound --cfg=network/model:LV08 -cfg=cpu/model:Cas01
861 \endverbatim
862
863 Possible models for the network are currently "Constant", "CM02",
864 "LegrandVelho", "GTNets", Reno", "Reno2", "Vegas". Others will
865 probably be added in the future and many of the previous ones are
866 experimental and are likely to disappear without notice... To know the
867 list of the currently  implemented models, you should use the
868 --help-models command line option.
869
870 \verbatim
871 ./masterslave_forwarder ../small_platform.xml deployment_masterslave.xml  --help-models
872 Long description of the workstation models accepted by this simulator:
873   CLM03: Default workstation model, using LV08 and CM02 as network and CPU
874   compound: Workstation model allowing you to use other network and CPU models
875   ptask_L07: Workstation model with better parallel task modeling
876 Long description of the CPU models accepted by this simulator:
877   Cas01_fullupdate: CPU classical model time=size/power
878   Cas01: Variation of Cas01_fullupdate with partial invalidation optimization of lmm system. Should produce the same values, only faster
879   CpuTI: Variation of Cas01 with also trace integration. Should produce the same values, only faster if you use availability traces
880 Long description of the network models accepted by this simulator:
881   Constant: Simplistic network model where all communication take a constant time (one second)
882   CM02: Realistic network model with lmm_solve and no correction factors
883   LV08: Realistic network model with lmm_solve and these correction factors: latency*=10.4, bandwidth*=.92, S=8775
884   Reno: Model using lagrange_solve instead of lmm_solve (experts only)
885   Reno2: Model using lagrange_solve instead of lmm_solve (experts only)
886   Vegas: Model using lagrange_solve instead of lmm_solve (experts only)
887 \endverbatim
888
889 \subsection faq_tracing Tracing Simulations for Visualization
890
891 The trace visualization is widely used to observe and understand the behavior
892 of parallel applications and distributed algorithms. Usually, this is done in a
893 two-step fashion: the user instruments the application and the traces are
894 analyzed after the end of the execution. The visualization itself can highlights
895 unexpected behaviors, bottlenecks and sometimes can be used to correct
896 distributed algorithms. The SimGrid team has instrumented the library
897 in order to let users trace their simulations and analyze them. This part of the
898 user manual explains how the tracing-related features can be enabled and used
899 during the development of simulators using the SimGrid library.
900
901 \subsubsection faq_tracing_howitworks How it works
902
903 For now, the SimGrid library is instrumented so users can trace the <b>platform
904 utilization</b> using the MSG, SimDAG and SMPI interface. This means that the tracing will
905 register how much power is used for each host and how much bandwidth is used for
906 each link of the platform. The idea with this type of tracing is to observe the
907 overall view of resources utilization in the first place, especially the
908 identification of bottlenecks, load-balancing among hosts, and so on.
909
910 The idea of the tracing facilities is to give SimGrid users to possibility to
911 classify MSG and SimDAG tasks by category, tracing the platform utilization
912 (hosts and links) for each of the categories. For that,
913 the tracing interface enables the declaration of categories and a function to
914 mark a task with a previously declared category. <em>The tasks that are not
915 classified according to a category are not traced</em>. Even if the user
916 does not specify any category, the simulations can still be traced in terms
917 of resource utilization by using a special parameter that is detailed below.
918
919 \subsubsection faq_tracing_enabling Enabling using CMake
920
921 With the sources of SimGrid, it is possible to enable the tracing 
922 using the parameter <b>-Denable_tracing=ON</b> when the cmake is executed.
923 The section \ref faq_tracing_functions describes all the functions available
924 when this Cmake options is activated. These functions will have no effect
925 if SimGrid is configured without this option (they are wiped-out by the
926 C-preprocessor).
927
928 \verbatim
929 $ cmake -Denable_tracing=ON .
930 $ make
931 \endverbatim
932
933 \subsubsection faq_tracing_functions Tracing Functions
934
935 \li <b>\c TRACE_category (const char *category)</b>: This function should be used
936 to define a user category. The category can be used to differentiate the tasks
937 that are created during the simulation (for example, tasks from server1,
938 server2, or request tasks, computation tasks, communication tasks).
939 All resource utilization (host power and link bandwidth) will be
940 classified according to the task category. Tasks that do not belong to a
941 category are not traced. The color for the category that is being declared
942 is random (use next function to specify a color).
943
944 \li <b>\c TRACE_category_with_color (const char *category, const char *color)</b>: Same
945 as TRACE_category, but let user specify a color encoded as a RGB-like string with
946 three floats from 0 to 1. So, to specify a red color, the user can pass "1 0 0" as
947 color parameter. A light-gray color can be specified using "0.7 0.7 0.7" as color.
948
949 \li <b>\c TRACE_msg_set_task_category (m_task_t task, const char *category)</b>:
950 This function should be called after the creation of a MSG task, to define the
951 category of that task. The first parameter \c task must contain a task that was
952 created with the function \c MSG_task_create. The second parameter
953 \c category must contain a category that was previously defined by the function
954 \c TRACE_category.
955
956 \li <b>\c TRACE_sd_set_task_category (SD_task_t task, const char *category)</b>:
957 This function should be called after the creation of a SimDAG task, to define the
958 category of that task. The first parameter \c task must contain a task that was
959 created with the function \c MSG_task_create. The second parameter
960 \c category must contain a category that was previously defined by the function
961 \c TRACE_category.
962
963 \li <b>\c TRACE_[host|link]_variable_declare (const char *variable)</b>:
964 Declare a user variable that will be associated to host/link. A variable can
965 be used to trace user variables such as the number of tasks in a server,
966 the number of clients in an application (for hosts), and so on.
967
968 \li <b>\c TRACE_[host|link]_variable_[set|add|sub] (const char *[host|link], const char *variable, double value)</b>:
969 Set the value of a given user variable for a given host/link. The value
970 of this variable is always associated to the host/link. The host/link 
971 parameters should be its name as the one listed in the platform file.
972
973 \li <b>\c TRACE_[host|link]_variable_[set|add|sub]_with_time (double time, const char *[host|link], const char *variable, double value)</b>:
974 Same as TRACE_[host|link]_variable_[set|add|sub], but let user specify
975 the time used to trace it. Users can specify a time that is not the 
976 simulated clock time as defined by the core simulator. This allows
977 a fine-grain control of time definition, but should be used with 
978 caution since the trace can be inconsistent if resource utilization
979 traces are also traced.
980
981 \li <b>\c TRACE_link_srcdst_variable_[set|add|sub] (const char *src, const char *dst, const char *variable, double value)</b>:
982 Same as TRACE_link_variable_[set|add|sub], but now users specify a source and
983 destination hosts (as the names from the platform file). The tracing library
984 will get the corresponding route that connects those two hosts (src and dst) and
985 [set|add|sub] the value's variable for all the links of the route.
986
987 \li <b>\c TRACE_link_srcdst_variable_[set|add|sub]_with_time (double time, const char *src, const char *dst, const char *variable, double value)</b>: 
988 Same as TRACE_link_srcdst_variable_[set|add|sub], but user specify a time different from the simulated time.
989
990 \subsubsection faq_tracing_options Tracing configuration Options
991
992 These are the options accepted by the tracing system of SimGrid:
993
994 \li <b>\c 
995 tracing
996 </b>:
997   Safe switch. It activates (or deactivates) the tracing system.
998   No other tracing options take effect if this one is not activated.
999
1000 \li <b>\c
1001 tracing/platform
1002 </b>:
1003   Register the simulation platform in the trace file.
1004
1005 \li <b>\c
1006 tracing/onelink_only
1007 </b>:
1008   By default, the tracing system uses all routes in the platform file
1009   to re-create a "graph" of the platform and register it in the trace file.
1010   This option let the user tell the tracing system to use only the routes
1011   that are composed with just one link.
1012
1013 \li <b>\c 
1014 tracing/categorized
1015 </b>:
1016   It activates the categorized resource utilization tracing. It should
1017   be enabled if tracing categories are used by this simulator.
1018
1019 \li <b>\c 
1020 tracing/uncategorized
1021 </b>:
1022   It activates the uncategorized resource utilization tracing. Use it if
1023   this simulator do not use tracing categories and resource use have to be
1024   traced.
1025
1026 \li <b>\c 
1027 tracing/filename
1028 </b>:
1029   A file with this name will be created to register the simulation. The file
1030   is in the Paje format and can be analyzed using Triva or Paje visualization
1031   tools. More information can be found in these webpages:
1032      <a href="http://triva.gforge.inria.fr/">http://triva.gforge.inria.fr/</a>
1033      <a href="http://paje.sourceforge.net/">http://paje.sourceforge.net/</a>
1034
1035 \li <b>\c 
1036 tracing/smpi
1037 </b>:
1038   This option only has effect if this simulator is SMPI-based. Traces the MPI
1039   interface and generates a trace that can be analyzed using Gantt-like
1040   visualizations. Every MPI function (implemented by SMPI) is transformed in a
1041   state, and point-to-point communications can be analyzed with arrows.
1042
1043 \li <b>\c 
1044 tracing/smpi/group
1045 </b>:
1046   This option only has effect if this simulator is SMPI-based. The processes
1047   are grouped by the hosts where they were executed.
1048
1049 \li <b>\c 
1050 tracing/msg/task
1051 </b>:
1052   This option only has effect if this simulator is MSG-based. It traces the
1053   behavior of all categorized MSG tasks, grouping them by hosts.
1054
1055 \li <b>\c 
1056 tracing/msg/process
1057 </b>:
1058   This option only has effect if this simulator is MSG-based. It traces the
1059   behavior of all categorized MSG processes, grouping them by hosts. This option
1060   can be used to track process location if this simulator has process migration.
1061
1062
1063 \li <b>\c 
1064 triva/categorized:graph_categorized.plist
1065 </b>:
1066   This option generates a graph configuration file for Triva considering
1067   categorized resource utilization.
1068
1069 \li <b>\c 
1070 triva/uncategorized:graph_uncategorized.plist
1071 </b>:
1072   This option generates a graph configuration file for Triva considering
1073   uncategorized resource utilization.
1074
1075 \subsubsection faq_tracing_example Example of Instrumentation
1076
1077 A simplified example using the tracing mandatory functions.
1078
1079 \verbatim
1080 int main (int argc, char **argv)
1081 {
1082   MSG_global_init (&argc, &argv);
1083
1084   //(... after deployment ...)
1085
1086   //note that category declaration must be called after MSG_create_environment
1087   TRACE_category_with_color ("request", "1 0 0");
1088   TRACE_category_with_color ("computation", "0.3 1 0.4");
1089   TRACE_category ("finalize");
1090
1091   m_task_t req1 = MSG_task_create("1st_request_task", 10, 10, NULL);
1092   m_task_t req2 = MSG_task_create("2nd_request_task", 10, 10, NULL);
1093   m_task_t req3 = MSG_task_create("3rd_request_task", 10, 10, NULL);
1094   m_task_t req4 = MSG_task_create("4th_request_task", 10, 10, NULL);
1095   TRACE_msg_set_task_category (req1, "request");
1096   TRACE_msg_set_task_category (req2, "request");
1097   TRACE_msg_set_task_category (req3, "request");
1098   TRACE_msg_set_task_category (req4, "request");
1099
1100   m_task_t comp = MSG_task_create ("comp_task", 100, 100, NULL);
1101   TRACE_msg_set_task_category (comp, "computation");
1102
1103   m_task_t finalize = MSG_task_create ("finalize", 0, 0, NULL);
1104   TRACE_msg_set_task_category (finalize, "finalize");
1105
1106   //(...)
1107
1108   MSG_clean();
1109   return 0;
1110 }
1111 \endverbatim
1112
1113 \subsubsection faq_tracing_analyzing Analyzing the SimGrid Traces
1114
1115 The SimGrid library, during an instrumented simulation, creates a trace file in
1116 the Paje file format that contains the platform utilization for the simulation
1117 that was executed. The visualization analysis of this file is performed with the
1118 visualization tool <a href="http://triva.gforge.inria.fr">Triva</a>, with
1119 special configurations tunned to SimGrid needs. This part of the documentation
1120 explains how to configure and use Triva to analyse a SimGrid trace file.
1121
1122 - <b>Installing Triva</b>: the tool is available in the INRIAGforge, 
1123 at <a href="http://triva.gforge.inria.fr">http://triva.gforge.inria.fr</a>.
1124 Use the following command to get the sources, and then check the file
1125 <i>INSTALL</i>. This file contains instructions to install
1126 the tool's dependencies in a Ubuntu/Debian Linux. The tool can also
1127 be compiled in MacOSes natively, check <i>INSTALL.mac</i> file.
1128 \verbatim
1129 $ svn checkout svn://scm.gforge.inria.fr/svn/triva
1130 $ cd triva
1131 $ cat INSTALL
1132 \endverbatim
1133
1134 - <b>Executing Triva</b>: a binary called <i>Triva</i> is available after the
1135   installation (you can execute it passing <em>--help</em> to check its
1136 options). If the triva binary is not available after following the
1137 installation instructions, you may want to execute the following command to
1138 initialize the GNUstep environment variables. We strongly recommend that you
1139 use the latest GNUstep packages, and not the packages available through apt-get
1140 in Ubuntu/Debian packaging systems. If you install GNUstep using the latest
1141 available packages, you can execute this command:
1142 \verbatim
1143 $ source /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
1144 \endverbatim
1145 You should be able to see this output after the installation of triva:
1146 \verbatim
1147 $ ./Triva.app/Triva --help
1148 Usage: Triva [OPTIONS...] TRACE0 [TRACE1]
1149 Trace Analysis through Visualization
1150
1151 TimeInterval
1152     --ti_frequency {double}    Animation: frequency of updates
1153     --ti_hide                  Hide the TimeInterval window
1154     --ti_forward {double}      Animation: value to move time-slice
1155     --ti_apply                 Apply the configuration
1156     --ti_update                Update on slider change
1157     --ti_animate               Start animation
1158     --ti_start {double}        Start of time slice
1159     --ti_size {double}         Size of time slice
1160 Triva
1161     --comparison               Compare Trace Files (Experimental)
1162     --graph                    Configurable Graph
1163     --list                     Print Trace Type Hierarchy
1164     --hierarchy                Export Trace Type Hierarchy (dot)
1165     --stat                     Trace Statistics and Memory Utilization
1166     --instances                List All Trace Entities
1167     --linkview                 Link View (Experimental)
1168     --treemap                  Squarified Treemap
1169     --merge                    Merge Trace Files (Experimental)
1170     --check                    Check Trace File Integrity
1171 GraphConfiguration
1172     --gc_conf {file}           Graph Configuration in Property List Format
1173     --gc_apply                 Apply the configuration
1174     --gc_hide                  Hide the GraphConfiguration window
1175 \endverbatim
1176 Triva expects that the user choose one of the available options 
1177 (currently <em>--graph</em> or <em>--treemap</em> for a visualization analysis)
1178 and the trace file from the simulation.
1179
1180 - <b>Understanding Triva - time-slice</b>: the analysis of a trace file using
1181   the tool always takes into account the concept of the <em>time-slice</em>.
1182 This concept means that what is being visualized in the screen is always
1183 calculated considering a specific time frame, with its beggining and end
1184 timestamp. The time-slice is configured by the user and can be changed
1185 dynamically through the window called <em>Time Interval</em> that is opened
1186 whenever a trace file is being analyzed. The next figure depicts the time-slice
1187 configuration window.
1188 In the top of the window, in the space named <i>Trace Time</i>,
1189 the two fields show the beggining of the trace (which usually starts in 0) and
1190 the end (that depends on the time simulated by SimGrid). The middle of the
1191 window, in the square named <i>Time Slice Configuration</i>, contains the
1192 aspects related to the time-slice, including its <i>start</i> and its
1193 <i>size</i>. The gray rectangle in the bottom of this part indicates the 
1194 <i>current time-slice</i> that is considered for the drawings. If the checkbox 
1195 <i>Update Drawings on Sliders Change</i> is not selected, the button
1196 <i>Apply</i> must be clicked in order to inform triva that the
1197 new time-slice must be considered. The bottom part of the window, in the space
1198 indicated by the square <i>Time Slice Animation</i> can be used to advance
1199 the time-frame automatically. The user configures the amount of time that the
1200 time-frame will forward and how frequent this update will happen. Once this is
1201 configured, the user clicks the <i>Play</i> button in order to see the dynamic
1202 changes on the drawings.
1203 <center>
1204 \htmlonly
1205 <a href="triva-time_interval.png" border=0><img src="triva-time_interval.png" width="50%" border=0></a>
1206 \endhtmlonly
1207 </center>
1208 <b>Remarks:</b> when the trace has too many hosts or links, the computation to
1209 take into account a new time-slice can be expensive. When this happens, the
1210 <i>Frequency</i> parameter, but also updates caused by change on configurations
1211 when the checkbox <i>Update Drawings on Sliders
1212 Change</i> is selected will not be followed.
1213
1214 - <b>Understanding Triva - graph</b>: this part of the documention explains how
1215   to analyze the traces using the graph view of Triva, when the user executes
1216 the tool passing <em>--graph</em> as parameter. Triva opens three windows when
1217 this parameter is used: the <i>Time Interval</i> window (previously described),
1218 the <i>Graph Representation</i> window, and the <em>Graph Configuration</em>
1219 window. The Graph Representation is the window where drawings take place.
1220 Initially, it is completely white waiting for a proper graph configuration input
1221 by the user. We start the description of this type of analysis by describing the
1222 <i>Graph Configuration</i> window (depicted below). By using a particular
1223 configuration, triva
1224 can be used to customize the graph drawing according to
1225 the SimGrid trace that was created with user-specific categories. Before delving
1226 into the details of this customization, let us first explain the major parts of
1227 the graph configuration window. The buttons located in the top-right corner can
1228 be used to delete, copy and create a new configuration. The checkbox in the
1229 top-middle part of the window indicates if the configuration typed in the
1230 textfield is syntactically correct (we are using the non-XML 
1231 <a href="http://en.wikipedia.org/wiki/Property_list">Property List Format</a> to
1232 describe the configuration). The pop-up button located on the top-left corner 
1233 indicates the selected configuration (the user can have multiple graph
1234 configurations). The bottom-left text field contains the name of the current
1235 configuration (updates on this field must be followed by typing enter on the
1236 keyboard to take into account the name change). The bottom-right <em>Apply</em>
1237 button activates the current configuration, resulting on an update on the graph
1238 drawings.
1239 <center>
1240 \htmlonly
1241 <a href="triva-graph_configuration.png" border=0><img src="triva-graph_configuration.png" width="50%" border=0></a>
1242 \endhtmlonly
1243 </center>
1244 <b>Basic SimGrid Configuration</b>: The figure shows in the big textfield the
1245 basic configuration that should be used during the analysis of a SimGrid trace
1246 file. The basic logic of the configuration is as follows:
1247 \verbatim
1248 {
1249   node = (HOST);
1250   edge = (LINK);
1251 \endverbatim
1252 The nodes of the graph will be created based on the <i>node</i> parameter, which
1253 in this case is the different <em>"HOST"</em>s of the platform 
1254 used to simulate. The <i>edge</i> parameter indicates that the edges of the
1255 graph will be created based on the <em>"LINK"</em>s of the platform. After the
1256 definition of these two parameters, the configuration must detail how
1257 <em>HOST</em>s and <em>LINK</em>s should be drawn. For that, the configuration
1258 must have an entry for each of the types used. For <em>HOST</em>, as basic
1259 configuration, we have:
1260 \verbatim
1261   HOST = {
1262     size = power;
1263     scale = global;
1264   };
1265 \endverbatim
1266 The parameter <em>size</em> indicates which variable from the trace file will be
1267 used to define the size of the node HOST in the visualization. If the simulation
1268 was executed with availability traces, the size of the nodes will be changed
1269 according to these traces. The parameter <em>scale</em> indicates if the value
1270 of the variable is <em>global</em> or <em>local</em>. If it is global, the value
1271 will be relative to the power of all other hosts, if it is local, the value will
1272 be relative locally.
1273 For <em>LINK</em> we have:
1274 \verbatim
1275   LINK = {
1276     src = source;
1277     dst = destination;
1278     
1279     size = bandwidth;
1280     scale = global;
1281   };
1282 \endverbatim
1283 For the types specified in the <em>edge</em> parameter (such as <em>LINK</em>),
1284 the configuration must contain two additional parameters: <em>src</em> and
1285 <em>dst</em> that are used to properly identify which nodes this edge is
1286 connecting. The values <em>source</em> and <em>destination</em> are always present
1287 in the SimGrid trace file and should not be changed in the configuration. The
1288 parameter <em>size</em> for the LINK, in this case, is configured as the
1289 variable <em>bandwidth</em>, with a <em>global</em> scale. The scale meaning
1290 here is exactly the same used for nodes. The last parameter is the GraphViz
1291 algorithm used to calculate the position of the nodes in the graph
1292 representation.
1293 \verbatim
1294   graphviz-algorithm = neato;
1295 }
1296 \endverbatim
1297 <b>Customizing the Graph Representation</b>: triva is capable to handle
1298 a customized graph representation based on the variables present in the trace
1299 file. In the case of SimGrid, every time a category is created for tasks, two
1300 variables in the trace file are defined: one to indicate node utilization (how
1301 much power was used by that task category), and another to indicate link
1302 utilization (how much bandwidth was used by that category). For instance, if the
1303 user declares a category named <i>request</i>, there will be variables named
1304 <b>p</b><i>request</i> and a <b>b</b><i>request</i> (<b>p</b> for power and
1305 <b>b</b> for bandwidth). It is important to notice that the variable
1306 <i>prequest</i> in this case is only available for HOST, and
1307 <i>brequest</i> is only available for LINK. <b>Example</b>: suppose there are
1308 two categories for tasks: request and compute. To create a customized graph
1309 representation with a proportional separation of host and link utilization, use
1310 as configuration for HOST and LINK this:
1311 \verbatim
1312   HOST = {
1313     size = power;
1314     scale = global;
1315   
1316     sep_host = {
1317       type = separation;
1318       size = power;
1319       values = (prequest, pcomputation);
1320     };
1321   };
1322
1323   LINK = {
1324     src = source;
1325     dst = destination;
1326     size = bandwidth;
1327     scale = global;
1328
1329     sep_link = {
1330       type = separation;
1331       size = bandwidth;
1332       values = (brequest, bcomputation);
1333     };
1334   };
1335 \endverbatim
1336 Where <i>sep_host</i> contains a composition of type <i>separation</i> where
1337 its max size is the <i>power</i> of the host and the variables <i>prequest</i>
1338 and <i>pcomputation</i> are drawn proportionally to the size of the HOST. And
1339 <i>sep_link</i> is also a separation where max is defined as the
1340 <i>bandwidth</i> of the link, and the variables <i>brequest</i> and
1341 <i>bcomputation</i> are drawn proportionally within a LINK.
1342 <i>This configuration enables the analysis of resource utilization by MSG tasks,
1343 and the identification of load-balancing issues, network bottlenecks, for
1344 instance.</i> \n
1345 <b>Other compositions</b>: besides <i>separation</i>, it is possible to use
1346 other types of compositions, such as gradients, and colors, like this:
1347 \verbatim
1348     gra_host = {
1349       type = gradient;
1350       scale = global;
1351       values = (numberOfTasks);
1352     };
1353     color_host = {
1354       type = color;
1355       values = (is_server);
1356     };
1357 \endverbatim
1358 Where <i>gra_host</i> creates a gradient within a node of the graph, using a
1359 global scale and using as value a variable called <i>numberOfTasks</i>, that
1360 could be declared by the user using the optional tracing functions of SimGrid.
1361 If scale is global, the max and min value for the gradient will be equal to the
1362 max and min numberOfTasks among all hosts, and if scale is local, the max and
1363 min value based on the value of numberOfTasks locally in each host.
1364 And <i>color_host</i> composition draws a square based on a positive value of
1365 the variable <i>is_server</i>, that could also be defined by the user using the
1366 SimGrid tracing functions. \n
1367 <b>The Graph Visualization</b>: The next figure shows a graph visualization of a
1368 given time-slice of the masterslave_forwarder example (present in the SimGrid
1369 sources). The red color indicates tasks from the <i>compute</i> category. This
1370 visualization was generated with the following configuration:
1371 \verbatim
1372 {
1373   node = (HOST);
1374   edge = (LINK);
1375
1376   HOST = {
1377     size = power;
1378     scale = global;
1379   
1380     sep_host = {
1381       type = separation;
1382       size = power;
1383       values = (pcompute, pfinalize);
1384     };
1385   };
1386   LINK = {
1387     src = source;
1388     dst = destination;
1389     size = bandwidth;
1390     scale = global;
1391
1392     sep_link = {
1393       type = separation;
1394       size = bandwidth;
1395       values = (bcompute, bfinalize);
1396     };
1397   };
1398   graphviz-algorithm = neato;
1399 }
1400 \endverbatim
1401 <center>
1402 \htmlonly
1403 <a href="triva-graph_visualization.png" border=0><img src="triva-graph_visualization.png" width="50%" border=0></a>
1404 \endhtmlonly
1405 </center>
1406
1407 - <b>Understading Triva - colors</b>: An important issue when using Triva is how
1408   to define colors. To do that, we have to know which variables are defined in
1409 the trace file generated by the SimGrid library. The parameter <em>--list</em> 
1410 lists the variables for a given trace file:
1411 \verbatim
1412 $ Triva -l masterslave_forwarder.trace
1413 iFile
1414 c  platform
1415 c    HOST
1416 v     power
1417 v     is_slave
1418 v     is_master
1419 v     task_creation
1420 v     task_computation
1421 v     pcompute
1422 v     pfinalize
1423 c    LINK
1424 v     bandwidth
1425 v     latency
1426 v     bcompute
1427 v     bfinalize
1428 c  user_type
1429 \endverbatim
1430 We can see that HOST has seven variables (from power to pfinalize) and LINK has
1431 four (from bandwidth to bfinalize). To define a red color for the
1432 <i>pcompute</i> and <i>bcompute</i> (which are defined based on user category
1433 <i>compute</i>), execute:
1434 \verbatim
1435 $ defaults write Triva 'pcompute Color' '1 0 0'
1436 $ defaults write Triva 'bcompute Color' '1 0 0'
1437 \endverbatim
1438 Where the three numbers in each line are the RGB color with values from 0 to 1.
1439
1440 \subsection faq_modelchecking Model-Checking
1441 \subsubsection faq_modelchecking_howto How to use it
1442 To enable the experimental SimGrid model-checking support the program should
1443 be executed with the command line argument 
1444 \verbatim
1445 --cfg=model-check:1 
1446 \endverbatim
1447 Properties are expressed as assertions using the function
1448 \verbatim
1449 void MC_assert(int prop);
1450 \endverbatim
1451
1452 \section faq_troubleshooting Troubleshooting
1453
1454 \subsection faq_trouble_lib_compil SimGrid compilation and installation problems
1455
1456 \subsubsection faq_trouble_lib_config cmake fails!
1457
1458 We know only one reason for the configure to fail:
1459
1460  - <b>You are using a broken build environment</b>\n
1461    If symptom is that the configury magic complains about gcc not being able to build
1462    executables, you are probably missing the libc6-dev package. Damn Ubuntu.
1463
1464 If you experience other kind of issue, please get in touch with us. We are
1465 always interested in improving our portability to new systems.
1466
1467 \subsubsection faq_trouble_distcheck Dude! "ctest" fails on my machine!
1468
1469 Don't assume we never run this target, because we do. Check
1470 http://cdash.inria.fr/CDash/index.php?project=Simgrid (click on
1471 previous if there is no result for today: results are produced only by
1472 11am, French time) and
1473 https://buildd.debian.org/status/logs.php?pkg=simgrid if you don't believe us. 
1474
1475 If it's failing on your machine in a way not experienced by the
1476 autobuilders above, please drop us a mail on the mailing list so that
1477 we can check it out. Make sure to read \ref faq_bugrepport before you
1478 do so.
1479
1480 \subsection faq_trouble_compil User code compilation problems
1481
1482 \subsubsection faq_trouble_err_logcat "gcc: _simgrid_this_log_category_does_not_exist__??? undeclared (first use in this function)"
1483
1484 This is because you are using the log mecanism, but you didn't created
1485 any default category in this file. You should refer to \ref XBT_log
1486 for all the details, but you simply forgot to call one of
1487 XBT_LOG_NEW_DEFAULT_CATEGORY() or XBT_LOG_NEW_DEFAULT_SUBCATEGORY().
1488
1489 \subsubsection faq_trouble_pthreadstatic "gcc: undefined reference to pthread_key_create"
1490
1491 This indicates that one of the library SimGrid depends on (libpthread
1492 here) was missing on the linking command line. Dependencies of
1493 libsimgrid are expressed directly in the dynamic library, so it's
1494 quite impossible that you see this message when doing dynamic linking. 
1495
1496 If you compile your code statically (and if you use a pthread version
1497 of SimGrid -- see \ref faq_more_processes), you must absolutely
1498 specify <tt>-lpthread</tt> on the linker command line. As usual, this should
1499 come after <tt>-lsimgrid</tt> on this command line.
1500
1501 \subsection faq_trouble_errors Runtime error messages
1502
1503 \subsubsection faq_flexml_limit "surf_parse_lex: Assertion `next limit' failed."
1504
1505 This is because your platform file is too big for the parser. 
1506
1507 Actually, the message comes directly from FleXML, the technology on top of
1508 which the parser is built. FleXML has the bad idea of fetching the whole
1509 document in memory before parsing it. And moreover, the memory buffer size
1510 must be determined at compilation time.
1511
1512 We use a value which seems big enough for our need without bloating the
1513 simulators footprints. But of course your mileage may vary. In this case,
1514 just edit src/surf/surfxml.l modify the definition of
1515 FLEXML_BUFFERSTACKSIZE. E.g.
1516
1517 \verbatim
1518 #define FLEXML_BUFFERSTACKSIZE 1000000000
1519 \endverbatim
1520
1521 Then recompile and everything should be fine, provided that your version of
1522 Flex is recent enough (>= 2.5.31). If not the compilation process should
1523 warn you.
1524
1525 A while ago, we worked on FleXML to reduce a bit its memory consumption, but
1526 these issues remain. There is two things we should do:
1527
1528   - use a dynamic buffer instead of a static one so that the only limit
1529     becomes your memory, not a stupid constant fixed at compilation time
1530     (maybe not so difficult).
1531   - change the parser so that it does not need to get the whole file in
1532     memory before parsing
1533     (seems quite difficult, but I'm a complete newbe wrt flex stuff).
1534
1535 These are changes to FleXML itself, not SimGrid. But since we kinda hijacked
1536 the development of FleXML, I can grant you that any patches would be really
1537 welcome and quickly integrated.
1538
1539 <b>Update:</b> A new version of FleXML (1.7) was released. Most of the work
1540 was done by William Dowling, who use it in his own work. The good point is
1541 that it now use a dynamic buffer, and that the memory usage was greatly
1542 improved. The downside is that William also changed some things internally,
1543 and it breaks the hack we devised to bypass the parser, as explained in 
1544 \ref faq_flexml_bypassing. Indeed, this is not a classical usage of the
1545 parser, and Will didn't imagine that we may have used (and even documented)
1546 such a crude usage of FleXML. So, we now have to repair the bypassing
1547 functionality to use the lastest FleXML version and fix the memory usage in
1548 SimGrid.
1549
1550 \subsubsection faq_trouble_gras_transport GRAS spits networking error messages
1551
1552 Gras, on real platforms, naturally use regular sockets to communicate. They
1553 are deeply hidden in the gras abstraction, but when things go wrong, you may
1554 get some weird error messages. Here are some example, with the probable
1555 reason:
1556
1557  - <b>Transport endpoint is not connected</b>: several processes try to open
1558    a server socket on the same port number of the same machine. This is
1559    naturally bad and each process should pick its own port number for this.\n
1560    Maybe, you just have some processes remaining from a previous experiment 
1561    on your machine.\n
1562    Killing them may help, but again if you kill -KILL them, you'll have to
1563    wait for a while: they didn't close there sockets properly and the system
1564    needs a while to notice that this port is free again.
1565
1566  - <b>Socket closed by remote side</b>: if the remote process is not
1567    supposed to close the socket at this point, it may be dead.
1568    
1569  - <b>Connection reset by peer</b>: I found this on Internet about this
1570    error. I think it's what's happening here, too:\n   
1571    <i>This basically means that a network error occurred while the client was
1572    receiving data from the server. But what is really happening is that the
1573    server actually accepts the connection, processes the request, and sends
1574    a reply to the client. However, when the server closes the socket, the
1575    client believes that the connection has been terminated abnormally
1576    because the socket implementation sends a TCP reset segment telling the
1577    client to throw away the data and report an error.\n
1578    Sometimes, this problem is caused by not properly closing the
1579    input/output streams and the socket connection. Make sure you close the
1580    input/output streams and socket connection properly. If everything is
1581    closed properly, however, and the problem persists, you can work around
1582    it by adding a one-second sleep before closing the streams and the
1583    socket. This technique, however, is not reliable and may not work on all
1584    systems.</i>\n
1585    Since GRAS sockets are closed properly (repeat after me: there is no bug
1586    in GRAS), it is either that you are closing your sockets on server side
1587    before the client get a chance to read them (use gras_os_sleep() to delay
1588    the server), or the server died awfully before the client got the data.
1589
1590 \subsubsection faq_trouble_errors_big_fat_warning I'm told that my XML files are too old.
1591
1592 The format of the XML platform description files is sometimes
1593 improved. For example, we decided to change the units used in SimGrid
1594 from MBytes, MFlops and seconds to Bytes, Flops and seconds to ease
1595 people exchanging small messages. We also reworked the route
1596 descriptions to allow more compact descriptions.
1597
1598 That is why the XML files are versionned using the 'version' attribute
1599 of the root tag. Currently, it should read:
1600 \verbatim
1601   <platform version="2">
1602 \endverbatim
1603
1604 If your files are too old, you can use the simgrid_update_xml.pl
1605 script which can be found in the tools directory of the archive.
1606
1607 \subsection faq_trouble_valgrind Valgrind-related and other debugger issues
1608
1609 If you don't, you really should use valgrind to debug your code, it's
1610 almost magic.
1611
1612 \subsubsection faq_trouble_vg_longjmp longjmp madness in valgrind
1613
1614 This is when valgrind starts complaining about longjmp things, just like:
1615
1616 \verbatim ==21434== Conditional jump or move depends on uninitialised value(s)
1617 ==21434==    at 0x420DBE5: longjmp (longjmp.c:33)
1618 ==21434==
1619 ==21434== Use of uninitialised value of size 4
1620 ==21434==    at 0x420DC3A: __longjmp (__longjmp.S:48)
1621 \endverbatim
1622
1623 This is the sign that you didn't used the exception mecanism well. Most
1624 probably, you have a <tt>return;</tt> somewhere within a <tt>TRY{}</tt>
1625 block. This is <b>evil</b>, and you must not do this. Did you read the section
1626 about \ref XBT_ex??
1627
1628 \subsubsection faq_trouble_vg_libc Valgrind spits tons of errors about backtraces!
1629
1630 It may happen that valgrind, the memory debugger beloved by any decent C
1631 programmer, spits tons of warnings like the following :
1632 \verbatim ==8414== Conditional jump or move depends on uninitialised value(s)
1633 ==8414==    at 0x400882D: (within /lib/ld-2.3.6.so)
1634 ==8414==    by 0x414EDE9: (within /lib/tls/i686/cmov/libc-2.3.6.so)
1635 ==8414==    by 0x400B105: (within /lib/ld-2.3.6.so)
1636 ==8414==    by 0x414F937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
1637 ==8414==    by 0x4150F4C: (within /lib/tls/i686/cmov/libc-2.3.6.so)
1638 ==8414==    by 0x400B105: (within /lib/ld-2.3.6.so)
1639 ==8414==    by 0x415102D: __libc_dlopen_mode (in /lib/tls/i686/cmov/libc-2.3.6.so)
1640 ==8414==    by 0x412D6B9: backtrace (in /lib/tls/i686/cmov/libc-2.3.6.so)
1641 ==8414==    by 0x8076446: xbt_dictelm_get_ext (dict_elm.c:714)
1642 ==8414==    by 0x80764C1: xbt_dictelm_get (dict_elm.c:732)
1643 ==8414==    by 0x8079010: xbt_cfg_register (config.c:208)
1644 ==8414==    by 0x806821B: MSG_config (msg_config.c:42)
1645 \endverbatim
1646
1647 This problem is somewhere in the libc when using the backtraces and there is
1648 very few things we can do ourselves to fix it. Instead, here is how to tell
1649 valgrind to ignore the error. Add the following to your ~/.valgrind.supp (or
1650 create this file on need). Make sure to change the obj line according to
1651 your personnal mileage (change 2.3.6 to the actual version you are using,
1652 which you can retrieve with a simple "ls /lib/ld*.so").
1653
1654 \verbatim {
1655    name: Backtrace madness
1656    Memcheck:Cond
1657    obj:/lib/ld-2.3.6.so
1658    fun:dl_open_worker
1659    fun:_dl_open
1660    fun:do_dlopen
1661    fun:dlerror_run
1662    fun:__libc_dlopen_mode
1663 }\endverbatim
1664
1665 Then, you have to specify valgrind to use this suppression file by passing
1666 the <tt>--suppressions=$HOME/.valgrind.supp</tt> option on the command line.
1667 You can also add the following to your ~/.bashrc so that it gets passed
1668 automatically. Actually, it passes a bit more options to valgrind, and this
1669 happen to be my personnal settings. Check the valgrind documentation for
1670 more information.
1671
1672 \verbatim export VALGRIND_OPTS="--leak-check=yes --leak-resolution=high --num-callers=40 --tool=memcheck --suppressions=$HOME/.valgrind.supp" \endverbatim
1673
1674 \subsubsection faq_trouble_backtraces Truncated backtraces
1675
1676 When debugging SimGrid, it's easier to pass the
1677 --disable-compiler-optimization flag to the configure if valgrind or
1678 gdb get fooled by the optimization done by the compiler. But you
1679 should remove these flag when everything works before going in
1680 production (before launching your 1252135 experiments), or everything
1681 will run only one half of the true SimGrid potential.
1682
1683 \subsection faq_deadlock There is a deadlock in my code!!!
1684
1685 Unfortunately, we cannot debug every code written in SimGrid.  We
1686 furthermore believe that the framework provides ways enough
1687 information to debug such informations yourself. If the textual output
1688 is not enough, Make sure to check the \ref faq_visualization FAQ entry to see
1689 how to get a graphical one.
1690
1691 Now, if you come up with a really simple example that deadlocks and
1692 you're absolutely convinced that it should not, you can ask on the
1693 list. Just be aware that you'll be severely punished if the mistake is
1694 on your side... We have plenty of FAQ entries to redact and new
1695 features to implement for the impenitents! ;)
1696
1697 \subsection faq_surf_network_latency I get weird timings when I play with the latencies.
1698
1699 OK, first of all, remember that units should be Bytes, Flops and
1700 Seconds. If you don't use such units, some SimGrid constants (e.g. the
1701 SG_TCP_CTE_GAMMA constant used in most network models) won't have the
1702 right unit and you'll end up with weird results.
1703
1704 Here is what happens with a single transfer of size L on a link
1705 (bw,lat) when nothing else happens.
1706
1707 \verbatim
1708 0-----lat--------------------------------------------------t
1709 |-----|**** real_bw =min(bw,SG_TCP_CTE_GAMMA/(2*lat)) *****|
1710 \endverbatim
1711
1712 In more complex situations, this min is the solution of a complex
1713 max-min linear system.  Have a look 
1714 <a href="http://lists.gforge.inria.fr/pipermail/simgrid-devel/2006-April/thread.html">here</a>
1715 and read the two threads "Bug in SURF?" and "Surf bug not
1716 fixed?". You'll have a few other examples of such computations. You
1717 can also read "A Network Model for Simulation of Grid Application" by
1718 Henri Casanova and Loris Marchal to have all the details. The fact
1719 that the real_bw is smaller than bw is easy to understand. The fact
1720 that real_bw is smaller than SG_TCP_CTE_GAMMA/(2*lat) is due to the
1721 window-based congestion mechanism of TCP. With TCP, you can't exploit
1722 your huge network capacity if you don't have a good round-trip-time
1723 because of the acks...
1724
1725 Anyway, what you get is t=lat + L/min(bw,SG_TCP_CTE_GAMMA/(2*lat)).
1726
1727   * if I you set (bw,lat)=(100 000 000, 0.00001), you get t =  1.00001 (you fully
1728 use your link)
1729   * if I you set (bw,lat)=(100 000 000, 0.0001),  you get t =  1.0001 (you're on the
1730 limit)
1731   * if I you set (bw,lat)=(100 000 000, 0.001),   you get t = 10.001  (ouch!)
1732
1733 This bound on the effective bandwidth of a flow is not the only thing
1734 that may make your result be unexpected. For example, two flows
1735 competing on a saturated link receive an amount of bandwidth inversely
1736 proportional to their round trip time.
1737
1738 \subsection faq_bugrepport So I've found a bug in SimGrid. How to report it?
1739
1740 We do our best to make sure to hammer away any bugs of SimGrid, but this is
1741 still an academic project so please be patient if/when you find bugs in it.
1742 If you do, the best solution is to drop an email either on the simgrid-user
1743 or the simgrid-devel mailing list and explain us about the issue.  You can
1744 also decide to open a formal bug report using the
1745 <a href="https://gforge.inria.fr/tracker/?atid=165&group_id=12&func=browse">relevant
1746 interface</a>. You need to login on the server to get the ability to submit
1747 bugs. 
1748
1749 We will do our best to solve any problem repported, but you need to help us
1750 finding the issue. Just telling "it segfault" isn't enough. Telling "It
1751 segfaults when running the attached simulator" doesn't really help either.
1752 You may find the following article interesting to see how to repport
1753 informative bug repports:
1754 http://www.chiark.greenend.org.uk/~sgtatham/bugs.html (it is not SimGrid
1755 specific at all, but it's full of good advices).
1756
1757 \author Arnaud Legrand (arnaud.legrand::imag.fr)
1758 \author Martin Quinson (martin.quinson::loria.fr)
1759
1760
1761 */
1762
1763 ******************************************************************
1764 *              OLD CRUFT NOT USED ANYMORE                        *
1765 ******************************************************************
1766
1767
1768 \subsection faq_crosscompile Cross-compiling a Windows DLL of SimGrid from linux
1769
1770 At the moment, we do not distribute Windows pre-compiled version of SimGrid
1771 because the support for this platform is still experimental. We know that
1772 some parts of the GRAS environment do not work, and we think that the others
1773 environments (MSG and SD) have good chances to work, but we didn't test
1774 ourselves. This section explains how we generate the SimGrid DLL so that you
1775 can build it for yourself. First of all, you need to have a version more
1776 recent than 3.1 (ie, a SVN version as time of writting).
1777
1778 In order to cross-compile the package to windows from linux, you need to
1779 install mingw32 (minimalist gnu win32). On Debian, you can do so by
1780 installing the packages mingw32 (compiler), mingw32-binutils (linker and
1781 so), mingw32-runtime.
1782
1783 You can use the VPATH support of configure to compile at the same time for
1784 linux and windows without dupplicating the source nor cleaning the tree
1785 between each. Just run bootstrap (if you use the SVN) to run the autotools.
1786 Then, create a linux and a win directories. Then, type:
1787 \verbatim  cd linux; ../configure --srcdir=.. <usual configure flags>; make; cd ..
1788 cd win;  ../configure --srcdir=.. --host=i586-mingw32msvc <flags>; make; cd ..
1789 \endverbatim
1790 The trick to VPATH builds is to call configure from another directory,
1791 passing it an extra --srcdir argument to tell it where all the sources are.
1792 It will understand you want to use VPATH. Then, the trick to cross-compile
1793 is simply to add a --host argument specifying the target you want to build
1794 for. The i586-mingw32msvc string is what you have to pass to use the mingw32
1795 environment as distributed in Debian.
1796
1797 After that, you can run all make targets from both directories, and test
1798 easily that what you change for one arch does not break the other one. 
1799
1800 It is possible that this VPATH build thing breaks from time to time in the
1801 SVN since it's quite fragile, but it's granted to work in any released
1802 version. If you experience problems, drop us a mail. 
1803
1804 Another possible source of issue is that at the moment, building the
1805 examples request to use the gras_stub_generator tool, which is a compiled
1806 program, not a script. In cross-compilation, you need to cross-execute with
1807 wine for example, which is not really pleasant. We are working on this, but
1808 in the meanwhile, simply don't build the examples in cross-compilation
1809 (<tt>cd src</tt> before running make).
1810     
1811 Program (cross-)compiled with mingw32 do request an extra DLL at run-time to be
1812 usable. For example, if you want to test your build with wine, you should do
1813 the following to put this library where wine looks for DLLs.
1814 \verbatim 
1815 cp /usr/share/doc/mingw32-runtime/mingwm10.dll.gz ~/.wine/c/windows/system/
1816 gunzip ~/.wine/c/windows/system/mingwm10.dll.gz
1817 \endverbatim
1818
1819 The DLL is built in src/.libs, and installed in the <i>prefix</i>/bin directory
1820 when you run make install. 
1821
1822 If you want to use it in a native project on windows, you need to use 
1823 simgrid.dll and mingwm10.dll. For each DLL, you need to build .def file
1824 under linux (listing the defined symbols), and convert it into a .lib file
1825 under windows (specifying this in a way that windows compilers like). To
1826 generate the def files, run (under linux):
1827 \verbatim echo "LIBRARY libsimgrid-0.dll" > simgrid.def
1828 echo EXPORTS >> simgrid.def
1829 nm libsimgrid-0.dll | grep ' T _' | sed 's/.* T _//' >> simgrid.def
1830 nm libsimgrid-0.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> simgrid.def
1831
1832 echo "LIBRARY mingwm10.dll" > mingwm10.def
1833 echo EXPORTS >> mingwm10.def
1834 nm mingwm10.dll | grep ' T _' | sed 's/.* T _//' >> mingwm10.def
1835 nm mingwm10.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> mingwm10.def
1836 \endverbatim
1837
1838 To create the import .lib files, use the <tt>lib</tt> windows tool (from
1839 MSVC) the following way to produce simgrid.lib and mingwm10.lib
1840 \verbatim lib /def:simgrid.def
1841 lib /def:mingwm10.def
1842 \endverbatim
1843
1844 If you happen to use Borland C Builder, the right command line is the
1845 following (note that you don't need any file.def to get this working).
1846 \verbatim implib simgrid.lib libsimgrid-0.dll
1847 implib mingwm10.lib mingwm10.dll
1848 \endverbatim
1849
1850 Then, set the following parameters in Visual C++ 2005:
1851 Linker -> Input -> Additional dependencies = simgrid.lib mingwm10.lib
1852
1853 Just in case you wonder how to generate a DLL from libtool in another
1854 project, we added -no-undefined to any lib*_la_LDFLAGS variables so that
1855 libtool accepts to generate a dynamic library under windows. Then, to make
1856 it true, we pass any dependencies (such as -lws2 under windows or -lpthread
1857 on need) on the linking line. Passing such deps is a good idea anyway so
1858 that they get noted in the library itself, avoiding the users to know about
1859 our dependencies and put them manually on their compilation line. Then we
1860 added the AC_LIBTOOL_WIN32_DLL macro just before AC_PROG_LIBTOOL in the
1861 configure.ac. It means that we exported any symbols which need to be.
1862 Nowadays, functions get automatically exported, so we don't need to load our
1863 header files with tons of __declspec(dllexport) cruft. We only need to do so
1864 for data, but there is no public data in SimGrid so we are good.
1865
1866