Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add properties to AS structure (Not work for now) and use SG_PLATF_AS_INITIALIZER
[simgrid.git] / include / simgrid / platf.h
1 /* platf.h - Public interface to the SimGrid platforms                      */
2
3 /* Copyright (c) 2004-2012. The SimGrid Team. All rights reserved.          */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #ifndef SG_PLATF_H
9 #define SG_PLATF_H
10
11 #include <xbt.h>
12
13 typedef void *sg_routing_link_t; /* The actual type is model-dependent so use void* instead*/
14 typedef struct s_routing_edge *sg_routing_edge_t;
15
16 XBT_PUBLIC(sg_routing_edge_t) sg_routing_edge_by_name_or_null(const char *name);
17
18 /** Defines whether a given resource is working or not */
19 typedef enum {
20   SURF_RESOURCE_ON = 1,                   /**< Up & ready        */
21   SURF_RESOURCE_OFF = 0                   /**< Down & broken     */
22 } e_surf_resource_state_t;
23
24 typedef enum {
25   SURF_LINK_FULLDUPLEX = 2,
26   SURF_LINK_SHARED = 1,
27   SURF_LINK_FATPIPE = 0
28 } e_surf_link_sharing_policy_t;
29
30 typedef enum {
31   SURF_TRACE_CONNECT_KIND_HOST_AVAIL = 4,
32   SURF_TRACE_CONNECT_KIND_POWER = 3,
33   SURF_TRACE_CONNECT_KIND_LINK_AVAIL = 2,
34   SURF_TRACE_CONNECT_KIND_BANDWIDTH = 1,
35   SURF_TRACE_CONNECT_KIND_LATENCY = 0
36 } e_surf_trace_connect_kin_t;
37
38 typedef enum {
39   SURF_PROCESS_ON_FAILURE_DIE = 1,
40   SURF_PROCESS_ON_FAILURE_RESTART = 0
41 } e_surf_process_on_failure_t;
42
43
44 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
45
46 /** opaque structure defining a event generator for availability based on a probability distribution */
47 typedef struct probabilist_event_generator *probabilist_event_generator_t;
48
49 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename);
50 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
51                                                     const char *input,
52                                                     double periodicity);
53
54 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_value(const char *id,
55                                               probabilist_event_generator_t date_generator,
56                                               probabilist_event_generator_t value_generator);
57 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_state(const char *id,
58                                               probabilist_event_generator_t date_generator,
59                                               e_surf_resource_state_t first_event_value);
60 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_avail_unavail(const char *id,
61                                               probabilist_event_generator_t avail_duration_generator,
62                                               probabilist_event_generator_t unavail_duration_generator,
63                                               e_surf_resource_state_t first_event_value);
64
65 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id,
66                                                                            double min,
67                                                                            double max);
68 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id,
69                                                                            double rate);
70 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
71                                                                            double scale,
72                                                                            double shape);
73
74 /*
75  * Platform creation functions. Instead of passing 123 arguments to the creation functions
76  * (one for each possible XML attribute), we pass structures containing them all. It removes the
77  * chances of switching arguments by error, and reduce the burden when we add a new attribute:
78  * old models can just continue to ignore it without having to update their headers.
79  *
80  * It shouldn't be too costly at runtime, provided that structures living on the stack are
81  * used, instead of malloced structures.
82  */
83
84 typedef struct {
85   const char* id;
86   double power_peak;
87   int core_amount;
88   double power_scale;
89   tmgr_trace_t power_trace;
90   e_surf_resource_state_t initial_state;
91   tmgr_trace_t state_trace;
92   const char* coord;
93   xbt_dict_t properties;
94 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
95
96 #define SG_PLATF_HOST_INITIALIZER {\
97     .id = NULL, \
98     .power_peak = 0, \
99     .core_amount = 1., \
100     .power_scale = 1, \
101     .initial_state = A_surfxml_host_state_ON, \
102     .power_trace = NULL, \
103     .state_trace = NULL, \
104     .coord = NULL, \
105     .properties = NULL \
106     }
107
108 typedef struct {
109   const char* id;
110   const char* link_up;
111   const char* link_down;
112 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
113
114 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
115
116 typedef struct {
117   const char* id;
118   const char* coord;
119 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
120
121 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
122
123 typedef struct {
124   const char* id;
125   double bandwidth;
126   tmgr_trace_t bandwidth_trace;
127   double latency;
128   tmgr_trace_t latency_trace;
129   e_surf_resource_state_t state;
130   tmgr_trace_t state_trace;
131   e_surf_link_sharing_policy_t policy;
132   xbt_dict_t properties;
133 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
134
135 #define SG_PLATF_LINK_INITIALIZER {\
136   .id = NULL,\
137   .bandwidth = 0.,\
138   .bandwidth_trace = NULL,\
139   .latency = 0.,\
140   .latency_trace = NULL,\
141   .state = A_surfxml_link_state_ON,\
142   .state_trace = NULL,\
143   .policy = A_surfxml_link_sharing_policy_SHARED,\
144   .properties = NULL\
145 }
146
147 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
148 typedef struct s_sg_platf_peer_cbarg {
149   const char* id;
150   double power;
151   double bw_in;
152   double bw_out;
153   double lat;
154   const char* coord;
155   tmgr_trace_t availability_trace;
156   tmgr_trace_t state_trace;
157 } s_sg_platf_peer_cbarg_t;
158
159 #define SG_PLATF_PEER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
160
161 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
162 typedef struct s_sg_platf_route_cbarg {
163   int symmetrical;
164   const char *src;
165   const char *dst;
166   sg_routing_edge_t gw_src;
167   sg_routing_edge_t gw_dst;
168   xbt_dynar_t link_list;
169 } s_sg_platf_route_cbarg_t;
170
171 #define SG_PLATF_ROUTE_INITIALIZER {TRUE,NULL,NULL,NULL,NULL,NULL}
172
173 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
174 typedef struct s_sg_platf_cluster_cbarg {
175   const char* id;
176   const char* prefix;
177   const char* suffix;
178   const char* radical;
179   double power;
180   int core_amount;
181   double bw;
182   double lat;
183   double bb_bw;
184   double bb_lat;
185   const char* router_id;
186   e_surf_link_sharing_policy_t sharing_policy;
187   e_surf_link_sharing_policy_t bb_sharing_policy;
188   const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
189   const char* state_trace;
190 } s_sg_platf_cluster_cbarg_t;
191
192 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL \
193   ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
194
195 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
196 typedef struct s_sg_platf_cabinet_cbarg {
197   const char* id;
198   const char* prefix;
199   const char* suffix;
200   const char* radical;
201   double power;
202   double bw;
203   double lat;
204 } s_sg_platf_cabinet_cbarg_t;
205
206 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL}
207
208 typedef struct {
209   const char* id;
210   const char* type_id;
211   const char* content;
212 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
213
214 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL}
215
216 typedef struct {
217   const char* id;
218   const char* model;
219   const char* content;
220   xbt_dict_t properties;
221   unsigned long size; /* size in Gbytes */
222 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
223
224 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL}
225
226 typedef struct {
227   const char* type_id;
228   const char* name;
229 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
230
231 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
232
233 typedef struct {
234   const char* id;
235   const char* name;
236 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
237
238 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
239
240 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
241 typedef struct s_sg_platf_prop_cbarg {
242   const char *id;
243   const char *value;
244 } s_sg_platf_prop_cbarg_t;
245
246 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
247
248 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
249 typedef struct s_sg_platf_trace_cbarg {
250   const char *id;
251   const char *file;
252   double periodicity;
253   const char *pc_data;
254 } s_sg_platf_trace_cbarg_t;
255
256 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,NULL,NULL}
257
258 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
259 typedef struct s_sg_platf_trace_connect_cbarg {
260   e_surf_trace_connect_kin_t kind;
261   const char *trace;
262   const char *element;
263 } s_sg_platf_trace_connect_cbarg_t;
264
265 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {NULL,NULL,NULL}
266
267 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
268 typedef struct s_sg_platf_process_cbarg {
269   const char **argv;
270   int argc;
271   xbt_dict_t properties;
272   const char *host;
273   const char *function;
274   double start_time;
275   double kill_time;
276   e_surf_process_on_failure_t on_failure;
277 } s_sg_platf_process_cbarg_t;
278
279 #define SG_PLATF_PROCESS_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
280
281 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
282 typedef struct s_sg_platf_AS_cbarg {
283   const char *id;
284   int routing;
285   xbt_dict_t properties;
286 } s_sg_platf_AS_cbarg_t;
287
288 #define SG_PLATF_AS_INITIALIZER {NULL,0,NULL}
289
290 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
291 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
292
293 XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
294 XBT_PUBLIC(void) sg_platf_new_AS_end(void);                            // That AS is fully described
295
296 XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
297 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
298 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
299 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
300 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
301 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
302 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
303
304 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
305 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_route_cbarg_t ASroute); // Add an ASroute
306 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
307 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_route_cbarg_t bypassASroute); // Add an bypassASroute
308 XBT_PUBLIC(void) sg_platf_new_prop (sg_platf_prop_cbarg_t prop); // Add a prop
309
310 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
311 XBT_PUBLIC(void) sg_platf_new_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
312
313 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
314 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
315 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
316 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
317 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
318
319 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
320
321 // Add route and Asroute without xml file with those functions
322 XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route
323 XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route
324
325 XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute); // Initialize ASroute
326 XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute); // Finalize and add a ASroute
327
328 XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list
329 XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute); // Add a link to link list
330
331 #endif                          /* SG_PLATF_H */