1 /* platf.h - Public interface to the SimGrid platforms */
3 /* Copyright (c) 2004-2015. 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 #include <simgrid/host.h>
18 static inline char* sg_storage_name(sg_storage_t storage) {
22 XBT_PUBLIC(sg_netcard_t) sg_netcard_by_name_or_null(const char *name);
24 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename);
25 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
29 SURF_CLUSTER_FAT_TREE=2,
30 SURF_CLUSTER_FLAT = 1,
31 SURF_CLUSTER_TORUS = 0
32 } e_surf_cluster_topology_t;
35 typedef struct s_model_type {
39 } s_routing_model_description_t, *routing_model_description_t;
41 /* ***************************************** */
43 * Platform creation functions. Instead of passing 123 arguments to the creation functions
44 * (one for each possible XML attribute), we pass structures containing them all. It removes the
45 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
46 * old models can just continue to ignore it without having to update their headers.
48 * It shouldn't be too costly at runtime, provided that structures living on the stack are
49 * used, instead of malloced structures.
54 xbt_dynar_t speed_peak;
58 tmgr_trace_t speed_trace;
60 tmgr_trace_t state_trace;
62 xbt_dict_t properties;
63 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
65 #define SG_PLATF_HOST_INITIALIZER { \
66 NULL, 0, 1, 1, 1., NULL, 1/*ON*/, NULL, \
73 const char* link_down;
74 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
76 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
81 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
83 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
88 tmgr_trace_t bandwidth_trace;
90 tmgr_trace_t latency_trace;
92 tmgr_trace_t state_trace;
93 e_surf_link_sharing_policy_t policy;
94 xbt_dict_t properties;
95 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
97 #define SG_PLATF_LINK_INITIALIZER {\
98 NULL, 0., NULL, 0., NULL, 1/*ON*/, \
99 NULL, SURF_LINK_SHARED, NULL \
102 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
103 typedef struct s_sg_platf_peer_cbarg {
110 tmgr_trace_t availability_trace;
111 tmgr_trace_t state_trace;
112 } s_sg_platf_peer_cbarg_t;
114 #define SG_PLATF_PEER_INITIALIZER {NULL,0.0,0.0,0.0,0.0,NULL,NULL,NULL}
116 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
117 typedef struct s_sg_platf_route_cbarg {
123 xbt_dynar_t link_list;
124 } s_sg_platf_route_cbarg_t;
126 #define SG_PLATF_ROUTE_INITIALIZER {1,NULL,NULL,NULL,NULL,NULL}
128 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
129 typedef struct s_sg_platf_cluster_cbarg {
143 e_surf_cluster_topology_t topology;
144 const char* topo_parameters;
145 xbt_dict_t properties;
146 const char* router_id;
147 e_surf_link_sharing_policy_t sharing_policy;
148 e_surf_link_sharing_policy_t bb_sharing_policy;
149 const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
150 const char* state_trace;
151 } s_sg_platf_cluster_cbarg_t;
153 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,0.0,1 \
154 ,1.,1.,0.,0.,0.,0.,0. \
155 ,SURF_CLUSTER_FLAT,NULL,NULL,NULL, \
156 SURF_LINK_SHARED,SURF_LINK_SHARED,NULL \
159 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
160 typedef struct s_sg_platf_cabinet_cbarg {
168 } s_sg_platf_cabinet_cbarg_t;
170 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,0.0,0.0,0.0}
176 const char* content_type;
177 xbt_dict_t properties;
179 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
181 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL}
187 const char* content_type;
188 xbt_dict_t properties;
189 xbt_dict_t model_properties;
191 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
193 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,0}
198 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
200 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
203 const char* storageId;
205 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
207 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
209 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
210 typedef struct s_sg_platf_prop_cbarg {
213 } s_sg_platf_prop_cbarg_t;
215 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
217 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
218 typedef struct s_sg_platf_trace_cbarg {
223 } s_sg_platf_trace_cbarg_t;
225 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,0.0,NULL}
227 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
228 typedef struct s_sg_platf_trace_connect_cbarg {
229 e_surf_trace_connect_kind_t kind;
232 } s_sg_platf_trace_connect_cbarg_t;
234 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {SURF_TRACE_CONNECT_KIND_LATENCY,NULL,NULL}
236 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
237 typedef struct s_sg_platf_process_cbarg {
240 xbt_dict_t properties;
242 const char *function;
245 e_surf_process_on_failure_t on_failure;
246 } s_sg_platf_process_cbarg_t;
248 #define SG_PLATF_PROCESS_INITIALIZER {NULL,0,NULL,NULL,NULL,-1.0,-1.0,SURF_PROCESS_ON_FAILURE_DIE}
250 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
251 typedef struct s_sg_platf_AS_cbarg {
254 } s_sg_platf_AS_cbarg_t;
256 #define SG_PLATF_AS_INITIALIZER {NULL,0}
258 /** opaque structure defining a event generator for availability based on a probability distribution */
259 typedef struct probabilist_event_generator *probabilist_event_generator_t;
261 /*** END of the parsing cruft ***/
263 XBT_PUBLIC(void) sg_platf_begin(void); // Start a new platform
264 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
266 XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
267 XBT_PUBLIC(void) sg_platf_new_AS_end(void); // That AS is fully described
269 XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an host to the currently described AS
270 XBT_PUBLIC(void) sg_platf_new_netcard(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
271 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router to the currently described AS
272 XBT_PUBLIC(void) sg_platf_new_link (sg_platf_link_cbarg_t link); // Add a link to the currently described AS
273 XBT_PUBLIC(void) sg_platf_new_peer (sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS
274 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
275 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
277 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
278 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_route_cbarg_t ASroute); // Add an ASroute
279 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
280 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_route_cbarg_t bypassASroute); // Add an bypassASroute
282 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
284 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
285 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
286 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
287 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
289 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
291 // Add route and Asroute without xml file with those functions
292 XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route
293 XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route
295 XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute); // Initialize ASroute
296 XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute); // Finalize and add a ASroute
298 XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list
299 XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute); // Add a link to link list
303 #endif /* SG_PLATF_H */