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. */
13 #define __STDC_FORMAT_MACROS
16 typedef void *sg_routing_link_t; /* FIXME:The actual type is model-dependent so use void* instead*/
17 typedef struct RoutingEdge *sg_routing_edge_t;
22 XBT_PUBLIC(sg_routing_edge_t) sg_routing_edge_by_name_or_null(const char *name);
27 /** Defines whether a given resource is working or not */
29 SURF_RESOURCE_ON = 1, /**< Up & ready */
30 SURF_RESOURCE_OFF = 0 /**< Down & broken */
31 } e_surf_resource_state_t;
34 SURF_LINK_FULLDUPLEX = 2,
37 } e_surf_link_sharing_policy_t;
40 SURF_TRACE_CONNECT_KIND_HOST_AVAIL = 4,
41 SURF_TRACE_CONNECT_KIND_POWER = 3,
42 SURF_TRACE_CONNECT_KIND_LINK_AVAIL = 2,
43 SURF_TRACE_CONNECT_KIND_BANDWIDTH = 1,
44 SURF_TRACE_CONNECT_KIND_LATENCY = 0
45 } e_surf_trace_connect_kind_t;
48 SURF_PROCESS_ON_FAILURE_DIE = 1,
49 SURF_PROCESS_ON_FAILURE_RESTART = 0
50 } e_surf_process_on_failure_t;
53 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
55 /** opaque structure defining a event generator for availability based on a probability distribution */
56 typedef struct probabilist_event_generator *probabilist_event_generator_t;
61 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename);
62 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
66 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_value(const char *id,
67 probabilist_event_generator_t date_generator,
68 probabilist_event_generator_t value_generator);
69 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_state(const char *id,
70 probabilist_event_generator_t date_generator,
71 e_surf_resource_state_t first_event_value);
72 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_avail_unavail(const char *id,
73 probabilist_event_generator_t avail_duration_generator,
74 probabilist_event_generator_t unavail_duration_generator,
75 e_surf_resource_state_t first_event_value);
77 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id,
80 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id,
82 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
89 typedef xbt_dictelm_t sg_host_t;
90 static inline char* sg_host_name(sg_host_t host) {
94 typedef xbt_dictelm_t sg_storage_t;
95 static inline char* sg_storage_name(sg_storage_t storage) {
98 /* Type for any simgrid size size */
99 typedef uint64_t sg_size_t;
102 * Platform creation functions. Instead of passing 123 arguments to the creation functions
103 * (one for each possible XML attribute), we pass structures containing them all. It removes the
104 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
105 * old models can just continue to ignore it without having to update their headers.
107 * It shouldn't be too costly at runtime, provided that structures living on the stack are
108 * used, instead of malloced structures.
113 xbt_dynar_t power_peak;
117 tmgr_trace_t power_trace;
118 e_surf_resource_state_t initial_state;
119 tmgr_trace_t state_trace;
121 xbt_dict_t properties;
122 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
124 #define SG_PLATF_HOST_INITIALIZER { \
129 .initial_state = SURF_RESOURCE_ON,\
130 .power_trace = NULL,\
131 .state_trace = NULL,\
139 const char* link_down;
140 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
142 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
147 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
149 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
154 tmgr_trace_t bandwidth_trace;
156 tmgr_trace_t latency_trace;
157 e_surf_resource_state_t state;
158 tmgr_trace_t state_trace;
159 e_surf_link_sharing_policy_t policy;
160 xbt_dict_t properties;
161 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
163 #define SG_PLATF_LINK_INITIALIZER {\
166 .bandwidth_trace = NULL,\
168 .latency_trace = NULL,\
169 .state = SURF_RESOURCE_ON,\
170 .state_trace = NULL,\
171 .policy = SURF_LINK_SHARED,\
175 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
176 typedef struct s_sg_platf_peer_cbarg {
183 tmgr_trace_t availability_trace;
184 tmgr_trace_t state_trace;
185 } s_sg_platf_peer_cbarg_t;
187 #define SG_PLATF_PEER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
189 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
190 typedef struct s_sg_platf_route_cbarg {
194 sg_routing_edge_t gw_src;
195 sg_routing_edge_t gw_dst;
196 xbt_dynar_t link_list;
197 } s_sg_platf_route_cbarg_t;
199 #define SG_PLATF_ROUTE_INITIALIZER {TRUE,NULL,NULL,NULL,NULL,NULL}
201 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
202 typedef struct s_sg_platf_cluster_cbarg {
216 xbt_dict_t properties;
217 const char* router_id;
218 e_surf_link_sharing_policy_t sharing_policy;
219 e_surf_link_sharing_policy_t bb_sharing_policy;
220 const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
221 const char* state_trace;
222 } s_sg_platf_cluster_cbarg_t;
224 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL \
225 ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
227 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
228 typedef struct s_sg_platf_cabinet_cbarg {
236 } s_sg_platf_cabinet_cbarg_t;
238 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL}
244 const char* content_type;
245 xbt_dict_t properties;
246 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
248 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL}
254 const char* content_type;
255 xbt_dict_t properties;
257 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
259 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL}
264 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
266 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
269 const char* storageId;
271 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
273 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
275 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
276 typedef struct s_sg_platf_prop_cbarg {
279 } s_sg_platf_prop_cbarg_t;
281 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
283 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
284 typedef struct s_sg_platf_trace_cbarg {
289 } s_sg_platf_trace_cbarg_t;
291 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,NULL,NULL}
293 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
294 typedef struct s_sg_platf_trace_connect_cbarg {
295 e_surf_trace_connect_kind_t kind;
298 } s_sg_platf_trace_connect_cbarg_t;
300 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {NULL,NULL,NULL}
302 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
303 typedef struct s_sg_platf_process_cbarg {
306 xbt_dict_t properties;
308 const char *function;
311 e_surf_process_on_failure_t on_failure;
312 } s_sg_platf_process_cbarg_t;
314 #define SG_PLATF_PROCESS_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
316 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
317 typedef struct s_sg_platf_AS_cbarg {
320 } s_sg_platf_AS_cbarg_t;
322 #define SG_PLATF_AS_INITIALIZER {NULL,0}
324 /* ***************************************** */
325 /* TUTORIAL: New TAG */
327 typedef struct s_sg_platf_gpu_cbarg *sg_platf_gpu_cbarg_t;
328 typedef struct s_sg_platf_gpu_cbarg {
330 } s_sg_platf_gpu_cbarg_t;
332 #define SG_PLATF_GPU_INITIALIZER {NULL}
334 /* ***************************************** */
340 XBT_PUBLIC(void) sg_platf_begin(void); // Start a new platform
341 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
343 XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
344 XBT_PUBLIC(void) sg_platf_new_AS_end(void); // That AS is fully described
346 XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an host to the currently described AS
347 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
348 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router to the currently described AS
349 XBT_PUBLIC(void) sg_platf_new_link (sg_platf_link_cbarg_t link); // Add a link to the currently described AS
350 XBT_PUBLIC(void) sg_platf_new_peer (sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS
351 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
352 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
354 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
355 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_route_cbarg_t ASroute); // Add an ASroute
356 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
357 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_route_cbarg_t bypassASroute); // Add an bypassASroute
358 XBT_PUBLIC(void) sg_platf_new_prop (sg_platf_prop_cbarg_t prop); // Add a prop
360 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
361 XBT_PUBLIC(void) sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
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_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
365 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
366 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
367 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
369 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
371 /* ***************************************** */
372 /* TUTORIAL: New TAG */
373 XBT_PUBLIC(void) sg_platf_new_gpu(sg_platf_gpu_cbarg_t gpu);
374 /* ***************************************** */
376 // Add route and Asroute without xml file with those functions
377 XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route
378 XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route
380 XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute); // Initialize ASroute
381 XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute); // Finalize and add a ASroute
383 XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list
384 XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute); // Add a link to link list
386 typedef void (*sg_platf_process_cb_t)(sg_platf_process_cbarg_t);
387 XBT_PUBLIC(void) sg_platf_process_add_cb(sg_platf_process_cb_t fct);
393 #endif /* SG_PLATF_H */