2 ** Source tree organization
4 ******************************************************
6 There is at least 5 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 - GRAS: Grid Reality And Simulation (message passing API with two
13 implementations allowing to compile programs on top of the
14 simulator or for the real life without code modification)
15 - AMOK: Advanced Metacomputing Overlay Kit (high level toolbox; Grid
16 application elements such as distributed database, topology
17 discovery service, and so on)
19 They are all in the same tree because they are complementary tools and
20 having all of them in the same package makes the installation easier
21 for end-users. Moreover, it enables to share the compilation chain and
22 eases the development.
24 The tree is not splited on projects, but on file finality:
25 include/ -> all *public* headers
26 include/xbt/*.h -> one file per module
27 include/gras.h -> file including all modules headers
28 (same for xbt instead of gras)
30 src/Makefile.am -> main makefile. All projects should fit in only one
31 library (I mean 2, RL+SG), which is compiled here.
33 Since all object.o files are placed here, you should
34 choose the name of c files carfully to avoid
37 src/gras/DataDesc -> typical project module
38 src/gras/DataDesc/datadesc_interface.h -> visible to any GRAS modules;
39 masked to the user and GROS/AMOK/SURF
40 src/gras/DataDesc/datadesc_private.h -> visible only from this module
42 So, the modules have 3 levels of publicity for their interface.
43 Private, internal to GRAS, public. Of course, I try to keep as much stuff
46 src/include -> another location for protected headers. Used by SURF, and
47 other should be converted, since this is the Right Thing.
49 testsuite/ -> The more test the better.
50 Same organization than src/ and include/
51 Tests are allowed to load some headers of the module they test.
52 All tests should be listed in run_test.in so that they get
54 They are not listed directly in the check_PROGRAMS part of
55 the makefile because run_test knows about the gras logging
56 features and relaunch with full details the failed tests.
58 examples/ -> Supposed to be copy/pastable by the user, so keep it clear and
59 avoid any kind of trick. In particular, do only include the
62 ** Indentation standard
64 *****************************************************
66 Most files use the Kernighan & Ritchie coding style with 2 spaces of
67 indentation. The indent program can help you to stick to it:
69 indent -br -brs -ce -bbo -bad -bap --dont-break-procedure-type
70 --no-tabs --cuddle-do-while --cuddle-else --indent-level2
71 --leave-preprocessor-space --no-space-after-function-call-names
74 FIXME: this list of arguments is still to be discussed, maybe
77 ** Type naming standard
79 *****************************************************
81 It may sound strange, but the type naming convention was source of intense
82 discution between da GRAS posse members. The convention we came to may not
83 be the best solution, but it has the merit to exist and leave everyone work.
84 So please stick to it.
86 - ???_t is a valid type (builded with typedef)
87 - s_toto_t is a structure (access to fields with .)
88 - s_toto is a structure needing 'struct' keyword to be used
90 - u_toto_t is an union
91 - u_toto is an union needing 'union' keyword to be used
92 - toto_t is an 'object' (struct*)
94 Please to not call toto_t something else than an 'object' (ie, something you
95 have to call _new and _free on it).
98 typedef struct s_toto {} s_toto_t, *toto_t;
99 typedef enum {} e_toto_t;
101 Moreover, only toto_t (and e_toto_t) are public. The rest (mainly s_toto_t)
104 If you see any part of the code not following this convention, this is a
105 bug. Please report it (or fix it yourself if you can).
108 ** Random bits about coding standards and portability
110 *****************************************************
113 Don't use it, or you'll have to check the result (and do some dirty stuff
114 on AIX). Use xbt_malloc (or even better, xbt_new) instead.
117 If possible, avoid size_t and use unsigned long instead. If not,
118 #include <sys/types.h> in all files manipulating size_t
119 do cast it to unsigned long before printing (and use %lu)
121 PRINTF pointer difference
122 printf ("diff = %ld\n", (long) (pointer2 - pointer1));
126 ** Commenting the source: doxygen
128 ****************************************************
130 The global structure of the documentation is in doc/modules.doc
132 The structure of each module (xbt, gras, etc) is in doc/module-<module>.doc
134 The structure of a module is in its public header. This way, you're sure to
135 see all the public interface (and only it). The different parts of the
136 interface are grouped using the @name construct, even if it's buggy. Since
137 parts often get reordered, it's better to add numbers to the parts (so that
138 users can see the intended order).
140 The documentation of each type and macro are also in the public header since
141 this is were they live.
143 The documentation of each function must be in the C file were it lives.
145 Any public element (function, type and macro) must have a @brief part.
148 ** XBT virtualization mecanism
150 ****************************************************
152 There is some functionnalities that we want to virtualize in XBT. We
153 want xbt_time to give the simulated clock when running on top of the
154 simulator, and the host clock when running on a real system. This
155 could be placed in GRAS (and was, historically), but there is some
156 reason to lower it down to XBT.
158 Here is the used naming scheme:
160 - xbt_<module>_<func>(): functions working both in SG and RL
161 - xbt_os_<module>_<func>(): RL functions usable even in simulator
163 That way, in libsimgrid, we still can use native functions if we
164 want to. It may for example be useful to get the real time when
165 implementing the simulator. Think of the SIGINT handler, which
166 wants to see if the user pressed the key twice in a 5 seconds
167 interval. This is of little use to check the simulated time here.
169 Here is the file layout:
171 - xbt_rl_<module>.c: native implementation (xbt_<module>_<func>()).
172 Simply call the corresponding xbt_os_<module>_<func>.
173 Part only of libgras.so
175 - xbt_sg_<module>.c: SIMIX implementation xbt_<module>_<func>()).
176 Simply call the corresponding SIMIX implementation.
177 Part only of libsimgrid.so
179 - xbt_os_<module>.c: body of the functions implementing natively the
180 stuff (xbt_os_<module>_<func>()).
181 Part of both libgras.so and libsimgrid.so
183 Since there is almost nothing in xbt_rl_module.c and xbt_sg_module.c,
184 it'd be better to use symbol aliasing here (to declare in the object
185 code that the same function have two names), but I'm still
186 investigating the portability of the thing to windows.