Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge tag 'v3_9_90' into hypervisor
[simgrid.git] / include / simgrid / platf.h
1 /* platf.h - Public interface to the SimGrid platforms                      */
2
3 /* Copyright (c) 2004-2013. 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
14 typedef void *sg_routing_link_t; /* The actual type is model-dependent so use void* instead*/
15 typedef struct s_routing_edge *sg_routing_edge_t;
16
17 XBT_PUBLIC(sg_routing_edge_t) sg_routing_edge_by_name_or_null(const char *name);
18
19 /** Defines whether a given resource is working or not */
20 typedef enum {
21   SURF_RESOURCE_ON = 1,                   /**< Up & ready        */
22   SURF_RESOURCE_OFF = 0                   /**< Down & broken     */
23 } e_surf_resource_state_t;
24
25 typedef enum {
26   SURF_LINK_FULLDUPLEX = 2,
27   SURF_LINK_SHARED = 1,
28   SURF_LINK_FATPIPE = 0
29 } e_surf_link_sharing_policy_t;
30
31 typedef enum {
32   SURF_TRACE_CONNECT_KIND_HOST_AVAIL = 4,
33   SURF_TRACE_CONNECT_KIND_POWER = 3,
34   SURF_TRACE_CONNECT_KIND_LINK_AVAIL = 2,
35   SURF_TRACE_CONNECT_KIND_BANDWIDTH = 1,
36   SURF_TRACE_CONNECT_KIND_LATENCY = 0
37 } e_surf_trace_connect_kind_t;
38
39 typedef enum {
40   SURF_PROCESS_ON_FAILURE_DIE = 1,
41   SURF_PROCESS_ON_FAILURE_RESTART = 0
42 } e_surf_process_on_failure_t;
43
44
45 /* FIXME: Where should the VM state be defined? */
46 typedef enum {
47   /* created, but not yet started */
48   SURF_VM_STATE_CREATED,
49
50   SURF_VM_STATE_RUNNING,
51   SURF_VM_STATE_MIGRATING,
52
53   /* Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
54   SURF_VM_STATE_SUSPENDED,
55
56   /* Save/restore involves disk I/O, so there should be transition states. */
57   SURF_VM_STATE_SAVING,
58   SURF_VM_STATE_SAVED,
59   SURF_VM_STATE_RESTORING,
60
61 } e_surf_vm_state_t;
62
63 typedef struct ws_params {
64   int ncpus;
65   long ramsize;
66   int overcommit;
67
68   /* The size of other states than memory pages, which is out-of-scope of dirty
69    * page tracking. */
70   long devsize;
71   int skip_stage1;
72   int skip_stage2;
73   double max_downtime;
74
75   double dp_rate;
76   double dp_cap; /* bytes per 1 flop execution */
77
78   double xfer_cpu_overhead;
79   double dpt_cpu_overhead;
80
81   /* set migration speed */
82   double mig_speed;
83 } s_ws_params_t, *ws_params_t;
84
85 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
86
87 /** opaque structure defining a event generator for availability based on a probability distribution */
88 typedef struct probabilist_event_generator *probabilist_event_generator_t;
89
90 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename);
91 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
92                                                     const char *input,
93                                                     double periodicity);
94
95 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_value(const char *id,
96                                               probabilist_event_generator_t date_generator,
97                                               probabilist_event_generator_t value_generator);
98 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_state(const char *id,
99                                               probabilist_event_generator_t date_generator,
100                                               e_surf_resource_state_t first_event_value);
101 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_avail_unavail(const char *id,
102                                               probabilist_event_generator_t avail_duration_generator,
103                                               probabilist_event_generator_t unavail_duration_generator,
104                                               e_surf_resource_state_t first_event_value);
105
106 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id,
107                                                                            double min,
108                                                                            double max);
109 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id,
110                                                                            double rate);
111 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
112                                                                            double scale,
113                                                                            double shape);
114 typedef xbt_dictelm_t sg_host_t;
115 static inline char* sg_host_name(sg_host_t host) {
116   return host->key;
117 }
118
119 typedef xbt_dictelm_t sg_storage_t;
120 static inline char* sg_storage_name(sg_storage_t storage) {
121   return storage->key;
122 }
123 /* Type for any integer storage size  */
124 typedef uint64_t sg_storage_size_t;
125
126
127 /*
128  * Platform creation functions. Instead of passing 123 arguments to the creation functions
129  * (one for each possible XML attribute), we pass structures containing them all. It removes the
130  * chances of switching arguments by error, and reduce the burden when we add a new attribute:
131  * old models can just continue to ignore it without having to update their headers.
132  *
133  * It shouldn't be too costly at runtime, provided that structures living on the stack are
134  * used, instead of malloced structures.
135  */
136
137 typedef struct {
138   const char* id;
139   xbt_dynar_t power_peak;
140   int pstate;
141   int core_amount;
142   double power_scale;
143   tmgr_trace_t power_trace;
144   e_surf_resource_state_t initial_state;
145   tmgr_trace_t state_trace;
146   const char* coord;
147   xbt_dict_t properties;
148 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
149
150 #define SG_PLATF_HOST_INITIALIZER { \
151     .id = NULL,\
152     .power_peak = 0,\
153     .core_amount = 1.,\
154     .power_scale = 1,\
155     .initial_state = SURF_RESOURCE_ON,\
156     .power_trace = NULL,\
157     .state_trace = NULL,\
158     .coord = NULL,\
159     .properties = NULL\
160     }
161
162 typedef struct {
163   const char* id;
164   const char* link_up;
165   const char* link_down;
166 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
167
168 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
169
170 typedef struct {
171   const char* id;
172   const char* coord;
173 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
174
175 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
176
177 typedef struct {
178   const char* id;
179   double bandwidth;
180   tmgr_trace_t bandwidth_trace;
181   double latency;
182   tmgr_trace_t latency_trace;
183   e_surf_resource_state_t state;
184   tmgr_trace_t state_trace;
185   e_surf_link_sharing_policy_t policy;
186   xbt_dict_t properties;
187 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
188
189 #define SG_PLATF_LINK_INITIALIZER {\
190   .id = NULL,\
191   .bandwidth = 0.,\
192   .bandwidth_trace = NULL,\
193   .latency = 0.,\
194   .latency_trace = NULL,\
195   .state = SURF_RESOURCE_ON,\
196   .state_trace = NULL,\
197   .policy = SURF_LINK_SHARED,\
198   .properties = NULL\
199 }
200
201 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
202 typedef struct s_sg_platf_peer_cbarg {
203   const char* id;
204   double power;
205   double bw_in;
206   double bw_out;
207   double lat;
208   const char* coord;
209   tmgr_trace_t availability_trace;
210   tmgr_trace_t state_trace;
211 } s_sg_platf_peer_cbarg_t;
212
213 #define SG_PLATF_PEER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
214
215 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
216 typedef struct s_sg_platf_route_cbarg {
217   int symmetrical;
218   const char *src;
219   const char *dst;
220   sg_routing_edge_t gw_src;
221   sg_routing_edge_t gw_dst;
222   xbt_dynar_t link_list;
223 } s_sg_platf_route_cbarg_t;
224
225 #define SG_PLATF_ROUTE_INITIALIZER {TRUE,NULL,NULL,NULL,NULL,NULL}
226
227 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
228 typedef struct s_sg_platf_cluster_cbarg {
229   const char* id;
230   const char* prefix;
231   const char* suffix;
232   const char* radical;
233   double power;
234   int core_amount;
235   double bw;
236   double lat;
237   double bb_bw;
238   double bb_lat;
239   double loopback_bw;
240   double loopback_lat;
241   double limiter_link;
242   xbt_dict_t properties;
243   const char* router_id;
244   e_surf_link_sharing_policy_t sharing_policy;
245   e_surf_link_sharing_policy_t bb_sharing_policy;
246   const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
247   const char* state_trace;
248 } s_sg_platf_cluster_cbarg_t;
249
250 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL \
251   ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
252
253 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
254 typedef struct s_sg_platf_cabinet_cbarg {
255   const char* id;
256   const char* prefix;
257   const char* suffix;
258   const char* radical;
259   double power;
260   double bw;
261   double lat;
262 } s_sg_platf_cabinet_cbarg_t;
263
264 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL}
265
266 typedef struct {
267   const char* id;
268   const char* type_id;
269   const char* content;
270   const char* content_type;
271   xbt_dict_t properties;
272 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
273
274 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL}
275
276 typedef struct {
277   const char* id;
278   const char* model;
279   const char* content;
280   const char* content_type;
281   xbt_dict_t properties;
282   sg_storage_size_t size;
283 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
284
285 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL}
286
287 typedef struct {
288   const char* type_id;
289   const char* name;
290 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
291
292 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
293
294 typedef struct {
295   const char* storageId;
296   const char* name;
297 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
298
299 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
300
301 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
302 typedef struct s_sg_platf_prop_cbarg {
303   const char *id;
304   const char *value;
305 } s_sg_platf_prop_cbarg_t;
306
307 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
308
309 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
310 typedef struct s_sg_platf_trace_cbarg {
311   const char *id;
312   const char *file;
313   double periodicity;
314   const char *pc_data;
315 } s_sg_platf_trace_cbarg_t;
316
317 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,NULL,NULL}
318
319 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
320 typedef struct s_sg_platf_trace_connect_cbarg {
321   e_surf_trace_connect_kind_t kind;
322   const char *trace;
323   const char *element;
324 } s_sg_platf_trace_connect_cbarg_t;
325
326 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {NULL,NULL,NULL}
327
328 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
329 typedef struct s_sg_platf_process_cbarg {
330   const char **argv;
331   int argc;
332   xbt_dict_t properties;
333   const char *host;
334   const char *function;
335   double start_time;
336   double kill_time;
337   e_surf_process_on_failure_t on_failure;
338 } s_sg_platf_process_cbarg_t;
339
340 #define SG_PLATF_PROCESS_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
341
342 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
343 typedef struct s_sg_platf_AS_cbarg {
344   const char *id;
345   int routing;
346 } s_sg_platf_AS_cbarg_t;
347
348 #define SG_PLATF_AS_INITIALIZER {NULL,0}
349
350 /* ***************************************** */
351 /* TUTORIAL: New TAG                         */
352
353 typedef struct s_sg_platf_gpu_cbarg *sg_platf_gpu_cbarg_t;
354 typedef struct s_sg_platf_gpu_cbarg {
355   const char *name;
356 } s_sg_platf_gpu_cbarg_t;
357
358 #define SG_PLATF_GPU_INITIALIZER {NULL}
359
360 /* ***************************************** */
361
362 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
363 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
364
365 XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
366 XBT_PUBLIC(void) sg_platf_new_AS_end(void);                            // That AS is fully described
367
368 XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
369 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
370 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
371 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
372 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
373 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
374 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
375
376 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
377 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_route_cbarg_t ASroute); // Add an ASroute
378 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
379 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_route_cbarg_t bypassASroute); // Add an bypassASroute
380 XBT_PUBLIC(void) sg_platf_new_prop (sg_platf_prop_cbarg_t prop); // Add a prop
381
382 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
383 XBT_PUBLIC(void) sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
384
385 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
386 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
387 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
388 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
389 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
390
391 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
392
393 /* ***************************************** */
394 /* TUTORIAL: New TAG                         */
395 XBT_PUBLIC(void) sg_platf_new_gpu(sg_platf_gpu_cbarg_t gpu);
396 /* ***************************************** */
397
398 // Add route and Asroute without xml file with those functions
399 XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route
400 XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route
401
402 XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute); // Initialize ASroute
403 XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute); // Finalize and add a ASroute
404
405 XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list
406 XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute); // Add a link to link list
407
408 typedef void (*sg_platf_process_cb_t)(sg_platf_process_cbarg_t);
409 XBT_PUBLIC(void) sg_platf_process_add_cb(sg_platf_process_cb_t fct);
410
411
412 #endif                          /* SG_PLATF_H */