Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Added an example with iteration sampling.
[simgrid.git] / README.coding
1 **
2 ** Source tree organization
3 **
4 ******************************************************
5
6 There is at least 5 sub-projects in the tree:
7
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
11          simulator.
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)
18
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.
23
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)
29   
30  src/Makefile.am     -> main makefile. All projects should fit in only one
31                         library (I mean 2, RL+SG), which is compiled here.
32                         
33                         Since all object.o files are placed here, you should
34                         choose the name of c files carfully to avoid
35                         conflict. 
36                         
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                                           
41   
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
44    private as possible.
45
46  src/include -> another location for protected headers. Used by SURF, and
47                 other should be converted, since this is the Right Thing.
48
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
53                   run on 'make check'. 
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.
57                   
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
60                 public headers here.
61 **
62 ** Indentation standard
63 **
64 *****************************************************
65
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:
68
69 indent -kr -br -brs -ce -bbo --dont-break-procedure-type --no-tabs
70 --cuddle-do-while --cuddle-else --indent-level2 --leave-preprocessor-space
71 --no-space-after-function-call-names <myfile>
72
73 FIXME: this list of arguments is still to be discussed, maybe
74
75 **
76 ** Type naming standard
77 **
78 *****************************************************
79
80 It may sound strange, but the type naming convention was source of intense
81 discution between da GRAS posse members. The convention we came to may not
82 be the best solution, but it has the merit to exist and leave everyone work.
83 So please stick to it.
84
85   - ???_t is a valid type (builded with typedef)
86   - s_toto_t is a structure (access to fields with .)
87   - s_toto   is a structure needing 'struct' keyword to be used
88   - e_toto_t is an enum
89   - u_toto_t is an union
90   - u_toto   is an union needing 'union' keyword to be used
91   -   toto_t is an 'object' (struct*)
92   
93 Please to not call toto_t something else than an 'object' (ie, something you
94 have to call _new and _free on it).
95
96 Exemple:
97   typedef struct s_toto {} s_toto_t, *toto_t;
98   typedef enum {} e_toto_t;
99   
100 Moreover, only toto_t (and e_toto_t) are public. The rest (mainly s_toto_t)
101 is private.
102
103 If you see any part of the code not following this convention, this is a
104 bug. Please report it (or fix it yourself if you can).
105
106 **
107 ** Random bits about coding standards and portability
108 **
109 *****************************************************
110
111 MALLOC:
112  Don't use it, or you'll have to check the result (and do some dirty stuff
113  on AIX). Use xbt_malloc (or even better, xbt_new) instead.
114
115 SIZE_T
116  If possible, avoid size_t and use unsigned long instead. If not,
117  #include <sys/types.h> in all files manipulating size_t
118  do cast it to unsigned long before printing (and use %lu)
119  
120 PRINTF pointer difference
121  printf ("diff = %ld\n", (long) (pointer2 - pointer1));
122   
123
124 **              
125 ** Commenting the source: doxygen
126 **
127 ****************************************************
128
129 The global structure of the documentation is in doc/modules.doc 
130
131 The structure of each module (xbt, gras, etc) is in doc/module-<module>.doc
132
133 The structure of a module is in its public header. This way, you're sure to
134 see all the public interface (and only it). The different parts of the
135 interface are grouped using the @name construct, even if it's buggy. Since
136 parts often get reordered, it's better to add numbers to the parts (so that
137 users can see the intended order).
138
139 The documentation of each type and macro are also in the public header since
140 this is were they live.
141
142 The documentation of each function must be in the C file were it lives. 
143
144 Any public element (function, type and macro) must have a @brief part.
145
146 **
147 ** XBT virtualization mecanism
148 **
149 ****************************************************
150
151 There is some functionnalities that we want to virtualize in XBT. We
152 want xbt_time to give the simulated clock when running on top of the
153 simulator, and the host clock when running on a real system. This
154 could be placed in GRAS (and was, historically), but there is some
155 reason to lower it down to XBT. 
156
157 Here is the used naming scheme:
158
159   - xbt_<module>_<func>(): functions working both in SG and RL  
160   - xbt_os_<module>_<func>(): RL functions usable even in simulator
161     
162     That way, in libsimgrid, we still can use native functions if we
163     want to. It may for example be useful to get the real time when
164     implementing the simulator. Think of the SIGINT handler, which
165     wants to see if the user pressed the key twice in a 5 seconds
166     interval. This is of little use to check the simulated time here.
167
168 Here is the file layout:
169
170   - xbt_rl_<module>.c: native implementation (xbt_<module>_<func>()).
171     Simply call the corresponding xbt_os_<module>_<func>.     
172     Part only of libgras.so
173     
174   - xbt_sg_<module>.c: SIMIX implementation xbt_<module>_<func>()).
175     Simply call the corresponding SIMIX implementation. 
176     Part only of libsimgrid.so
177     
178   - xbt_os_<module>.c: body of the functions implementing natively the
179     stuff (xbt_os_<module>_<func>()).
180     Part of both libgras.so and libsimgrid.so
181     
182 Since there is almost nothing in xbt_rl_module.c and xbt_sg_module.c,
183 it'd be better to use symbol aliasing here (to declare in the object
184 code that the same function have two names), but I'm still
185 investigating the portability of the thing to windows.