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 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
47 /** opaque structure defining a event generator for availability based on a probability distribution */
48 typedef struct probabilist_event_generator *probabilist_event_generator_t;
50 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename);
51 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
55 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_value(const char *id,
56 probabilist_event_generator_t date_generator,
57 probabilist_event_generator_t value_generator);
58 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_state(const char *id,
59 probabilist_event_generator_t date_generator,
60 e_surf_resource_state_t first_event_value);
61 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_avail_unavail(const char *id,
62 probabilist_event_generator_t avail_duration_generator,
63 probabilist_event_generator_t unavail_duration_generator,
64 e_surf_resource_state_t first_event_value);
66 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id,
69 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id,
71 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
74 typedef xbt_dictelm_t sg_host_t;
75 static inline char* sg_host_name(sg_host_t host) {
79 typedef xbt_dictelm_t sg_storage_t;
80 static inline char* sg_storage_name(sg_storage_t storage) {
85 * Platform creation functions. Instead of passing 123 arguments to the creation functions
86 * (one for each possible XML attribute), we pass structures containing them all. It removes the
87 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
88 * old models can just continue to ignore it without having to update their headers.
90 * It shouldn't be too costly at runtime, provided that structures living on the stack are
91 * used, instead of malloced structures.
96 xbt_dynar_t power_peak;
100 tmgr_trace_t power_trace;
101 e_surf_resource_state_t initial_state;
102 tmgr_trace_t state_trace;
104 xbt_dict_t properties;
105 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
107 #define SG_PLATF_HOST_INITIALIZER { \
112 .initial_state = SURF_RESOURCE_ON,\
113 .power_trace = NULL,\
114 .state_trace = NULL,\
122 const char* link_down;
123 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
125 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
130 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
132 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
137 tmgr_trace_t bandwidth_trace;
139 tmgr_trace_t latency_trace;
140 e_surf_resource_state_t state;
141 tmgr_trace_t state_trace;
142 e_surf_link_sharing_policy_t policy;
143 xbt_dict_t properties;
144 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
146 #define SG_PLATF_LINK_INITIALIZER {\
149 .bandwidth_trace = NULL,\
151 .latency_trace = NULL,\
152 .state = SURF_RESOURCE_ON,\
153 .state_trace = NULL,\
154 .policy = SURF_LINK_SHARED,\
158 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
159 typedef struct s_sg_platf_peer_cbarg {
166 tmgr_trace_t availability_trace;
167 tmgr_trace_t state_trace;
168 } s_sg_platf_peer_cbarg_t;
170 #define SG_PLATF_PEER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
172 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
173 typedef struct s_sg_platf_route_cbarg {
177 sg_routing_edge_t gw_src;
178 sg_routing_edge_t gw_dst;
179 xbt_dynar_t link_list;
180 } s_sg_platf_route_cbarg_t;
182 #define SG_PLATF_ROUTE_INITIALIZER {TRUE,NULL,NULL,NULL,NULL,NULL}
184 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
185 typedef struct s_sg_platf_cluster_cbarg {
199 xbt_dict_t properties;
200 const char* router_id;
201 e_surf_link_sharing_policy_t sharing_policy;
202 e_surf_link_sharing_policy_t bb_sharing_policy;
203 const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
204 const char* state_trace;
205 } s_sg_platf_cluster_cbarg_t;
207 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL \
208 ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
210 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
211 typedef struct s_sg_platf_cabinet_cbarg {
219 } s_sg_platf_cabinet_cbarg_t;
221 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL}
227 const char* content_type;
228 xbt_dict_t properties;
229 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
231 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL}
237 const char* content_type;
238 xbt_dict_t properties;
240 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
242 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL}
247 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
249 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
252 const char* storageId;
254 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
256 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
258 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
259 typedef struct s_sg_platf_prop_cbarg {
262 } s_sg_platf_prop_cbarg_t;
264 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
266 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
267 typedef struct s_sg_platf_trace_cbarg {
272 } s_sg_platf_trace_cbarg_t;
274 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,NULL,NULL}
276 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
277 typedef struct s_sg_platf_trace_connect_cbarg {
278 e_surf_trace_connect_kind_t kind;
281 } s_sg_platf_trace_connect_cbarg_t;
283 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {NULL,NULL,NULL}
285 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
286 typedef struct s_sg_platf_process_cbarg {
289 xbt_dict_t properties;
291 const char *function;
294 e_surf_process_on_failure_t on_failure;
295 } s_sg_platf_process_cbarg_t;
297 #define SG_PLATF_PROCESS_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
299 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
300 typedef struct s_sg_platf_AS_cbarg {
303 } s_sg_platf_AS_cbarg_t;
305 #define SG_PLATF_AS_INITIALIZER {NULL,0}
307 /* ***************************************** */
308 /* TUTORIAL: New TAG */
310 typedef struct s_sg_platf_gpu_cbarg *sg_platf_gpu_cbarg_t;
311 typedef struct s_sg_platf_gpu_cbarg {
313 } s_sg_platf_gpu_cbarg_t;
315 #define SG_PLATF_GPU_INITIALIZER {NULL}
317 /* ***************************************** */
319 XBT_PUBLIC(void) sg_platf_begin(void); // Start a new platform
320 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
322 XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
323 XBT_PUBLIC(void) sg_platf_new_AS_end(void); // That AS is fully described
325 XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an host to the currently described AS
326 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
327 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router to the currently described AS
328 XBT_PUBLIC(void) sg_platf_new_link (sg_platf_link_cbarg_t link); // Add a link to the currently described AS
329 XBT_PUBLIC(void) sg_platf_new_peer (sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS
330 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
331 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
333 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
334 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_route_cbarg_t ASroute); // Add an ASroute
335 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
336 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_route_cbarg_t bypassASroute); // Add an bypassASroute
337 XBT_PUBLIC(void) sg_platf_new_prop (sg_platf_prop_cbarg_t prop); // Add a prop
339 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
340 XBT_PUBLIC(void) sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
342 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
343 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
344 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
345 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
346 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
348 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
350 /* ***************************************** */
351 /* TUTORIAL: New TAG */
352 XBT_PUBLIC(void) sg_platf_new_gpu(sg_platf_gpu_cbarg_t gpu);
353 /* ***************************************** */
355 // Add route and Asroute without xml file with those functions
356 XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route
357 XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route
359 XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute); // Initialize ASroute
360 XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute); // Finalize and add a ASroute
362 XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list
363 XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute); // Add a link to link list
365 typedef void (*sg_platf_process_cb_t)(sg_platf_process_cbarg_t);
366 XBT_PUBLIC(void) sg_platf_process_add_cb(sg_platf_process_cb_t fct);
369 #endif /* SG_PLATF_H */