Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
These two files need to be added to EXTRA_DIST for an unknown reason related to some...
[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 **
70 ** Type naming standard
71 **
72 *****************************************************
73
74 It may sound strange, but the type naming convention was source of intense
75 discution between da GRAS posse members. The convention we came to may not
76 be the best solution, but it has the merit to exist and leave everyone work.
77 So please stick to it.
78
79   - ???_t is a valid type (builded with typedef)
80   - s_toto_t is a structure (access to fields with .)
81   - s_toto   is a structure needing 'struct' keyword to be used
82   - e_toto_t is an enum
83   - u_toto_t is an union
84   - u_toto   is an union needing 'union' keyword to be used
85   -   toto_t is an 'object' (struct*)
86   
87 Please to not call toto_t something else than an 'object' (ie, something you
88 have to call _new and _free on it).
89
90 Exemple:
91   typedef struct s_toto {} s_toto_t, *toto_t;
92   typedef enum {} e_toto_t;
93   
94 Moreover, only toto_t (and e_toto_t) are public. The rest (mainly s_toto_t)
95 is private.
96
97 If you see any part of the code not following this convention, this is a
98 bug. Please report it (or fix it yourself if you can).
99
100 **
101 ** Random bits about coding standards and portability
102 **
103 *****************************************************
104
105 MALLOC:
106  Don't use it, or you'll have to check the result (and do some dirty stuff
107  on AIX). Use xbt_malloc (or even better, xbt_new) instead.
108
109 SIZE_T
110  If possible, avoid size_t and use unsigned long instead. If not,
111  #include <sys/types.h> in all files manipulating size_t
112  do cast it to unsigned long before printing (and use %lu)
113  
114 PRINTF pointer difference
115  printf ("diff = %ld\n", (long) (pointer2 - pointer1));
116   
117
118 **              
119 ** Commenting the source: doxygen
120 **
121 ****************************************************
122
123 The global structure of the documentation is in doc/modules.doc 
124
125 The structure of each module (xbt, gras, etc) is in doc/module-<module>.doc
126
127 The structure of a module is in its public header. This way, you're sure to
128 see all the public interface (and only it). The different parts of the
129 interface are grouped using the @name construct, even if it's buggy. Since
130 parts often get reordered, it's better to add numbers to the parts (so that
131 users can see the intended order).
132
133 The documentation of each type and macro are also in the public header since
134 this is were they live.
135
136 The documentation of each function must be in the C file were it lives. 
137
138 Any public element (function, type and macro) must have a @brief part.
139
140 **
141 ** XBT virtualization mecanism
142 **
143 ****************************************************
144
145 There is some functionnalities that we want to virtualize in XBT. We
146 want xbt_time to give the simulated clock when running on top of the
147 simulator, and the host clock when running on a real system. This
148 could be placed in GRAS (and was, historically), but there is some
149 reason to lower it down to XBT. 
150
151 Here is the used naming scheme:
152
153   - xbt_<module>_<func>(): functions working both in SG and RL  
154   - xbt_os_<module>_<func>(): RL functions usable even in simulator
155     
156     That way, in libsimgrid, we still can use native functions if we
157     want to. It may for example be useful to get the real time when
158     implementing the simulator. Think of the SIGINT handler, which
159     wants to see if the user pressed the key twice in a 5 seconds
160     interval. This is of little use to check the simulated time here.
161
162 Here is the file layout:
163
164   - xbt_rl_<module>.c: native implementation (xbt_<module>_<func>()).
165     Simply call the corresponding xbt_os_<module>_<func>.     
166     Part only of libgras.so
167     
168   - xbt_sg_<module>.c: SIMIX implementation xbt_<module>_<func>()).
169     Simply call the corresponding SIMIX implementation. 
170     Part only of libsimgrid.so
171     
172   - xbt_os_<module>.c: body of the functions implementing natively the
173     stuff (xbt_os_<module>_<func>()).
174     Part of both libgras.so and libsimgrid.so
175     
176 Since there is almost nothing in xbt_rl_module.c and xbt_sg_module.c,
177 it'd be better to use symbol aliasing here (to declare in the object
178 code that the same function have two names), but I'm still
179 investigating the portability of the thing to windows.