1 /*! \page faq Frequently Asked Questions
3 \htmlinclude .FAQ.doc.toc
5 \section faq_installation Installing the SimGrid library
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>.
14 \subsection faq_compiling Compiling SimGrid from an archive
16 First of all, you need to download the latest version of SimGrid from
17 <a href="http://gforge.inria.fr/frs/?group_id=12">here</a>.
18 Suppose you have uncompressed SimGrid in some temporary location of
19 your home directory (say <tt>/home/joe/tmp/simgrid-3.0.1 </tt>). The
20 simplest way to use SimGrid is to install it in your home
21 directory. Change your directory to
22 <tt>/home/joe/tmp/simgrid-3.0.1</tt> and type
24 \verbatim./configure --prefix=$HOME
29 If at some point, something fails, check the section "\ref
30 faq_compil_trouble". If it does not help, you can report this problem to the
31 list but, please, avoid sending a laconic mail like "There is a problem. Is it
32 okay?". Send the config.log file which is automatically generated by
33 configure. Try to capture both the standard output and the error output of the
34 <tt>make</tt> command with <tt>script</tt>. There is no way for us to help you
35 without the relevant bits of information.
37 Now, the following directory should have been created :
39 \li <tt>/home/joe/doc/simgrid/html/</tt>
40 \li <tt>/home/joe/lib/</tt>
41 \li <tt>/home/joe/include/</tt>
43 SimGrid is not a binary, it is a library. Both a static and a dynamic
44 version are available. Here is what you can find if you try a <tt>ls
47 \verbatim libsimgrid.a libsimgrid.la libsimgrid.so libsimgrid.so.0 libsimgrid.so.0.0.1
50 Thus, there is two ways to link your program with SimGrid:
51 \li Either you use the static version, e.g
52 \verbatim gcc libsimgrid.a -o MainProgram MainProgram.c
54 In this case, all the SimGrid functions are directly
55 included in <tt>MainProgram</tt> (hence a bigger binary).
56 \li Either you use the dynamic version (the preferred method)
57 \verbatim gcc -lsimgrid -o MainProgram MainProgram.c
59 In this case, the SimGrid functions are not included in
60 <tt>MainProgram</tt> and you need to set your environment
61 variable in such a way that <tt>libsimgrid.so</tt> will be
62 found at runtime. This can be done by adding the following
63 line in your .bashrc (if you use bash and if you have
64 installed the SimGrid libraries in your home directory):
65 \verbatim export LD_LIBRARY_PATH=$HOME/lib/:$LD_LIBRARY_PATH
69 \subsection faq_compiling_cvs Compiling SimGrid from the CVS
71 The project development takes place in the cvs, where all changes are
72 commited when they happen. Then every once in a while, we make sure that the
73 code quality meets our standard and release an archive from the code in the
74 CVS. We afterward go back to the development in the CVS. So, if you need a
75 recently added feature and can afford some little problem with the stability
76 of the lastest features, you may want to use the CVS version instead of a
79 For that, you first need to get the "simgrid" module from
80 <a href="http://gforge.inria.fr/scm/?group_id=12">here</a>.
82 You won't find any <tt>configure</tt> and a few other things
83 (<tt>Makefile.in</tt>'s, documentation, ...) will be missing as
84 well. The reason for that is that all these files have to be
85 regenerated using the latest versions of <tt>autoconf</tt>,
86 <tt>automake</tt> (1.9) and <tt>doxygen</tt>. To generate the
87 <tt>configure</tt> and the <tt>Makefile.in</tt>'s, you just have to
88 launch the <tt>bootstrap</tt> command that resides in the top of the
89 source tree. Then just follow the instructions of Section
92 We insist on the fact that you really need the latest versions of
93 autoconf and automake. Doing this step on exotic architectures/systems
94 (i.e. anything different from a recent linux distribution) may be
95 ... uncertain. If you want to use the CVS version on another
96 architecture/system, you should do the previous steps on a perfectly
97 standard box, then do a <tt>make dist</tt> that will build you a
98 perfectly portable SimGrid archive.
100 In summary, the following commands will checkout the CVS, regenerate the
101 configure script and friends, configure SimGrid and build an archive you can
102 use on another machine afterward.
104 \verbatim cvs -d :pserver:anonymous@scm.gforge.inria.fr:/cvsroot/simgrid login
105 cvs -d :pserver:anonymous@scm.gforge.inria.fr:/cvsroot/simgrid checkout simgrid
108 ./configure --enable-maintainer-mode
109 make dist \endverbatim
111 \subsection faq_setting Setting up your own code
113 Do not build your simulator by modifying the SimGrid examples. Go
114 outside the SimGrid source tree and create your own working directory
115 (say <tt>/home/joe/SimGrid/MyFirstScheduler/</tt>).
117 Suppose your simulation has the following structure (remember it is
118 just an example to illustrate a possible way to compile everything;
119 feel free to organize it as you want).
121 \li <tt>sched.h</tt>: a description of the core of the
122 scheduler (i.e. which functions are can be used by the
123 agents). For example we could find the following functions
124 (master, forwarder, slave).
126 \li <tt>sched.c</tt>: a C file including <tt>sched.h</tt> and
127 implementing the core of the scheduler. Most of these
128 functions use the MSG functions defined in section \ref
131 \li <tt>masterslave.c</tt>: a C file with the main function, i.e.
132 the MSG initialization (MSG_global_init()), the platform
133 creation (e.g. with MSG_create_environment()), the
134 deployment phase (e.g. with MSG_function_register() and
135 MSG_launch_application()) and the call to
138 To compile such a program, we suggest to use the following
139 Makefile. It is a generic Makefile that we have used many times with
140 our students when we teach the C language.
144 masterslave: masterslave.o sched.o
146 INSTALL_PATH = $$HOME
148 PEDANTIC_PARANOID_FREAK = -O0 -Wshadow -Wcast-align \
149 -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
150 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
151 -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
152 -Wpointer-arith -Wwrite-strings -finline-functions
153 REASONABLY_CAREFUL_DUDE = -Wall
154 NO_PRAYER_FOR_THE_WICKED = -w -O2
155 WARNINGS = $(REASONABLY_CAREFUL_DUDE)
156 CFLAGS = -g $(WARNINGS)
158 INCLUDES = -I$(INSTALL_PATH)/include
159 DEFS = -L$(INSTALL_PATH)/lib/
160 LDADD = -lm -lsimgrid
164 $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@
167 $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
170 rm -f $(BIN_FILES) *.o *~
176 The first two lines indicates what should be build when typing make
177 (<tt>masterslave</tt>) and of which files it is to be made of
178 (<tt>masterslave.o</tt> and <tt>sched.o</tt>). This makefile assumes
179 that you have set up correctly your <tt>LD_LIBRARY_PATH</tt> variable
180 (look, there is a <tt>LDADD = -lm -lsimgrid</tt>). If you prefer using
181 the static version, remove the <tt>-lsimgrid</tt> and add a
182 <tt>$(INSTALL_PATH)/lib/libsimgrid.a</tt> on the next line, right
183 after the <tt>LIBS = </tt>.
185 More generally, if you have never written a Makefile by yourself, type
186 in a terminal : <tt>info make</tt> and read the introduction. The
187 previous example should be enough for a first try but you may want to
188 perform some more complex compilations...
190 \section faq_simgrid I'm new to SimGrid. I have some questions. Where should I start?
192 You are at the right place... Having a look to these
193 <a href="http://graal.ens-lyon.fr/~alegrand/articles/slides_g5k_simul.pdf">slides</a>
195 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">"obsolete" slides</a>)
196 may give you some insights on what SimGrid can help you to do and what
197 are its limitations. Then you definitely should read the \ref
198 MSG_examples. There is also a mailing list: <simgrid-user@lists.gforge.inria.fr>.
200 \subsection faq_generic Building a generic simulator
202 Please read carefully the \ref MSG_examples. You'll find in \ref
203 MSG_ex_master_slave a very simple consisting of a master (that owns a bunch of
204 tasks and distributes them) , some slaves (that process tasks whenever
205 they receive one) and some forwarder agents (that simply pass the
206 tasks they receive to some slaves).
208 \subsection faq_visualization Visualizing the schedule
210 It is sometime convenient to "see" how the agents are behaving. If you
211 like colors, you can use <tt>tools/MSG_visualization/colorize.pl </tt>
212 as a filter to your MSG outputs. It works directly with INFO. Beware,
213 INFO() prints on stderr. Do not forget to redirect if you want to
214 filter (e.g. with bash):
216 ./msg_test small_platform.xml small_deployment.xml 2>&1 | ../../tools/MSG_visualization/colorize.pl
219 We also have a more graphical output. Have a look at MSG_paje_output(). It
220 generates an input to <a href="http://www-id.imag.fr/Logiciels/paje/">Paje</a>.
223 <a href="Paje_MSG_screenshot.jpg"><img src="Paje_MSG_screenshot_thn.jpg"></a>
227 \subsection faq_postmortem_analysis Online/postmortem analysis
229 Vizualization with Paje can be seen as a kind of postmortem
230 analysis. However, as soon as you start playing with big simulations,
231 you'll realize that processing such output is kind of tricky. There is
232 so much generic informations that it is hard to find the information
235 As a matter of fact, loging really depends on simulations (e.g. what
236 kind of events is important...). That is why we do not propose a big
237 dump of your whole simulation (it would slow everything down) but give
238 you neat tools to structure you logs. Have a look at \ref XBT_log. In
239 fact, rather than a post-mortem analysis, you may want to do it on the
240 fly. The process you are running can do whatever you want. Have you
241 thought about adding a global structure where you directly compute the
242 informations that are really important rather than writing everything
243 down and then processing huge files ?
245 \subsection faq_C Argh! Do I really have to code in C ?
247 Up until now, there is no binding for other languages. If you use C++,
248 you should be able to use the SimGrid library as a standard C library
249 and everything should work fine (simply <i>link</i> against this
250 library; recompiling SimGrid with a C++ compiler won't work and it
251 wouldn't help if you could).
253 In fact, the bindings needed to allow one to use SimGrid from Perl,
254 Python, Java, etc. are double-layered. The first layer would allow
255 you to call for example the MSG_task_get_name(task) function while
256 what you really want is a proper object wrapping allowing you to call
257 task->name(). That's the purpose of the second layer. The first one
258 is granted with C++ but can be done with tools like
259 <a href="www.swig.org/">swig</a> for other languages like Perl, Ruby,
260 Python, CAML. None of us really need the second one (which is a bit
261 more demanding and cannot be automatically generated) yet and there is
262 no real point in doing the first one without the second. :)
264 As usual, you're welcome to participate.
266 \section faq_MIA How to ....? Is there a function in the API to simply ....?
268 Here is the deal. The whole SimGrid project (MSG, SURF, GRAS, ...) is
269 meant to be kept as simple and generic as possible. We cannot add
270 functions for everybody's need when these functions can easily be
271 built from the ones already in the API. Most of the time, it is
272 possible and when it was not possible we always have upgraded the API
273 accordingly. When somebody asks us a question like "How to do that ?
274 Is there a function in the API to simply do this ?", we're always glad
275 to answer and help. However if we don't need this code for our own
276 need, there is no chance we're going to write it... it's your job! :)
277 The counterpart to our answers is that once you come up with a neat
278 implementation of this feature (task duplication, RPC, thread
279 synchronization, ...), you should send it to us and we will be glad to
280 add it to the distribution. Thus, other people will take advantage of
281 it (and we don't have to answer this question again and again ;).
283 You'll find in this section a few "Missing In Action" features. Many
284 people have asked about it and we have given hints on how to simply do
285 it with MSG. Feel free to contribute...
287 \subsection faq_MIA_examples I want some more complex examples!
289 Many people have come to ask me a more complex example and each time,
290 they have realized afterward that the basics were in the previous three
293 Of course they have often been needing more complex functions like
294 MSG_process_suspend(), MSG_process_resume() and
295 MSG_process_isSuspended() (to perform synchronization), or
296 MSG_task_Iprobe() and MSG_process_sleep() (to avoid blocking
297 receptions), or even MSG_process_create() (to design asynchronous
298 communications or computations). But the examples are sufficient to
301 We know. We should add some more examples, but not really some more
302 complex ones... We should add some examples that illustrate some other
303 functionalities (like how to simply encode asynchronous
304 communications, RPC, process migrations, thread synchronization, ...)
305 and we will do it when we will have a little bit more time. We have
306 tried to document the examples so that they are understandable. Tell
307 us if something is not clear and once again feel free to participate!
310 \subsection faq_MIA_taskdup Missing in action: Task duplication/replication
312 There is no task duplication in MSG. When you create a task, you can
313 process it or send it somewhere else. As soon as a process has sent
314 this task, he doesn't have this task anymore. It's gone. The receiver
315 process has got the task. However, you could decide upon receiving to
316 create a "copy" of a task but you have to handle by yourself the
317 semantic associated to this "duplication".
319 As we already told, we prefer keeping the API as simple as
320 possible. This kind of feature is rather easy to implement by users
321 and the semantic you associate really depends on people. Having a
322 *generic* task duplication mechanism is not that trivial (in
323 particular because of the data field). That is why I would recommand
324 that you write it by yourself even if I can give you advice on how to
327 You have the following functions to get informations about a task:
328 MSG_task_get_name(), MSG_task_get_compute_duration(),
329 MSG_task_get_remaining_computation(), MSG_task_get_data_size(),
330 and MSG_task_get_data().
332 You could use a dictionnary (#xbt_dict_t) of dynars (#xbt_dict_t). If
333 you still don't see how to do it, please come back to us...
335 \subsection faq_MIA_asynchronous I want to do asynchronous communications.
337 Up until now, there is no asynchronous communications in MSG. However,
338 you can create as many process as you want so you should be able to do
339 whatever you want... I've written a queue module to help implementing
340 some asynchronous communications at low cost (creating thousands of
341 process only to handle communications may be problematic in term of
342 performance at some point). I'll add it in the distribution asap.
344 \subsection faq_MIA_thread_synchronization I need to synchronize my processes
346 You obviously cannot use pthread_mutexes of pthread_conds. The best
347 thing would be to propose similar structures. Unfortunately, we
348 haven't found time to do it yet. However you can try to play with
349 MSG_process_suspend() and MSG_process_resume(). You can even do some
350 synchronization with fake communications (using MSG_task_get(),
351 MSG_task_put() and MSG_task_Iprobe()).
353 \subsection faq_MIA_host_load Where is the get_host_load function hidden in MSG?
355 There is no such thing because its semantic wouldn't be really
356 clear. Of course, it is something about the amount of host throughput,
357 but there is as many definition of "host load" as people asking for
358 this function. First, you have to remember that resource availability
359 may vary over time, which make any load notion harder to define.
361 It may be instantaneous value or an average one. Moreover it may be only the
362 power of the computer, or may take the background load into account, or may
363 even take the currently running tasks into account. In some SURF models,
364 communications have an influence on computational power. Should it be taken
367 So, we decided not to include such a function into MSG and let people do it
368 thereselves so that they get the value matching exactly what they mean. One
369 possibility is to run active measurement as in next code snippet. It is very
370 close from what you would have to do out of the simulator, and thus gives
371 you information that you could also get in real settings to not hinder the
372 realism of your simulation.
375 double get_host_load() {
376 m_task_t task = MSG_task_create("test", 0.001, 0, NULL);
377 double date = MSG_get_clock();
379 MSG_task_execute(task);
380 date = MSG_get_clock() - date;
381 MSG_task_destroy(task);
386 Of course, it may not match your personal definition of "host load". In this
387 case, please detail what you mean on the mailing list, and we will extend
388 this FAQ section to fit your taste if possible.
390 \subsection faq_MIA_batch_scheduler Is there a native support for batch schedulers in SimGrid ?
392 No, there is no native support for batch schedulers and none is
393 planned because this is a very specific need (and doing it in a
394 generic way is thus very hard). However some people have implemented
395 their own batch schedulers. Vincent Garonne wrote one during his PhD
396 and put his code in the contrib directory of our CVS so that other can
397 keep working on it. You may find inspinring ideas in it.
399 \subsection faq_MIA_checkpointing I need a checkpointing thing
401 Actually, it depends on whether you want to checkpoint the simulation, or to
402 simulate checkpoints.
404 The first one could help if your simulation is a long standing process you
405 want to keep running even on hardware issues. It could also help to
406 <i>rewind</i> the simulation by jumping sometimes on an old checkpoint to
407 cancel recent calculations.\n
408 Unfortunately, such thing will probably never exist in SG. One would have to
409 duplicate all data structures because doing a rewind at the simulator level
410 is very very hard (not talking about the malloc free operations that might
411 have been done in between). Instead, you may be interested in the Libckpt
412 library (http://www.cs.utk.edu/~plank/plank/www/libckpt.html). This is the
413 checkpointing solution used in the condor project, for example. It makes it
414 easy to create checkpoints (at the OS level, creating something like core
415 files), and rerunning them on need.
417 If you want to simulate checkpoints instead, it means that you want the
418 state of an executing task (in particular, the progress made towards
419 completion) to be saved somewhere. So if a host (and the task executing on
420 it) fails (cf. #MSG_HOST_FAILURE), then the task can be restarted
421 from the last checkpoint.\n
423 Actually, such a thing does not exists in SimGrid either, but it's just
424 because we don't think it is fundamental and it may be done in the user code
425 at relatively low cost. You could for example use a watcher that
426 periodically get the remaining amount of things to do (using
427 MSG_task_get_remaining_computation()), or fragment the task in smaller
430 \section faq_SG Where has SG disappeared?!?
432 OK, it's time to explain what's happening to the SimGrid project. Let's
433 start with a little bit of history.
435 * Historically, SimGrid was a low-level toolkit for scheduling with
436 classical models such as DAGs. That was SimGrid v.1.* aka SG, written
437 by Henri Casanova. I (Arnaud) had been using it in its earliest
438 versions during an internship at UCSD.
440 Then we have realized that encoding distributed algorithm in SG was a
443 * So we have built MSG on top of SG and have released SimGrid v.2.*. MSG
444 offered a very basic API to encode a distributed application easily.
445 However encoding MSG on top of SG was not really convenient and did not
446 use the DAG part since the control of the task synchronization was done
447 on top of MSG and no more in SG. We have been playing a little bit with
448 MSG. We have realized that:
450 \li 1) the platform modeling was quite flexible and could be "almost"
451 automated (e.g. using random generator and post-annotations);
453 \li 2) SG was the bottleneck because of the way we were using
454 it. We needed to simulate concurrent transfers, complex load
455 sharing mechanisms. Many optimizations (e.g. trace integration)
456 were totally inefficient when combined with MSG and made extending SG
457 to implement new sharing policies, parallel tasks models, or failures
458 (many people were asking for these kind of features) a real pain;
460 \li 3) the application modeling was not really easy. Even though the
461 application modeling depends on people's applications, we thought
462 we could improve things here. One of our target here was realistic
463 distributed applications ranging from computer sensor networks like
464 the NWS to peer-to-peer applications;
466 * So we have been planning mainly two things for SimGrid 3:
468 \li 1) I have proposed to get rid of SG and to re-implement a new kernel
469 that would be faster and more flexible. That is what I did in the
470 end of 2004: SURF. SURF is based on a fast max-min linear solver
471 using O(1) data-structures. I have quickly replaced SG by SURF in
472 MSG and the result has been that on the MSG example, the new
473 version was more than 10 times faster while we had gain a lot of
474 flexibility. I think I could still easily make MSG faster but I
475 have to work on MSG now (e.g. using some of the O(1)
476 data-structures I've been using to build SURF) since it has become
477 the bottleneck. Some MSG functions have been removed from the API
478 but they were mainly intended to build the platform by hand (they
479 had appeared in the earliest versions of MSG) and were therefore
480 not useful anymore since we are providing a complete mechanism to
481 automatically build the platform and deploy the agents on it.;
483 \li 2) GRAS is a new project Martin and I have come up with. The idea is
484 to have a programming environment that let you program real
485 distributed applications while letting you the ability to run it in
486 the simulator without having to change the slightest line of your
487 code. From the simulation point of view, GRAS performs the
488 application modeling automatically... Up until now, GRAS works on
489 top MSG for historical reasons but I'm going to make it work
490 directly on top of SURF so that it can use all the flex and the
491 speed provided by SURF.
493 Those two things are working, but we want to make everything as clean as
494 possible before releasing SimGrid v.3.
496 So what about those nice DAGs we used to have in SimGrid v.1.? They're not
497 anymore in SimGrid v.3. Let me recall you the way SimGrid 3 is organized:
511 XBT is our tool box and now, you should have an idea of what the other ones
512 are. As you can see, the primitive SG is not here anymore. However it could
513 still be brought back if people really need it. Here is how it would fit.
516 ______________________
518 |____________________|
519 | | MSG | GRAS | SG |
520 | -------------------|
522 | -------------------|
524 ----------------------
527 Re-implementing SG on top of SURF is really straightforward (it only
528 requires a little bit of time that I really don't have right now)
529 since the only thing that lacks to SURF is the DAG part. But adding it
530 to SURF would slow it down and therefore slow MSG and GRAS which is
531 not a good thing. However it is really not on the top of our TODO
532 list because we have to work on GRAS, and its MPI counterpart, and a
533 parallel task model, and ... Anyway, we finally have migrated our CVS
534 to gforge so people that are interested by helping on this part will
535 have the possibility to do it.
537 \subsection faq_SG_DAG How to implement a distributed dynamic scheduler of DAGs.
539 Distributed is somehow "contagious". If you start making distributed
540 decisions, there is no way to handle DAGs directly anymore (unless I am
541 missing something). You have to encode your DAGs in term of communicating
542 process to make the whole scheduling process distributed. Believe me, it is
543 worth the effort since you'll then be able to try your algorithms in a very
544 wide variety of conditions. Here is an example of how you could do that.
545 Assume T1 has to be done before T2.
548 int your_agent(int argc, char *argv[] {
550 T1 = MSG_task_create(...);
551 T2 = MSG_task_create(...);
555 if(cond) MSG_task_execute(T1);
557 if((MSG_task_get_remaining_computation(T1)=0.0) && (you_re_in_a_good_mood))
560 /* do something else */
566 If you decide that the distributed part is not that much important and that
567 DAG is really the level of abstraction you want to work with (but it
568 prevents you from having "realistic" platform modeling), then you should
569 keep using the 2.18.5 versions until somebody has ported SG on top of SURF.
570 Note however that SURF will be slower than the old SG to handle traces with
571 a lots of variations (there is no trace integration anymore).
573 \subsection faq_SG_future Will SG come back in the maintained branch one day?
575 Sure. In fact, we already have thought about a new and cleaner API:
577 void* SG_link_get_data(SG_link_t link);
578 void SG_link_set_data(SG_link_t link, void *data);
579 const char* SG_link_get_name(SG_link_t link);
580 double SG_link_get_capacity(SG_link_t link);
581 double SG_link_get_current_bandwidth(SG_link_t link);
582 double SG_link_get_current_latency(SG_link_t link);
584 SG_workstation_t SG_workstation_get_by_name(const char *name);
585 SG_workstation_t* SG_workstation_get_list(void);
586 int SG_workstation_get_number(void);
587 void SG_workstation_set_data(SG_workstation_t workstation, void *data);
588 void * SG_workstation_get_data(SG_workstation_t workstation);
589 const char* SG_workstation_get_name(SG_workstation_t workstation);
590 SG_link_t* SG_workstation_route_get_list(SG_workstation_t src, SG_workstation_t dst);
591 int SG_workstation_route_get_size(SG_workstation_t src, SG_workstation_t dst);
592 double SG_workstation_get_power(SG_workstation_t workstation);
593 double SG_workstation_get_available_power(SG_workstation_t workstation);
595 SG_task_t SG_task_create(const char *name, void *data, double amount);
596 int SG_task_schedule(SG_task_t task, int workstation_nb,
597 SG_workstation_t **workstation_list, double *computation_amount,
598 double *communication_amount, double rate);
600 void* SG_task_get_data(SG_task_t task);
601 void SG_task_set_data(SG_task_t task, void *data);
602 const char* SG_task_get_name(SG_task_t task);
603 double SG_task_get_amount(SG_task_t task);
604 double SG_task_get_remaining_amount(SG_task_t task);
605 void SG_task_dependency_add(const char *name, void *data, SG_task_t src, SG_task_t dst);
606 void SG_task_dependency_remove(SG_task_t src, SG_task_t dst);
607 e_SG_task_state_t SG_task_state_get(SG_task_t task); /* e_SG_task_state_t can be either SG_SCHEDULED, SG_RUNNING, SG_DONE, or SG_FAILED */
608 void SG_task_watch(SG_task_t task, e_SG_task_state_t state); /* SG_simulate will stop as soon as the state of this task is the one given in argument.
609 Watch-point is then automatically removed */
610 void SG_task_unwatch(SG_task_t task, e_SG_task_state_t state);
612 void SG_task_unschedule(SG_task_t task); /* change state and rerun.. */
614 SG_task_t *SG_simulate(double how_long); /* returns a NULL-terminated array of SG_task_t whose state has changed */
617 We're just looking for somebody to implement it... :)
619 \section faq_dynamic Dynamic resources and platform building
621 \subsection faq_platform Building a realistic platform
623 We can speak more than an hour on this subject and we still do not have
624 the right answer, just some ideas. You can read the following
625 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">slides</a>.
626 It may give you some hints. You can also have a look at the
627 <tt>tools/platform_generation/</tt> directory. There is a perl-script
628 we use to annotate a Tiers generated platform.
630 \subsection faq_SURF_dynamic How can I have variable resource availability?
632 A nice feature of SimGrid is that it enables you to seamlessly have
633 resources whose availability change over time. When you build a
634 platform, you generally declare CPUs like that:
637 <cpu name="Cpu A" power="100.00"/>
640 If you want the availability of "CPU A" to change over time, the only
641 thing you have to do is change this definition like that:
644 <cpu name="Cpu A" power="100.00" availability_file="trace_A.txt" state_file="trace_A_failure.txt"/>
647 For CPUs, availability files are expressed in fraction of available
648 power. Let's have a look at what "trace_A.txt" may look like:
657 At time 0, our CPU will deliver 100 Mflop/s. At time 11.0, it will
658 deliver only 50 Mflop/s until time 20.0 where it will will start
659 delivering 90 Mflop/s. Last at time 21.0 (20.0 plus the periodicity
660 1.0), we'll be back to the beginning and it will deliver 100Mflop/s.
662 Now let's look at the state file:
669 A negative value means "off" while a positive one means "on". At time
670 1.0, the CPU is on. At time 1.0, it is turned off and at time 2.0, it
671 is turned on again until time 12 (2.0 plus the periodicity 10.0). It
672 will be turned on again at time 13.0 until time 23.0, and so on.
674 Now, let's look how the same kind of thing can be done for network
675 links. A usual declaration looks like:
678 <network_link name="LinkA" bandwidth="10.0" latency="0.2"/>
681 You have at your disposal the following options: bandwidth_file,
682 latency_file and state_file. The only difference with CPUs is that
683 bandwidth_file and latency_file do not express fraction of available
684 power but are expressed directly in Mb/s and seconds.
686 \subsection faq_flexml_bypassing How can I have some C functions do what the platform file does?
688 So you want to bypass the XML files parser, uh? Maybe doin some parameter
689 sweep experiments on your simulations or so? This is possible, but it's not
690 really easy. Here is how it goes.
692 For this, you have to first remember that the XML parsing in SimGrid is done
693 using a tool called FleXML. Given a DTD, this gives a flex-based parser. If
694 you want to bypass the parser, you need to provide some code mimicking what
695 it does and replacing it in its interactions with the SURF code. So, let's
696 have a look at these interactions.
698 FleXML parser are close to classical SAX parsers. It means that a
699 well-formed SimGrid platform XML file might result in the following
702 - start "platform_description"
703 - start "cpu" with attributes name="host1" power="1.0"
705 - start "cpu" with attributes name="host2" power="2.0"
707 - start "network_link" with ...
709 - start "route" with ...
711 - start "route" with ...
713 - end "platform_description"
715 The communication from the parser to the SURF code uses two means:
716 Attributes get copied into some global variables, and a surf-provided
717 function gets called by the parser for each event. For example, the event
718 - start "cpu" with attributes name="host1" power="1.0"
720 let the parser do the equivalent of:
722 strcpy("host1",A_cpu_name);
727 In SURF, we attach callbacks to the different events by initializing the
728 pointer functions to some the right surf functions. Example in
729 workstation_KCCFLN05.c (surf_parse_open() ends up calling surf_parse()):
731 // Building the routes
732 surf_parse_reset_parser();
733 STag_route_fun=parse_route_set_endpoints;
734 ETag_route_element_fun=parse_route_elem;
735 ETag_route_fun=parse_route_set_route;
736 surf_parse_open(file);
737 xbt_assert1((!surf_parse()),"Parse error in %s",file);
741 So, to bypass the FleXML parser, you need to write your own version of the
742 surf_parse function, which should do the following:
743 - Call the corresponding STag_<tag>_fun function to simulate tag start
744 - Fill the A_<tag>_<attribute> variables with the wanted values
745 - Call the corresponding ETag_<tag>_fun function to simulate tag end
746 - (do the same for the next set of values, and loop)
748 Then, tell SimGrid that you want to use your own "parser" instead of the stock one:
750 surf_parse = surf_parse_bypass;
751 MSG_create_environment(NULL);
754 An example of this trick is distributed in the file examples/msg/msg_test_surfxml_bypassed.c
756 \section faq_troubleshooting Troubleshooting
758 \subsection faq_compil_trouble ./configure fails!
760 We now only one reason for the configure to fail:
762 - <b>You are using a borken build environment</b>\n
763 If symptom is that configure complains about gcc not being able to build
764 executables, you are probably missing the libc6-dev package. Damn Ubuntu.
766 If you experience other kind of issue, please get in touch with us. We are
767 always interested in improving our portability to new systems.
769 \subsection faq_distcheck_fails Dude! "make check" fails on my machine!
771 Don't assume we never run this target, because we do. Really. Promise!
773 There is several reasons which may cause the make check to fail on your
776 - <b>You are using a borken compiler</b>.\n
777 The symptom may be that the "make check" fails within testsuite/gras
779 For example, the breezy release of Ubuntu comes with a prerelease of the
780 4.0 gcc compiler. This version happens to be completely unusable, and you
781 should install a gcc-3.4 compiler and change the /usr/bin/gcc link to let
782 it point on /usr/bin/gcc-3.4.
783 - <b>You are using a borken libc (probably concerning the contextes)</b>.\n
784 The symptom is that the "make check" fails within the examples/msg directory.\n
785 By default, SimGrid uses something called ucontexts. This is part of the
786 libc, but it's quite undertested. For example, some (old) versions of the
787 glibc on alpha do not implement these functions, but provide the stubs
788 (which return ENOSYS: not implemented). It fools our detection mecanism
789 and leads to segfaults.\n
790 On some x86_64, the pointer to function is stored into a integer, but int
791 are 32bits only on this arch while pointers are 64bits. Our detection
792 mecanism also fails to detect the problem, which leads to segfaults.\n
793 In both cases, there is not much we can do to fix the bug. We are working
794 on a workaround for x86_64 machines, but in the meanwhile, you can
795 compile with --with-context=pthread to avoid ucontext completely. You'll
796 be a bit more limitated in the number of simulated processes you can start
797 concurently, but 5000 processes is still enough for most purposes, isn't
799 This limitation is the reason why we insist on using this piece of ...
800 software even if it's so troublesome.
801 - <b>There is a bug in SimGrid we aren't aware of</b>.\n
802 If none of the above apply, please drop us a mail on the mailing list so
803 that we can check it out.
805 \subsection faq_context_1000 I want thousands of simulated processes
807 SimGrid can use either pthreads library or the UNIX98 contextes. On most
808 systems, the number of pthreads is limited and then your simulation may be
809 limited for a stupid reason. This is especially true with the current linux
810 pthreads, and I cannot get more than 2000 simulated processes with pthreads
811 on my box. The UNIX98 contexts allow me to raise the limit to 25,000
812 simulated processes on my laptop.
814 The <tt>--with-context</tt> option of the <tt>./configure</tt> script allows
815 you to choose between UNIX98 contextes (<tt>--with-context=ucontext</tt>)
816 and the pthread version ( (<tt>--with-context=pthread</tt>). The default
817 value is ucontext when the script detect a working UNIX98 context
818 implementation. On Windows boxes, the provided value is discarded and an
819 adapted version is picked up.
821 We experienced some issues with contextes on some rare systems (solaris 8
822 and lower or old alpha linuxes comes to mind). The main problem is that the
823 configure script detect the contextes as being functional when it's not
824 true. If you happen to use such a system, switch manually to the pthread
825 version, and provide us with a good patch for the configure script so that
826 it is done automatically ;)
828 \subsection faq_context_10000 I want hundred thousands of simulated processes
830 As explained above, SimGrid can use UNIX98 contextes to represent and handle
831 the simulated processes. Thanks to this, the main limitation to the number
832 of simulated processes becomes the available memory.
834 Here are some tricks I had to use in order to run a token ring between
835 25,000 processes on my laptop (1Gb memory, 1.5Gb swap).
837 - First of all, make sure your code runs for a few hundreds processes
838 before trying to push the limit. Make sure it's valgrind-clean, ie that
839 valgrind does not report neither memory error nor memory leaks. Indeed,
840 numerous simulated processes result in *fat* simulation hindering debugging.
842 - It was really boring to write 25,000 entries in the deployment file, so I wrote
843 a little script <tt>examples/gras/tokenS/make_deployment.pl</tt>, which you may
844 want to adapt to your case. You could also think about hijacking
845 the SURFXML parser (have look at \ref faq_flexml_bypassing).
847 - The deployment file became quite big, so I had to do what is in the FAQ
848 entry \ref faq_flexml_limit
850 - Each UNIX98 context has its own stack entry. As debugging this is quite
851 hairly, the default value is a bit overestimated so that user don't get
852 into trouble about this. You want to tune this size to increse the number
853 of processes. This is the <tt>STACK_SIZE</tt> define in
854 <tt>src/xbt/context_private.h</tt>, which is 128kb by default.
855 Reduce this as much as you can, but be warned that if this value is too
856 low, you'll get a segfault. The token ring example, which is quite simple,
857 runs with 40kb stacks.
859 \subsection faq_longjmp longjmp madness
861 This is when valgrind starts complaining about longjmp things, just like:
863 \verbatim ==21434== Conditional jump or move depends on uninitialised value(s)
864 ==21434== at 0x420DBE5: longjmp (longjmp.c:33)
866 ==21434== Use of uninitialised value of size 4
867 ==21434== at 0x420DC3A: __longjmp (__longjmp.S:48)
870 or even when it reports scary things like:
872 \verbatim ==24023== Warning: client switching stacks? SP change: 0xBE3FF618 --> 0xBE7FF710
873 x86->IR: unhandled instruction bytes: 0xF4 0xC7 0x83 0xD0
874 ==24023== to suppress, use: --max-stackframe=4194552 or greater
875 ==24023== Your program just tried to execute an instruction that Valgrind
876 ==24023== did not recognise. There are two possible reasons for this.
877 ==24023== 1. Your program has a bug and erroneously jumped to a non-code
878 ==24023== location. If you are running Memcheck and you just saw a
879 ==24023== warning about a bad jump, it's probably your program's fault.
880 ==24023== 2. The instruction is legitimate but Valgrind doesn't handle it,
881 ==24023== i.e. it's Valgrind's fault. If you think this is the case or
882 ==24023== you are not sure, please let us know.
883 ==24023== Either way, Valgrind will now raise a SIGILL signal which will
884 ==24023== probably kill your program.
886 ==24023== Process terminating with default action of signal 4 (SIGILL)
887 ==24023== Illegal opcode at address 0x420D234
888 ==24023== at 0x420D234: abort (abort.c:124)
891 This is the sign that you didn't used the exception mecanism well. Most
892 probably, you have a <tt>return;</tt> somewhere within a <tt>TRY{}</tt>
893 block. This is <b>evil</b>, and you must not do this. Did you read the section
896 \subsection faq_flexml_limit I get the message "surf_parse_lex: Assertion `next<limit' failed."
898 This is because your platform file is too big for the parser.
900 Actually, the message comes directly from FleXML, the technology on top of
901 which the parser is built. FleXML has the bad idea of fetching the whole
902 document in memory before parsing it. And moreover, the memory buffer size
903 must be determinded at compilation time.
905 We use a value which seems big enough for our need without bloating the
906 simulators footprints. But of course your mileage may vary. In this case,
907 just edit src/surf/surfxml.l modify the definition of
908 FLEXML_BUFFERSTACKSIZE. E.g.
911 #define FLEXML_BUFFERSTACKSIZE 1000000000
914 Then recompile and everything should be fine, provided that your version of
915 Flex is recent enough (>= 2.5.31). If not the compilation process should
918 A while ago, we worked on FleXML to reduce a bit its memory consumtion, but
919 these issues remain. There is two things we should do:
921 - use a dynamic buffer instead of a static one so that the only limit
922 becomes your memory, not a stupid constant fixed at compilation time
923 (maybe not so difficult).
924 - change the parser so that it does not need to get the whole file in
925 memory before parsing
926 (seems quite difficult, but I'm a complete newbe wrt flex stuff).
928 These are changes to FleXML itself, not SimGrid. But since we kinda hijacked
929 the development of FleXML, I can grant you that any patches would be really
930 welcome and quickly integrated.
932 \subsection faq_gras_transport GRAS spits networking error messages
934 Gras, on real platforms, naturally use regular sockets to communicate. They
935 are deeply hiden in the gras abstraction, but when things go wrong, you may
936 get some weird error messages. Here are some example, with the probable
939 - <b>Transport endpoint is not connected</b>: several processes try to open
940 a server socket on the same port number of the same machine. This is
941 naturally bad and each process should pick its own port number for this.\n
942 Maybe, you just have some processes remaining from a previous experiment
944 Killing them may help, but again if you kill -KILL them, you'll have to
945 wait for a while: they didn't close there sockets properly and the system
946 needs a while to notice that this port is free again.
948 - <b>Socket closed by remote side</b>: if the remote process is not
949 supposed to close the socket at this point, it may be dead.
951 - <b>Connection reset by peer</b>: I found this on internet about this
952 error. I think it's what's happening here, too:\n
953 <i>This basically means that a network error occurred while the client was
954 receiving data from the server. But what is really happening is that the
955 server actually accepts the connection, processes the request, and sends
956 a reply to the client. However, when the server closes the socket, the
957 client believes that the connection has been terminated abnormally
958 because the socket implementation sends a TCP reset segment telling the
959 client to throw away the data and report an error.\n
960 Sometimes, this problem is caused by not properly closing the
961 input/output streams and the socket connection. Make sure you close the
962 input/output streams and socket connection properly. If everything is
963 closed properly, however, and the problem persists, you can work around
964 it by adding a one-second sleep before closing the streams and the
965 socket. This technique, however, is not reliable and may not work on all
967 Since GRAS sockets are closed properly (repeat after me: there is no bug
968 in GRAS), it is either that you are closing your sockets on server side
969 before the client get a chance to read them (use gras_os_sleep() to delay
970 the server), or the server died awfully before the client got the data.
973 \subsection faq_deadlock There is a deadlock !!!
975 Unfortunately, we cannot debug every code written in SimGrid. We
976 furthermore believe that the framework provides ways enough
977 information to debug such informations yourself. If the textual output
978 is not enough, Make sure to check the \ref faq_visualization FAQ entry to see
979 how to get a graphical one.
981 Now, if you come up with a really simple example that deadlocks and
982 you're absolutely convinced that it should not, you can ask on the
983 list. Just be aware that you'll be severely punished if the mistake is
984 on your side... We have plenty of FAQ entries to redact and new
985 features to implement for the impenitents! ;)
987 \author Arnaud Legrand (arnaud.legrand::imag.fr)
988 \author Martin Quinson (martin.quinson::loria.fr)