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; /* FIXME:The actual type is model-dependent so use void* instead*/
15 typedef struct RoutingEdge *sg_routing_edge_t;
20 XBT_PUBLIC(sg_routing_edge_t) sg_routing_edge_by_name_or_null(const char *name);
25 /** Defines whether a given resource is working or not */
27 SURF_RESOURCE_ON = 1, /**< Up & ready */
28 SURF_RESOURCE_OFF = 0 /**< Down & broken */
29 } e_surf_resource_state_t;
32 SURF_LINK_FULLDUPLEX = 2,
35 } e_surf_link_sharing_policy_t;
38 SURF_TRACE_CONNECT_KIND_HOST_AVAIL = 4,
39 SURF_TRACE_CONNECT_KIND_POWER = 3,
40 SURF_TRACE_CONNECT_KIND_LINK_AVAIL = 2,
41 SURF_TRACE_CONNECT_KIND_BANDWIDTH = 1,
42 SURF_TRACE_CONNECT_KIND_LATENCY = 0
43 } e_surf_trace_connect_kind_t;
46 SURF_PROCESS_ON_FAILURE_DIE = 1,
47 SURF_PROCESS_ON_FAILURE_RESTART = 0
48 } e_surf_process_on_failure_t;
51 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
53 /** opaque structure defining a event generator for availability based on a probability distribution */
54 typedef struct probabilist_event_generator *probabilist_event_generator_t;
59 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename);
60 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
64 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_value(const char *id,
65 probabilist_event_generator_t date_generator,
66 probabilist_event_generator_t value_generator);
67 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_state(const char *id,
68 probabilist_event_generator_t date_generator,
69 e_surf_resource_state_t first_event_value);
70 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_avail_unavail(const char *id,
71 probabilist_event_generator_t avail_duration_generator,
72 probabilist_event_generator_t unavail_duration_generator,
73 e_surf_resource_state_t first_event_value);
75 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id,
78 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id,
80 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
87 typedef xbt_dictelm_t sg_host_t;
88 static inline char* sg_host_name(sg_host_t host) {
92 typedef xbt_dictelm_t sg_storage_t;
93 static inline char* sg_storage_name(sg_storage_t storage) {
96 /* Type for any integer storage size */
97 typedef uint64_t sg_storage_size_t;
101 * Platform creation functions. Instead of passing 123 arguments to the creation functions
102 * (one for each possible XML attribute), we pass structures containing them all. It removes the
103 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
104 * old models can just continue to ignore it without having to update their headers.
106 * It shouldn't be too costly at runtime, provided that structures living on the stack are
107 * used, instead of malloced structures.
112 xbt_dynar_t power_peak;
116 tmgr_trace_t power_trace;
117 e_surf_resource_state_t initial_state;
118 tmgr_trace_t state_trace;
120 xbt_dict_t properties;
121 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
123 #define SG_PLATF_HOST_INITIALIZER { \
128 .initial_state = SURF_RESOURCE_ON,\
129 .power_trace = NULL,\
130 .state_trace = NULL,\
138 const char* link_down;
139 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
141 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
146 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
148 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
153 tmgr_trace_t bandwidth_trace;
155 tmgr_trace_t latency_trace;
156 e_surf_resource_state_t state;
157 tmgr_trace_t state_trace;
158 e_surf_link_sharing_policy_t policy;
159 xbt_dict_t properties;
160 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
162 #define SG_PLATF_LINK_INITIALIZER {\
165 .bandwidth_trace = NULL,\
167 .latency_trace = NULL,\
168 .state = SURF_RESOURCE_ON,\
169 .state_trace = NULL,\
170 .policy = SURF_LINK_SHARED,\
174 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
175 typedef struct s_sg_platf_peer_cbarg {
182 tmgr_trace_t availability_trace;
183 tmgr_trace_t state_trace;
184 } s_sg_platf_peer_cbarg_t;
186 #define SG_PLATF_PEER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
188 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
189 typedef struct s_sg_platf_route_cbarg {
193 sg_routing_edge_t gw_src;
194 sg_routing_edge_t gw_dst;
195 xbt_dynar_t link_list;
196 } s_sg_platf_route_cbarg_t;
198 #define SG_PLATF_ROUTE_INITIALIZER {TRUE,NULL,NULL,NULL,NULL,NULL}
200 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
201 typedef struct s_sg_platf_cluster_cbarg {
215 xbt_dict_t properties;
216 const char* router_id;
217 e_surf_link_sharing_policy_t sharing_policy;
218 e_surf_link_sharing_policy_t bb_sharing_policy;
219 const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
220 const char* state_trace;
221 } s_sg_platf_cluster_cbarg_t;
223 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL \
224 ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
226 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
227 typedef struct s_sg_platf_cabinet_cbarg {
235 } s_sg_platf_cabinet_cbarg_t;
237 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL}
243 const char* content_type;
244 xbt_dict_t properties;
245 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
247 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL}
253 const char* content_type;
254 xbt_dict_t properties;
255 sg_storage_size_t size;
256 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
258 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL}
263 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
265 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
268 const char* storageId;
270 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
272 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
274 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
275 typedef struct s_sg_platf_prop_cbarg {
278 } s_sg_platf_prop_cbarg_t;
280 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
282 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
283 typedef struct s_sg_platf_trace_cbarg {
288 } s_sg_platf_trace_cbarg_t;
290 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,NULL,NULL}
292 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
293 typedef struct s_sg_platf_trace_connect_cbarg {
294 e_surf_trace_connect_kind_t kind;
297 } s_sg_platf_trace_connect_cbarg_t;
299 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {NULL,NULL,NULL}
301 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
302 typedef struct s_sg_platf_process_cbarg {
305 xbt_dict_t properties;
307 const char *function;
310 e_surf_process_on_failure_t on_failure;
311 } s_sg_platf_process_cbarg_t;
313 #define SG_PLATF_PROCESS_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
315 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
316 typedef struct s_sg_platf_AS_cbarg {
319 } s_sg_platf_AS_cbarg_t;
321 #define SG_PLATF_AS_INITIALIZER {NULL,0}
323 /* ***************************************** */
324 /* TUTORIAL: New TAG */
326 typedef struct s_sg_platf_gpu_cbarg *sg_platf_gpu_cbarg_t;
327 typedef struct s_sg_platf_gpu_cbarg {
329 } s_sg_platf_gpu_cbarg_t;
331 #define SG_PLATF_GPU_INITIALIZER {NULL}
333 /* ***************************************** */
339 XBT_PUBLIC(void) sg_platf_begin(void); // Start a new platform
340 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
342 XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
343 XBT_PUBLIC(void) sg_platf_new_AS_end(void); // That AS is fully described
345 XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an host to the currently described AS
346 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
347 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router to the currently described AS
348 XBT_PUBLIC(void) sg_platf_new_link (sg_platf_link_cbarg_t link); // Add a link to the currently described AS
349 XBT_PUBLIC(void) sg_platf_new_peer (sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS
350 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
351 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
353 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
354 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_route_cbarg_t ASroute); // Add an ASroute
355 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
356 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_route_cbarg_t bypassASroute); // Add an bypassASroute
357 XBT_PUBLIC(void) sg_platf_new_prop (sg_platf_prop_cbarg_t prop); // Add a prop
359 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
360 XBT_PUBLIC(void) sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
362 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
363 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
364 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
365 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
366 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
368 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
370 /* ***************************************** */
371 /* TUTORIAL: New TAG */
372 XBT_PUBLIC(void) sg_platf_new_gpu(sg_platf_gpu_cbarg_t gpu);
373 /* ***************************************** */
375 // Add route and Asroute without xml file with those functions
376 XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route
377 XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route
379 XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute); // Initialize ASroute
380 XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute); // Finalize and add a ASroute
382 XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list
383 XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute); // Add a link to link list
385 typedef void (*sg_platf_process_cb_t)(sg_platf_process_cbarg_t);
386 XBT_PUBLIC(void) sg_platf_process_add_cb(sg_platf_process_cb_t fct);
392 #endif /* SG_PLATF_H */