Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
00c9192491d7f201653e12c774f5785ba5c394d0
[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_LINK_DIRECTION_NONE = 2,
57   SURF_LINK_DIRECTION_UP = 1,
58   SURF_LINK_DIRECTION_DOWN = 0
59 } e_surf_link_ctn_direction_t;
60
61 typedef enum {
62   SURF_TRACE_CONNECT_KIND_HOST_AVAIL = 4,
63   SURF_TRACE_CONNECT_KIND_POWER = 3,
64   SURF_TRACE_CONNECT_KIND_LINK_AVAIL = 2,
65   SURF_TRACE_CONNECT_KIND_BANDWIDTH = 1,
66   SURF_TRACE_CONNECT_KIND_LATENCY = 0
67 } e_surf_trace_connect_kin_t;
68
69 typedef enum {
70   SURF_PROCESS_ON_FAILURE_DIE = 1,
71   SURF_PROCESS_ON_FAILURE_RESTART = 0
72 } e_surf_process_on_failure_t;
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 typedef struct {
97   const char* id;
98   const char* link_up;
99   const char* link_down;
100 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
101
102
103 typedef struct {
104   const char* id;
105   const char* coord;
106 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
107
108 typedef struct {
109   const char* id;
110   double bandwidth;
111   tmgr_trace_t bandwidth_trace;
112   double latency;
113   tmgr_trace_t latency_trace;
114   e_surf_resource_state_t state;
115   tmgr_trace_t state_trace;
116   e_surf_link_sharing_policy_t policy;
117   xbt_dict_t properties;
118 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
119
120 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
121 typedef struct s_sg_platf_peer_cbarg {
122   const char* id;
123   double power;
124   double bw_in;
125   double bw_out;
126   double lat;
127   const char* coord;
128   tmgr_trace_t availability_trace;
129   tmgr_trace_t state_trace;
130 } s_sg_platf_peer_cbarg_t;
131
132 typedef struct s_sg_platf_linkctn_cbarg *sg_platf_linkctn_cbarg_t;
133 typedef struct s_sg_platf_linkctn_cbarg {
134   const char *id;
135   e_surf_link_ctn_direction_t direction;
136 } s_sg_platf_linkctn_cbarg_t;
137
138 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
139 typedef struct s_sg_platf_route_cbarg {
140   int symmetrical;
141   const char *src;
142   const char *dst;
143 } s_sg_platf_route_cbarg_t;
144
145 typedef struct s_sg_platf_ASroute_cbarg *sg_platf_ASroute_cbarg_t;
146 typedef struct s_sg_platf_ASroute_cbarg {
147   int symmetrical;
148   const char *src;
149   const char *dst;
150   const char *gw_src;
151   const char *gw_dst;
152 } s_sg_platf_ASroute_cbarg_t;
153
154 typedef struct s_sg_platf_bypassRoute_cbarg *sg_platf_bypassRoute_cbarg_t;
155 typedef struct s_sg_platf_bypassRoute_cbarg {
156   const char *src;
157   const char *dst;
158 } s_sg_platf_bypassRoute_cbarg_t;
159
160 typedef struct s_sg_platf_bypassASroute_cbarg *sg_platf_bypassASroute_cbarg_t;
161 typedef struct s_sg_platf_bypassASroute_cbarg {
162   const char *src;
163   const char *dst;
164   const char *gw_src;
165   const char *gw_dst;
166 } s_sg_platf_bypassASroute_cbarg_t;
167
168 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
169 typedef struct s_sg_platf_cluster_cbarg {
170   const char* id;
171   const char* prefix;
172   const char* suffix;
173   const char* radical;
174   double power;
175   int core_amount;
176   double bw;
177   double lat;
178   double bb_bw;
179   double bb_lat;
180   const char* router_id;
181   e_surf_link_sharing_policy_t sharing_policy;
182   e_surf_link_sharing_policy_t bb_sharing_policy;
183   const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
184   const char* state_trace;
185 } s_sg_platf_cluster_cbarg_t;
186
187 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
188 typedef struct s_sg_platf_cabinet_cbarg {
189   const char* id;
190   const char* prefix;
191   const char* suffix;
192   const char* radical;
193   double power;
194   double bw;
195   double lat;
196 } s_sg_platf_cabinet_cbarg_t;
197
198 typedef struct {
199   const char* id;
200   const char* type_id;
201   const char* content;
202 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
203
204 typedef struct {
205   const char* id;
206   const char* model;
207   const char* content;
208   xbt_dict_t properties;
209   unsigned long size; /* size in Gbytes */
210 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
211
212 typedef struct {
213   const char* type_id;
214   const char* name;
215 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
216
217 typedef struct {
218   const char* id;
219   const char* name;
220 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
221
222 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
223 typedef struct s_sg_platf_prop_cbarg {
224   const char *id;
225   const char *value;
226 } s_sg_platf_prop_cbarg_t;
227
228 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
229 typedef struct s_sg_platf_trace_cbarg {
230   const char *id;
231   const char *file;
232   double periodicity;
233   const char *pc_data;
234 } s_sg_platf_trace_cbarg_t;
235
236 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
237 typedef struct s_sg_platf_trace_connect_cbarg {
238   e_surf_trace_connect_kin_t kind;
239   const char *trace;
240   const char *element;
241 } s_sg_platf_trace_connect_cbarg_t;
242
243 typedef struct s_sg_platf_arg_cbarg *sg_platf_arg_cbarg_t;
244 typedef struct s_sg_platf_arg_cbarg {
245   const char *value;
246 } s_sg_platf_arg_cbarg_t;
247
248 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
249 typedef struct s_sg_platf_process_cbarg {
250   const char **argv;
251   int argc;
252   xbt_dict_t properties;
253   const char *host;
254   const char *function;
255   double start_time;
256   double kill_time;
257   e_surf_process_on_failure_t on_failure;
258 } s_sg_platf_process_cbarg_t;
259
260 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
261 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
262
263 XBT_PUBLIC(void) sg_platf_new_AS_begin(const char *id, int mode); // Begin description of new AS
264 XBT_PUBLIC(void) sg_platf_new_AS_end(void);                            // That AS is fully described
265
266 XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
267 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
268 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
269 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
270 XBT_PUBLIC(void) sg_platf_new_linkctn   (sg_platf_linkctn_cbarg_t linkctn);     // Add a linkctn
271 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
272 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
273 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
274
275 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
276 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_ASroute_cbarg_t ASroute); // Add an ASroute
277 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_bypassRoute_cbarg_t bypassroute); // Add a bypassRoute
278 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_bypassASroute_cbarg_t bypassASroute); // Add an bypassASroute
279 XBT_PUBLIC(void) sg_platf_new_prop (sg_platf_prop_cbarg_t prop); // Add a prop
280
281 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
282 XBT_PUBLIC(void) sg_platf_new_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
283
284 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
285 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
286 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
287 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
288 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
289
290 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
291 XBT_PUBLIC(void) sg_platf_new_arg(sg_platf_arg_cbarg_t arg);
292
293 #endif                          /* SG_PLATF_H */