1 /* platf.h - Public interface to the SimGrid platforms */
3 /* Copyright (c) 2004-2013. The SimGrid Team.
4 * All rights reserved. */
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. */
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;
17 XBT_PUBLIC(sg_routing_edge_t) sg_routing_edge_by_name_or_null(const char *name);
19 /** Defines whether a given resource is working or not */
21 SURF_RESOURCE_ON = 1, /**< Up & ready */
22 SURF_RESOURCE_OFF = 0 /**< Down & broken */
23 } e_surf_resource_state_t;
26 SURF_LINK_FULLDUPLEX = 2,
29 } e_surf_link_sharing_policy_t;
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;
40 SURF_PROCESS_ON_FAILURE_DIE = 1,
41 SURF_PROCESS_ON_FAILURE_RESTART = 0
42 } e_surf_process_on_failure_t;
45 /* FIXME: Where should the VM state be defined? */
47 /* created, but not yet started */
48 SURF_VM_STATE_CREATED,
50 SURF_VM_STATE_RUNNING,
51 SURF_VM_STATE_MIGRATING,
53 /* Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
54 SURF_VM_STATE_SUSPENDED,
56 /* Save/restore involves disk I/O, so there should be transition states. */
59 SURF_VM_STATE_RESTORING,
63 typedef struct ws_params {
68 /* The size of other states than memory pages, which is out-of-scope of dirty
76 double dp_cap; /* bytes per 1 flop execution */
78 double xfer_cpu_overhead;
79 double dpt_cpu_overhead;
81 /* set migration speed */
83 } s_ws_params_t, *ws_params_t;
85 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
87 /** opaque structure defining a event generator for availability based on a probability distribution */
88 typedef struct probabilist_event_generator *probabilist_event_generator_t;
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,
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);
106 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id,
109 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id,
111 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
114 typedef xbt_dictelm_t sg_host_t;
115 static inline char* sg_host_name(sg_host_t host) {
119 typedef xbt_dictelm_t sg_storage_t;
120 static inline char* sg_storage_name(sg_storage_t storage) {
123 /* Type for any integer storage size */
124 typedef uint64_t sg_storage_size_t;
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.
133 * It shouldn't be too costly at runtime, provided that structures living on the stack are
134 * used, instead of malloced structures.
139 xbt_dynar_t power_peak;
143 tmgr_trace_t power_trace;
144 e_surf_resource_state_t initial_state;
145 tmgr_trace_t state_trace;
147 xbt_dict_t properties;
148 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
150 #define SG_PLATF_HOST_INITIALIZER { \
155 .initial_state = SURF_RESOURCE_ON,\
156 .power_trace = NULL,\
157 .state_trace = NULL,\
165 const char* link_down;
166 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
168 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
173 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
175 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
180 tmgr_trace_t bandwidth_trace;
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;
189 #define SG_PLATF_LINK_INITIALIZER {\
192 .bandwidth_trace = NULL,\
194 .latency_trace = NULL,\
195 .state = SURF_RESOURCE_ON,\
196 .state_trace = NULL,\
197 .policy = SURF_LINK_SHARED,\
201 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
202 typedef struct s_sg_platf_peer_cbarg {
209 tmgr_trace_t availability_trace;
210 tmgr_trace_t state_trace;
211 } s_sg_platf_peer_cbarg_t;
213 #define SG_PLATF_PEER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
215 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
216 typedef struct s_sg_platf_route_cbarg {
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;
225 #define SG_PLATF_ROUTE_INITIALIZER {TRUE,NULL,NULL,NULL,NULL,NULL}
227 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
228 typedef struct s_sg_platf_cluster_cbarg {
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;
250 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL \
251 ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
253 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
254 typedef struct s_sg_platf_cabinet_cbarg {
262 } s_sg_platf_cabinet_cbarg_t;
264 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL}
270 const char* content_type;
271 xbt_dict_t properties;
272 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
274 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL}
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;
285 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL}
290 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
292 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
295 const char* storageId;
297 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
299 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
301 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
302 typedef struct s_sg_platf_prop_cbarg {
305 } s_sg_platf_prop_cbarg_t;
307 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
309 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
310 typedef struct s_sg_platf_trace_cbarg {
315 } s_sg_platf_trace_cbarg_t;
317 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,NULL,NULL}
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;
324 } s_sg_platf_trace_connect_cbarg_t;
326 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {NULL,NULL,NULL}
328 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
329 typedef struct s_sg_platf_process_cbarg {
332 xbt_dict_t properties;
334 const char *function;
337 e_surf_process_on_failure_t on_failure;
338 } s_sg_platf_process_cbarg_t;
340 #define SG_PLATF_PROCESS_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
342 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
343 typedef struct s_sg_platf_AS_cbarg {
346 } s_sg_platf_AS_cbarg_t;
348 #define SG_PLATF_AS_INITIALIZER {NULL,0}
350 /* ***************************************** */
351 /* TUTORIAL: New TAG */
353 typedef struct s_sg_platf_gpu_cbarg *sg_platf_gpu_cbarg_t;
354 typedef struct s_sg_platf_gpu_cbarg {
356 } s_sg_platf_gpu_cbarg_t;
358 #define SG_PLATF_GPU_INITIALIZER {NULL}
360 /* ***************************************** */
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
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
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
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
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);
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);
391 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
393 /* ***************************************** */
394 /* TUTORIAL: New TAG */
395 XBT_PUBLIC(void) sg_platf_new_gpu(sg_platf_gpu_cbarg_t gpu);
396 /* ***************************************** */
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
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
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
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);
412 #endif /* SG_PLATF_H */