2 ** Source tree organization
4 ******************************************************
6 There is at least 4 sub-projects in the tree:
8 - XBT: eXtended Bundle of Tools (low-level toolbox: logging, datatypes).
9 - SURF: a SimUlation aRtiFact. This is the simulation kernel.
10 - MSG: originally MetaSimGrid, MSG is a simple distributed application
12 - SMPI: Simulated MPI, to run MPI application using emulation technics.
14 They are all in the same tree because they are complementary tools and
15 having all of them in the same package makes the installation easier
16 for end-users. Moreover, it enables to share the compilation chain and
17 eases the development.
19 The tree is not split on projects, but on file finality:
20 include/ -> all *public* headers
21 include/xbt/*.h -> one file per module
23 src/include -> another location for protected headers. Used by SURF, and
24 other should be converted, since this is the Right Thing.
26 testsuite/ -> The more test the better.
27 Same organization than src/ and include/
28 Tests are allowed to load some headers of the module they test.
29 All tests should be listed in run_test.in so that they get
32 examples/ -> Supposed to be copy/pastable by the user, so keep it clear and
33 avoid any kind of trick. In particular, do only include the
36 teshsuite/ -> The more test the better. Put in there any strange test
37 doing things that the users are not supposed to do,
38 just to see if our framework is robust to incorrect and
39 unusual behaviors. All tests written in this section
40 should leverage our tesh(1) utility.
42 testsuite/ -> Old test suite, that should be converted to tesh and
43 moved to teshsuite at some point.
46 ** Indentation standard
48 *****************************************************
50 Most files use the Kernighan & Ritchie coding style with 2 spaces of
51 indentation. The indent program can help you to stick to it:
53 indent -kr -l80 -nut -i2 -lps -npcs -br -brs -ce -cdw -bbo -npsl <myfile>
55 The script ./tools/indent runs indent with the appropriate options.
57 FIXME: this list of arguments is still to be discussed, maybe
60 ** Type naming standard
62 *****************************************************
64 It may sound strange, but the type naming convention was source of intense
65 discussion between da SimGrid posse members. The convention we came to may not
66 be the best solution, but it has the merit to exist and leave everyone work.
67 So please stick to it.
69 - ???_t is a valid type (built with typedef)
70 - s_toto_t is a structure (access to fields with .)
71 - s_toto is a structure needing 'struct' keyword to be used
73 - u_toto_t is an union
74 - u_toto is an union needing 'union' keyword to be used
75 - toto_t is an 'object' (struct*)
77 Please to not call toto_t something else than an 'object' (ie, something you
78 have to call _new and _free on it).
81 typedef struct s_toto {} s_toto_t, *toto_t;
82 typedef enum {} e_toto_t;
84 Moreover, only toto_t (and e_toto_t) are public. The rest (mainly s_toto_t)
87 If you see any part of the code not following this convention, this is a
88 bug. Please report it (or fix it yourself if you can).
91 ** Random bits about coding standards and portability
93 *****************************************************
96 Don't use it, or you'll have to check the result (and do some dirty stuff
97 on AIX). Use xbt_malloc (or even better, xbt_new) instead.
99 SIZE_T (FIXME: obsolete?)
100 If possible, avoid size_t and use unsigned long instead. If not,
101 #include <sys/types.h> in all files manipulating size_t
102 do cast it to unsigned long before printing (and use %lu),
105 PRINTF pointer difference (FIXME: advertise %td instead?)
106 printf ("diff = %ld\n", (long) (pointer2 - pointer1));
109 The definition of a inline function must be visible when it is used.
110 As such, an inline function should be defined (an not only declared)
111 in header file (.h) with attributes 'static XBT_INLINE'. It should
112 not be defined in source file (.c).
115 ** Commenting the source: doxygen
117 ****************************************************
119 The global structure of the documentation is in doc/modules.doc
121 The structure of each module (xbt, msg, etc) is in doc/module-<module>.doc
123 The structure of a module is in its public header. This way, you're sure to
124 see all the public interface (and only it). The different parts of the
125 interface are grouped using the @name construct, even if it's buggy. Since
126 parts often get reordered, it's better to add numbers to the parts (so that
127 users can see the intended order).
129 The documentation of each type and macro are also in the public header since
130 this is were they live.
132 The documentation of each function must be in the C file were it lives.
134 Any public element (function, type and macro) must have a @brief part.
137 ** XBT virtualization mechanism (FIXME: this section is deprecated)
139 ****************************************************
141 There is some functionalities that we want to virtualize in XBT. We
142 want xbt_time to give the simulated clock when running on top of the
143 simulator, and the host clock when running on a real system. This
144 could be placed in GRAS (and was, historically), but there is some
145 reason to lower it down to XBT.
147 Here is the used naming scheme:
149 - xbt_<module>_<func>(): functions working both in SG and RL
150 - xbt_os_<module>_<func>(): RL functions usable even in simulator
152 That way, in libsimgrid, we still can use native functions if we
153 want to. It may for example be useful to get the real time when
154 implementing the simulator. Think of the SIGINT handler, which
155 wants to see if the user pressed the key twice in a 5 seconds
156 interval. This is of little use to check the simulated time here.
158 Here is the file layout:
160 - xbt_rl_<module>.c: native implementation (xbt_<module>_<func>()).
161 Simply call the corresponding xbt_os_<module>_<func>.
162 Part only of libgras.so
164 - xbt_sg_<module>.c: SIMIX implementation xbt_<module>_<func>()).
165 Simply call the corresponding SIMIX implementation.
166 Part only of libsimgrid.so
168 - xbt_os_<module>.c: body of the functions implementing natively the
169 stuff (xbt_os_<module>_<func>()).
170 Part of both libgras.so and libsimgrid.so
172 Since there is almost nothing in xbt_rl_module.c and xbt_sg_module.c,
173 it'd be better to use symbol aliasing here (to declare in the object
174 code that the same function have two names), but I'm still
175 investigating the portability of the thing to windows.
179 * SimGrid Hacker Survival Guide (FIXME: should be betterly placed)
180 ********************************
182 * Before pushing any change, don't forget to check if the compilation
183 passes with compiler optimizations and warnings turned on:
184 cmake -Denable_compile_optimizations=ON \
185 -Denable_compile_warnings=ON
187 * Your commit message should follow the git habits, explained eg here:
188 http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
190 * When you add/remove files, and/or make changes in the lists of files to build,
191 please check that "make distcheck" still succeeds. This is needed to ensure
192 that the generated archive is consistent.
194 * If you want to debug memory allocation problems, here are a few hints:
195 - disable compiler optimizations, to have better backtraces;
196 - disable the mallocators, or it will be hard to match malloc's with
198 - disable model checking, unless your problem lies in the model
199 checker part of SimGrid (MC brings its own malloc implementation,
200 which valgrind doesn't understand).
201 All this is configured with:
202 cmake -Denable_model-checking=OFF \
203 -Denable_mallocators=OFF \
204 -Denable_compile_optimizations=OFF
206 * If you break the logs (for example while hacking in the dynars), you
207 want to define XBT_LOG_MAYDAY at the beginning of log.h. It will
208 deactivate the whole logging mechanism, switching to printfs
209 instead. SimGrid becomes incredibly verbose when doing so, but it
210 you let you fixing the dynars.