1 /* platf.h - Public interface to the SimGrid platforms */
3 /* Copyright (c) 2004-2012. The SimGrid Team. All rights reserved. */
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. */
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;
16 XBT_PUBLIC(sg_routing_edge_t) sg_routing_edge_by_name_or_null(const char *name);
18 /** Defines whether a given resource is working or not */
20 SURF_RESOURCE_ON = 1, /**< Up & ready */
21 SURF_RESOURCE_OFF = 0 /**< Down & broken */
22 } e_surf_resource_state_t;
25 SURF_LINK_FULLDUPLEX = 2,
28 } e_surf_link_sharing_policy_t;
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_kind_t;
39 SURF_PROCESS_ON_FAILURE_DIE = 1,
40 SURF_PROCESS_ON_FAILURE_RESTART = 0
41 } e_surf_process_on_failure_t;
44 /* FIXME: Where should the VM state be defined? */
46 /* created, but not yet started */
47 SURF_VM_STATE_CREATED,
49 SURF_VM_STATE_RUNNING,
50 SURF_VM_STATE_MIGRATING,
52 /* Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
53 SURF_VM_STATE_SUSPENDED,
55 /* Save/restore involves disk I/O, so there should be transition states. */
58 SURF_VM_STATE_RESTORING,
62 typedef struct ws_params {
67 /* The size of other states than memory pages, which is out-of-scope of dirty
75 double dp_cap; /* bytes per 1 flop execution */
77 double xfer_cpu_overhead;
78 double dpt_cpu_overhead;
80 /* set migration speed */
82 } s_ws_params_t, *ws_params_t;
84 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
86 /** opaque structure defining a event generator for availability based on a probability distribution */
87 typedef struct probabilist_event_generator *probabilist_event_generator_t;
89 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename);
90 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
94 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_value(const char *id,
95 probabilist_event_generator_t date_generator,
96 probabilist_event_generator_t value_generator);
97 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_state(const char *id,
98 probabilist_event_generator_t date_generator,
99 e_surf_resource_state_t first_event_value);
100 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_avail_unavail(const char *id,
101 probabilist_event_generator_t avail_duration_generator,
102 probabilist_event_generator_t unavail_duration_generator,
103 e_surf_resource_state_t first_event_value);
105 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id,
108 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id,
110 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
113 typedef xbt_dictelm_t sg_host_t;
114 static inline char* sg_host_name(sg_host_t host) {
120 * Platform creation functions. Instead of passing 123 arguments to the creation functions
121 * (one for each possible XML attribute), we pass structures containing them all. It removes the
122 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
123 * old models can just continue to ignore it without having to update their headers.
125 * It shouldn't be too costly at runtime, provided that structures living on the stack are
126 * used, instead of malloced structures.
134 tmgr_trace_t power_trace;
135 e_surf_resource_state_t initial_state;
136 tmgr_trace_t state_trace;
138 xbt_dict_t properties;
139 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
141 #define SG_PLATF_HOST_INITIALIZER { \
146 .initial_state = SURF_RESOURCE_ON,\
147 .power_trace = NULL,\
148 .state_trace = NULL,\
156 const char* link_down;
157 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
159 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
164 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
166 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
171 tmgr_trace_t bandwidth_trace;
173 tmgr_trace_t latency_trace;
174 e_surf_resource_state_t state;
175 tmgr_trace_t state_trace;
176 e_surf_link_sharing_policy_t policy;
177 xbt_dict_t properties;
178 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
180 #define SG_PLATF_LINK_INITIALIZER {\
183 .bandwidth_trace = NULL,\
185 .latency_trace = NULL,\
186 .state = SURF_RESOURCE_ON,\
187 .state_trace = NULL,\
188 .policy = SURF_LINK_SHARED,\
192 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
193 typedef struct s_sg_platf_peer_cbarg {
200 tmgr_trace_t availability_trace;
201 tmgr_trace_t state_trace;
202 } s_sg_platf_peer_cbarg_t;
204 #define SG_PLATF_PEER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
206 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
207 typedef struct s_sg_platf_route_cbarg {
211 sg_routing_edge_t gw_src;
212 sg_routing_edge_t gw_dst;
213 xbt_dynar_t link_list;
214 } s_sg_platf_route_cbarg_t;
216 #define SG_PLATF_ROUTE_INITIALIZER {TRUE,NULL,NULL,NULL,NULL,NULL}
218 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
219 typedef struct s_sg_platf_cluster_cbarg {
233 const char* router_id;
234 e_surf_link_sharing_policy_t sharing_policy;
235 e_surf_link_sharing_policy_t bb_sharing_policy;
236 const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
237 const char* state_trace;
238 } s_sg_platf_cluster_cbarg_t;
240 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL \
241 ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
243 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
244 typedef struct s_sg_platf_cabinet_cbarg {
252 } s_sg_platf_cabinet_cbarg_t;
254 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL}
260 xbt_dict_t properties;
261 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
263 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL}
269 xbt_dict_t properties;
270 unsigned long size; /* size in Gbytes */
271 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
273 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL}
278 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
280 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
285 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
287 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
289 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
290 typedef struct s_sg_platf_prop_cbarg {
293 } s_sg_platf_prop_cbarg_t;
295 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
297 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
298 typedef struct s_sg_platf_trace_cbarg {
303 } s_sg_platf_trace_cbarg_t;
305 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,NULL,NULL}
307 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
308 typedef struct s_sg_platf_trace_connect_cbarg {
309 e_surf_trace_connect_kind_t kind;
312 } s_sg_platf_trace_connect_cbarg_t;
314 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {NULL,NULL,NULL}
316 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
317 typedef struct s_sg_platf_process_cbarg {
320 xbt_dict_t properties;
322 const char *function;
325 e_surf_process_on_failure_t on_failure;
326 } s_sg_platf_process_cbarg_t;
328 #define SG_PLATF_PROCESS_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
330 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
331 typedef struct s_sg_platf_AS_cbarg {
334 } s_sg_platf_AS_cbarg_t;
336 #define SG_PLATF_AS_INITIALIZER {NULL,0}
338 /* ***************************************** */
339 /* TUTORIAL: New TAG */
341 typedef struct s_sg_platf_gpu_cbarg *sg_platf_gpu_cbarg_t;
342 typedef struct s_sg_platf_gpu_cbarg {
344 } s_sg_platf_gpu_cbarg_t;
346 #define SG_PLATF_GPU_INITIALIZER {NULL}
348 /* ***************************************** */
350 XBT_PUBLIC(void) sg_platf_begin(void); // Start a new platform
351 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
353 XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
354 XBT_PUBLIC(void) sg_platf_new_AS_end(void); // That AS is fully described
356 XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an host to the currently described AS
357 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
358 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router to the currently described AS
359 XBT_PUBLIC(void) sg_platf_new_link (sg_platf_link_cbarg_t link); // Add a link to the currently described AS
360 XBT_PUBLIC(void) sg_platf_new_peer (sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS
361 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
362 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
364 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
365 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_route_cbarg_t ASroute); // Add an ASroute
366 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
367 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_route_cbarg_t bypassASroute); // Add an bypassASroute
368 XBT_PUBLIC(void) sg_platf_new_prop (sg_platf_prop_cbarg_t prop); // Add a prop
370 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
371 XBT_PUBLIC(void) sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
373 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
374 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
375 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
376 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
377 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
379 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
381 /* ***************************************** */
382 /* TUTORIAL: New TAG */
383 XBT_PUBLIC(void) sg_platf_new_gpu(sg_platf_gpu_cbarg_t gpu);
384 /* ***************************************** */
386 // Add route and Asroute without xml file with those functions
387 XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route
388 XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route
390 XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute); // Initialize ASroute
391 XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute); // Finalize and add a ASroute
393 XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list
394 XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute); // Add a link to link list
396 typedef void (*sg_platf_process_cb_t)(sg_platf_process_cbarg_t);
397 XBT_PUBLIC(void) sg_platf_process_add_cb(sg_platf_process_cb_t fct);
400 #endif /* SG_PLATF_H */