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;
34 /* ***************************************** */
36 * Platform creation functions. Instead of passing 123 arguments to the creation functions
37 * (one for each possible XML attribute), we pass structures containing them all. It removes the
38 * chances of switching arguments by error, and reduce the burden when we add a new attribute:
39 * old models can just continue to ignore it without having to update their headers.
41 * It shouldn't be too costly at runtime, provided that structures living on the stack are
42 * used, instead of malloced structures.
47 xbt_dynar_t speed_peak;
51 tmgr_trace_t speed_trace;
53 tmgr_trace_t state_trace;
55 xbt_dict_t properties;
56 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
58 #define SG_PLATF_HOST_INITIALIZER { \
59 NULL, 0, 1, 1, 1., NULL, 1/*ON*/, NULL, \
66 const char* link_down;
67 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
69 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
74 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
76 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
81 tmgr_trace_t bandwidth_trace;
83 tmgr_trace_t latency_trace;
85 tmgr_trace_t state_trace;
86 e_surf_link_sharing_policy_t policy;
87 xbt_dict_t properties;
88 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
90 #define SG_PLATF_LINK_INITIALIZER {\
91 NULL, 0., NULL, 0., NULL, 1/*ON*/, \
92 NULL, SURF_LINK_SHARED, NULL \
95 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
96 typedef struct s_sg_platf_peer_cbarg {
103 tmgr_trace_t availability_trace;
104 tmgr_trace_t state_trace;
105 } s_sg_platf_peer_cbarg_t;
107 #define SG_PLATF_PEER_INITIALIZER {NULL,0.0,0.0,0.0,0.0,NULL,NULL,NULL}
109 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
110 typedef struct s_sg_platf_route_cbarg {
116 xbt_dynar_t link_list;
117 } s_sg_platf_route_cbarg_t;
119 #define SG_PLATF_ROUTE_INITIALIZER {1,NULL,NULL,NULL,NULL,NULL}
121 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
122 typedef struct s_sg_platf_cluster_cbarg {
136 e_surf_cluster_topology_t topology;
137 const char* topo_parameters;
138 xbt_dict_t properties;
139 const char* router_id;
140 e_surf_link_sharing_policy_t sharing_policy;
141 e_surf_link_sharing_policy_t bb_sharing_policy;
142 const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
143 const char* state_trace;
144 } s_sg_platf_cluster_cbarg_t;
146 #define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,0.0,1 \
147 ,1.,1.,0.,0.,0.,0.,0. \
148 ,SURF_CLUSTER_FLAT,NULL,NULL,NULL, \
149 SURF_LINK_SHARED,SURF_LINK_SHARED,NULL \
152 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
153 typedef struct s_sg_platf_cabinet_cbarg {
161 } s_sg_platf_cabinet_cbarg_t;
163 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,0.0,0.0,0.0}
169 const char* content_type;
170 xbt_dict_t properties;
172 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
174 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL}
180 const char* content_type;
181 xbt_dict_t properties;
182 xbt_dict_t model_properties;
184 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
186 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,0}
191 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
193 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
196 const char* storageId;
198 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
200 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
202 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
203 typedef struct s_sg_platf_prop_cbarg {
206 } s_sg_platf_prop_cbarg_t;
208 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
210 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
211 typedef struct s_sg_platf_trace_cbarg {
216 } s_sg_platf_trace_cbarg_t;
218 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,0.0,NULL}
220 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
221 typedef struct s_sg_platf_trace_connect_cbarg {
222 e_surf_trace_connect_kind_t kind;
225 } s_sg_platf_trace_connect_cbarg_t;
227 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {SURF_TRACE_CONNECT_KIND_LATENCY,NULL,NULL}
229 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
230 typedef struct s_sg_platf_process_cbarg {
233 xbt_dict_t properties;
235 const char *function;
238 e_surf_process_on_failure_t on_failure;
239 } s_sg_platf_process_cbarg_t;
241 #define SG_PLATF_PROCESS_INITIALIZER {NULL,0,NULL,NULL,NULL,-1.0,-1.0,SURF_PROCESS_ON_FAILURE_DIE}
243 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
244 typedef struct s_sg_platf_AS_cbarg {
247 } s_sg_platf_AS_cbarg_t;
249 #define SG_PLATF_AS_INITIALIZER {NULL,0}
251 /** opaque structure defining a event generator for availability based on a probability distribution */
252 typedef struct probabilist_event_generator *probabilist_event_generator_t;
254 /*** END of the parsing cruft ***/
256 XBT_PUBLIC(void) sg_platf_begin(void); // Start a new platform
257 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
259 XBT_PUBLIC(void) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
260 XBT_PUBLIC(void) sg_platf_new_AS_end(void); // That AS is fully described
262 XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an host to the currently described AS
263 XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
264 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router to the currently described AS
265 XBT_PUBLIC(void) sg_platf_new_link (sg_platf_link_cbarg_t link); // Add a link to the currently described AS
266 XBT_PUBLIC(void) sg_platf_new_peer (sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS
267 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
268 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
270 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
271 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
273 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
275 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
276 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
277 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
278 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
280 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
282 // Add route and Asroute without xml file with those functions
283 XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route
284 XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route
286 XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list
287 XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute); // Add a link to link list
291 #endif /* SG_PLATF_H */