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. */
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;
19 XBT_PUBLIC(sg_routing_edge_t) sg_routing_edge_by_name_or_null(const char *name);
21 /** @ingroup SURF_interface
22 * @brief Defines whether a given resource is working or not */
24 SURF_RESOURCE_ON = 1, /**< Up & ready */
25 SURF_RESOURCE_OFF = 0 /**< Down & broken */
26 } e_surf_resource_state_t;
29 SURF_LINK_FULLDUPLEX = 2,
32 } e_surf_link_sharing_policy_t;
35 SURF_TRACE_CONNECT_KIND_HOST_AVAIL = 4,
36 SURF_TRACE_CONNECT_KIND_POWER = 3,
37 SURF_TRACE_CONNECT_KIND_LINK_AVAIL = 2,
38 SURF_TRACE_CONNECT_KIND_BANDWIDTH = 1,
39 SURF_TRACE_CONNECT_KIND_LATENCY = 0
40 } e_surf_trace_connect_kind_t;
43 SURF_PROCESS_ON_FAILURE_DIE = 1,
44 SURF_PROCESS_ON_FAILURE_RESTART = 0
45 } e_surf_process_on_failure_t;
48 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
50 /** opaque structure defining a event generator for availability based on a probability distribution */
51 typedef struct probabilist_event_generator *probabilist_event_generator_t;
53 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename);
54 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
58 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_value(const char *id,
59 probabilist_event_generator_t date_generator,
60 probabilist_event_generator_t value_generator);
61 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_state(const char *id,
62 probabilist_event_generator_t date_generator,
63 e_surf_resource_state_t first_event_value);
64 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_avail_unavail(const char *id,
65 probabilist_event_generator_t avail_duration_generator,
66 probabilist_event_generator_t unavail_duration_generator,
67 e_surf_resource_state_t first_event_value);
69 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id,
72 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id,
74 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
78 typedef xbt_dictelm_t sg_host_t;
79 static inline char* sg_host_name(sg_host_t host) {
83 typedef xbt_dictelm_t sg_storage_t;
84 static inline char* sg_storage_name(sg_storage_t storage) {
87 /* Type for any simgrid size */
88 typedef unsigned long long sg_size_t;
91 * Platform creation functions. Instead of passing 123 arguments to the creation functions
92 * (one for each possible XML attribute), we pass structures containing them all. It removes the
93 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
94 * old models can just continue to ignore it without having to update their headers.
96 * It shouldn't be too costly at runtime, provided that structures living on the stack are
97 * used, instead of malloced structures.
102 xbt_dynar_t power_peak;
106 tmgr_trace_t power_trace;
107 e_surf_resource_state_t initial_state;
108 tmgr_trace_t state_trace;
110 xbt_dict_t properties;
111 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
113 #define SG_PLATF_HOST_INITIALIZER { \
118 .initial_state = SURF_RESOURCE_ON,\
119 .power_trace = NULL,\
120 .state_trace = NULL,\
128 const char* link_down;
129 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
131 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
136 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
138 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
143 tmgr_trace_t bandwidth_trace;
145 tmgr_trace_t latency_trace;
146 e_surf_resource_state_t state;
147 tmgr_trace_t state_trace;
148 e_surf_link_sharing_policy_t policy;
149 xbt_dict_t properties;
150 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
152 #define SG_PLATF_LINK_INITIALIZER {\
155 .bandwidth_trace = NULL,\
157 .latency_trace = NULL,\
158 .state = SURF_RESOURCE_ON,\
159 .state_trace = NULL,\
160 .policy = SURF_LINK_SHARED,\
164 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
165 typedef struct s_sg_platf_peer_cbarg {
172 tmgr_trace_t availability_trace;
173 tmgr_trace_t state_trace;
174 } s_sg_platf_peer_cbarg_t;
176 #define SG_PLATF_PEER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
178 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
179 typedef struct s_sg_platf_route_cbarg {
183 sg_routing_edge_t gw_src;
184 sg_routing_edge_t gw_dst;
185 xbt_dynar_t link_list;
186 } s_sg_platf_route_cbarg_t;
188 #define SG_PLATF_ROUTE_INITIALIZER {TRUE,NULL,NULL,NULL,NULL,NULL}
190 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
191 typedef struct s_sg_platf_cluster_cbarg {
205 xbt_dict_t properties;
206 const char* router_id;
207 e_surf_link_sharing_policy_t sharing_policy;
208 e_surf_link_sharing_policy_t bb_sharing_policy;
209 const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
210 const char* state_trace;
211 } s_sg_platf_cluster_cbarg_t;
213 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL \
214 ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
216 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
217 typedef struct s_sg_platf_cabinet_cbarg {
225 } s_sg_platf_cabinet_cbarg_t;
227 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL}
233 const char* content_type;
234 xbt_dict_t properties;
235 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
237 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL}
243 const char* content_type;
244 xbt_dict_t properties;
246 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
248 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL}
253 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
255 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
258 const char* storageId;
260 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
262 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
264 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
265 typedef struct s_sg_platf_prop_cbarg {
268 } s_sg_platf_prop_cbarg_t;
270 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
272 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
273 typedef struct s_sg_platf_trace_cbarg {
278 } s_sg_platf_trace_cbarg_t;
280 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,NULL,NULL}
282 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
283 typedef struct s_sg_platf_trace_connect_cbarg {
284 e_surf_trace_connect_kind_t kind;
287 } s_sg_platf_trace_connect_cbarg_t;
289 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {NULL,NULL,NULL}
291 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
292 typedef struct s_sg_platf_process_cbarg {
295 xbt_dict_t properties;
297 const char *function;
300 e_surf_process_on_failure_t on_failure;
301 } s_sg_platf_process_cbarg_t;
303 #define SG_PLATF_PROCESS_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
305 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
306 typedef struct s_sg_platf_AS_cbarg {
309 } s_sg_platf_AS_cbarg_t;
311 #define SG_PLATF_AS_INITIALIZER {NULL,0}
313 /* ***************************************** */
314 /* TUTORIAL: New TAG */
316 typedef struct s_sg_platf_gpu_cbarg *sg_platf_gpu_cbarg_t;
317 typedef struct s_sg_platf_gpu_cbarg {
319 } s_sg_platf_gpu_cbarg_t;
321 #define SG_PLATF_GPU_INITIALIZER {NULL}
323 /* ***************************************** */
325 XBT_PUBLIC(void) sg_platf_begin(void); // Start a new platform
326 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
328 XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
329 XBT_PUBLIC(void) sg_platf_new_AS_end(void); // That AS is fully described
331 XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an host to the currently described AS
332 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
333 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router to the currently described AS
334 XBT_PUBLIC(void) sg_platf_new_link (sg_platf_link_cbarg_t link); // Add a link to the currently described AS
335 XBT_PUBLIC(void) sg_platf_new_peer (sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS
336 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
337 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
339 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
340 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_route_cbarg_t ASroute); // Add an ASroute
341 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
342 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_route_cbarg_t bypassASroute); // Add an bypassASroute
343 XBT_PUBLIC(void) sg_platf_new_prop (sg_platf_prop_cbarg_t prop); // Add a prop
345 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
346 XBT_PUBLIC(void) sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
348 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
349 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
350 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
351 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
352 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
354 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
356 /* ***************************************** */
357 /* TUTORIAL: New TAG */
358 XBT_PUBLIC(void) sg_platf_new_gpu(sg_platf_gpu_cbarg_t gpu);
359 /* ***************************************** */
361 // Add route and Asroute without xml file with those functions
362 XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route
363 XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route
365 XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute); // Initialize ASroute
366 XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute); // Finalize and add a ASroute
368 XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list
369 XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute); // Add a link to link list
371 typedef void (*sg_platf_process_cb_t)(sg_platf_process_cbarg_t);
372 XBT_PUBLIC(void) sg_platf_process_add_cb(sg_platf_process_cb_t fct);
376 #endif /* SG_PLATF_H */