Logo AND Algorithmique Numérique Distribuée

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