Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
3f6189a68167cbfa87a5e9932375228fe0f7b440
[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
19
20 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
21
22 /** opaque structure defining a event generator for availability based on a probability distribution */
23 typedef struct probabilist_event_generator *probabilist_event_generator_t;
24
25 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename);
26 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
27                                                     const char *input,
28                                                     double periodicity);
29 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_generator(const char *id,
30                                                   probabilist_event_generator_t generator1,
31                                                   probabilist_event_generator_t generator2,
32                                                   int is_state_trace);
33
34 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id,
35                                                                            double min,
36                                                                            double max);
37 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id,
38                                                                            double rate);
39 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
40                                                                            double scale,
41                                                                            double shape);
42
43 /** Defines whether a given resource is working or not */
44 typedef enum {
45   SURF_RESOURCE_ON = 1,                   /**< Up & ready        */
46   SURF_RESOURCE_OFF = 0                   /**< Down & broken     */
47 } e_surf_resource_state_t;
48
49 typedef enum {
50   SURF_LINK_FULLDUPLEX = 2,
51   SURF_LINK_SHARED = 1,
52   SURF_LINK_FATPIPE = 0
53 } e_surf_link_sharing_policy_t;
54
55 typedef enum {
56   SURF_TRACE_CONNECT_KIND_HOST_AVAIL = 4,
57   SURF_TRACE_CONNECT_KIND_POWER = 3,
58   SURF_TRACE_CONNECT_KIND_LINK_AVAIL = 2,
59   SURF_TRACE_CONNECT_KIND_BANDWIDTH = 1,
60   SURF_TRACE_CONNECT_KIND_LATENCY = 0
61 } e_surf_trace_connect_kin_t;
62
63 typedef enum {
64   SURF_PROCESS_ON_FAILURE_DIE = 1,
65   SURF_PROCESS_ON_FAILURE_RESTART = 0
66 } e_surf_process_on_failure_t;
67
68 /*
69  * Platform creation functions. Instead of passing 123 arguments to the creation functions
70  * (one for each possible XML attribute), we pass structures containing them all. It removes the
71  * chances of switching arguments by error, and reduce the burden when we add a new attribute:
72  * old models can just continue to ignore it without having to update their headers.
73  *
74  * It shouldn't be too costly at runtime, provided that structures living on the stack are
75  * used, instead of malloced structures.
76  */
77
78 typedef struct {
79   const char* id;
80   double power_peak;
81   int core_amount;
82   double power_scale;
83   tmgr_trace_t power_trace;
84   e_surf_resource_state_t initial_state;
85   tmgr_trace_t state_trace;
86   const char* coord;
87   xbt_dict_t properties;
88 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
89
90 typedef struct {
91   const char* id;
92   const char* link_up;
93   const char* link_down;
94 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
95
96
97 typedef struct {
98   const char* id;
99   const char* coord;
100 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
101
102 typedef struct {
103   const char* id;
104   double bandwidth;
105   tmgr_trace_t bandwidth_trace;
106   double latency;
107   tmgr_trace_t latency_trace;
108   e_surf_resource_state_t state;
109   tmgr_trace_t state_trace;
110   e_surf_link_sharing_policy_t policy;
111   xbt_dict_t properties;
112 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
113
114 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
115 typedef struct s_sg_platf_peer_cbarg {
116   const char* id;
117   double power;
118   double bw_in;
119   double bw_out;
120   double lat;
121   const char* coord;
122   tmgr_trace_t availability_trace;
123   tmgr_trace_t state_trace;
124 } s_sg_platf_peer_cbarg_t;
125
126 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
127 typedef struct s_sg_platf_route_cbarg {
128   int symmetrical;
129   const char *src;
130   const char *dst;
131   xbt_dynar_t link_list;
132 } s_sg_platf_route_cbarg_t;
133
134 typedef struct s_sg_platf_ASroute_cbarg *sg_platf_ASroute_cbarg_t;
135 typedef struct s_sg_platf_ASroute_cbarg {
136   int symmetrical;
137   const char *src;
138   const char *dst;
139   const char *gw_src;
140   const char *gw_dst;
141   xbt_dynar_t link_list;
142 } s_sg_platf_ASroute_cbarg_t;
143
144 typedef struct s_sg_platf_bypassRoute_cbarg *sg_platf_bypassRoute_cbarg_t;
145 typedef struct s_sg_platf_bypassRoute_cbarg {
146   const char *src;
147   const char *dst;
148   xbt_dynar_t link_list;
149 } s_sg_platf_bypassRoute_cbarg_t;
150
151 typedef struct s_sg_platf_bypassASroute_cbarg *sg_platf_bypassASroute_cbarg_t;
152 typedef struct s_sg_platf_bypassASroute_cbarg {
153   const char *src;
154   const char *dst;
155   const char *gw_src;
156   const char *gw_dst;
157   xbt_dynar_t link_list;
158 } s_sg_platf_bypassASroute_cbarg_t;
159
160 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
161 typedef struct s_sg_platf_cluster_cbarg {
162   const char* id;
163   const char* prefix;
164   const char* suffix;
165   const char* radical;
166   double power;
167   int core_amount;
168   double bw;
169   double lat;
170   double bb_bw;
171   double bb_lat;
172   const char* router_id;
173   e_surf_link_sharing_policy_t sharing_policy;
174   e_surf_link_sharing_policy_t bb_sharing_policy;
175   const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
176   const char* state_trace;
177 } s_sg_platf_cluster_cbarg_t;
178
179 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
180 typedef struct s_sg_platf_cabinet_cbarg {
181   const char* id;
182   const char* prefix;
183   const char* suffix;
184   const char* radical;
185   double power;
186   double bw;
187   double lat;
188 } s_sg_platf_cabinet_cbarg_t;
189
190 typedef struct {
191   const char* id;
192   const char* type_id;
193   const char* content;
194 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
195
196 typedef struct {
197   const char* id;
198   const char* model;
199   const char* content;
200   xbt_dict_t properties;
201   unsigned long size; /* size in Gbytes */
202 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
203
204 typedef struct {
205   const char* type_id;
206   const char* name;
207 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
208
209 typedef struct {
210   const char* id;
211   const char* name;
212 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
213
214 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
215 typedef struct s_sg_platf_prop_cbarg {
216   const char *id;
217   const char *value;
218 } s_sg_platf_prop_cbarg_t;
219
220 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
221 typedef struct s_sg_platf_trace_cbarg {
222   const char *id;
223   const char *file;
224   double periodicity;
225   const char *pc_data;
226 } s_sg_platf_trace_cbarg_t;
227
228 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
229 typedef struct s_sg_platf_trace_connect_cbarg {
230   e_surf_trace_connect_kin_t kind;
231   const char *trace;
232   const char *element;
233 } s_sg_platf_trace_connect_cbarg_t;
234
235 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
236 typedef struct s_sg_platf_process_cbarg {
237   const char **argv;
238   int argc;
239   xbt_dict_t properties;
240   const char *host;
241   const char *function;
242   double start_time;
243   double kill_time;
244   e_surf_process_on_failure_t on_failure;
245 } s_sg_platf_process_cbarg_t;
246
247 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
248 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
249
250 XBT_PUBLIC(void) sg_platf_new_AS_begin(const char *id, int mode); // Begin description of new AS
251 XBT_PUBLIC(void) sg_platf_new_AS_end(void);                            // That AS is fully described
252
253 XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
254 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
255 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
256 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
257 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
258 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
259 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
260
261 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
262 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_ASroute_cbarg_t ASroute); // Add an ASroute
263 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_bypassRoute_cbarg_t bypassroute); // Add a bypassRoute
264 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_bypassASroute_cbarg_t bypassASroute); // Add an bypassASroute
265 XBT_PUBLIC(void) sg_platf_new_prop (sg_platf_prop_cbarg_t prop); // Add a prop
266
267 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
268 XBT_PUBLIC(void) sg_platf_new_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
269
270 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
271 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
272 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
273 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
274 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
275
276 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
277
278 // Add route and Asroute without xml file with those functions
279 XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route
280 XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route
281
282 XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_ASroute_cbarg_t ASroute); // Initialize ASroute
283 XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_ASroute_cbarg_t ASroute); // Finalize and add a ASroute
284
285 XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list
286 XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_ASroute_cbarg_t ASroute); // Add a link to link list
287
288 #endif                          /* SG_PLATF_H */