Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
5f2d8b8ddb70971c929274e0a67bf4c8a88c9d30
[simgrid.git] / include / simgrid / platf.h
1 /* platf.h - Public interface to the SimGrid platforms                      */
2
3 /* Copyright (c) 2004-2015. The SimGrid Team.
4  * All rights reserved.                                                     */
5
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. */
8
9 #ifndef SG_PLATF_H
10 #define SG_PLATF_H
11
12 #include <xbt.h>
13 #include <simgrid/host.h>
14 #include "forward.h"
15
16 SG_BEGIN_DECL()
17
18 static inline char* sg_storage_name(sg_storage_t storage) {
19   return storage->key;
20 }
21
22 XBT_PUBLIC(sg_netcard_t) sg_netcard_by_name_or_null(const char *name);
23
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,
26                                                     const char *input,
27                                                     double periodicity);
28 typedef enum {
29   SURF_CLUSTER_FAT_TREE=2,
30   SURF_CLUSTER_FLAT = 1,
31   SURF_CLUSTER_TORUS = 0
32 } e_surf_cluster_topology_t;
33
34
35 typedef struct s_model_type {
36   const char *name;
37   const char *desc;
38   AS_t (*create) ();
39 } s_routing_model_description_t, *routing_model_description_t;
40
41 /* ***************************************** */
42 /*
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.
47  *
48  * It shouldn't be too costly at runtime, provided that structures living on the stack are
49  * used, instead of malloced structures.
50  */
51
52 typedef struct {
53   const char* id;
54   xbt_dynar_t speed_peak;
55   int pstate;
56   int core_amount;
57   double speed_scale;
58   tmgr_trace_t speed_trace;
59   int initiallyOn;
60   tmgr_trace_t state_trace;
61   const char* coord;
62   xbt_dict_t properties;
63 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
64
65 #define SG_PLATF_HOST_INITIALIZER { \
66     NULL, 0, 1, 1, 1., NULL, 1/*ON*/, NULL, \
67     NULL, NULL \
68 }
69
70 typedef struct {
71   const char* id;
72   const char* link_up;
73   const char* link_down;
74 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
75
76 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
77
78 typedef struct {
79   const char* id;
80   const char* coord;
81 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
82
83 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
84
85 typedef struct {
86   const char* id;
87   double bandwidth;
88   tmgr_trace_t bandwidth_trace;
89   double latency;
90   tmgr_trace_t latency_trace;
91   int initiallyOn;
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;
96
97 #define SG_PLATF_LINK_INITIALIZER {\
98   NULL, 0., NULL, 0., NULL, 1/*ON*/, \
99   NULL, SURF_LINK_SHARED, NULL \
100 }
101
102 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
103 typedef struct s_sg_platf_peer_cbarg {
104   const char* id;
105   double speed;
106   double bw_in;
107   double bw_out;
108   double lat;
109   const char* coord;
110   tmgr_trace_t availability_trace;
111   tmgr_trace_t state_trace;
112 } s_sg_platf_peer_cbarg_t;
113
114 #define SG_PLATF_PEER_INITIALIZER {NULL,0.0,0.0,0.0,0.0,NULL,NULL,NULL}
115
116 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
117 typedef struct s_sg_platf_route_cbarg {
118   int symmetrical;
119   const char *src;
120   const char *dst;
121   sg_netcard_t gw_src;
122   sg_netcard_t gw_dst;
123   xbt_dynar_t link_list;
124 } s_sg_platf_route_cbarg_t;
125
126 #define SG_PLATF_ROUTE_INITIALIZER {1,NULL,NULL,NULL,NULL,NULL}
127
128 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
129 typedef struct s_sg_platf_cluster_cbarg {
130   const char* id;
131   const char* prefix;
132   const char* suffix;
133   const char* radical;
134   double speed;
135   int core_amount;
136   double bw;
137   double lat;
138   double bb_bw;
139   double bb_lat;
140   double loopback_bw;
141   double loopback_lat;
142   double limiter_link;
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;
152
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 \
157   ,NULL}
158
159 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
160 typedef struct s_sg_platf_cabinet_cbarg {
161   const char* id;
162   const char* prefix;
163   const char* suffix;
164   const char* radical;
165   double speed;
166   double bw;
167   double lat;
168 } s_sg_platf_cabinet_cbarg_t;
169
170 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,0.0,0.0,0.0}
171
172 typedef struct {
173   const char* id;
174   const char* type_id;
175   const char* content;
176   const char* content_type;
177   xbt_dict_t properties;
178   const char* attach;
179 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
180
181 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL}
182
183 typedef struct {
184   const char* id;
185   const char* model;
186   const char* content;
187   const char* content_type;
188   xbt_dict_t properties;
189   xbt_dict_t model_properties;
190   sg_size_t size;
191 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
192
193 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,0}
194
195 typedef struct {
196   const char* type_id;
197   const char* name;
198 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
199
200 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
201
202 typedef struct {
203   const char* storageId;
204   const char* name;
205 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
206
207 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
208
209 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
210 typedef struct s_sg_platf_prop_cbarg {
211   const char *id;
212   const char *value;
213 } s_sg_platf_prop_cbarg_t;
214
215 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
216
217 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
218 typedef struct s_sg_platf_trace_cbarg {
219   const char *id;
220   const char *file;
221   double periodicity;
222   const char *pc_data;
223 } s_sg_platf_trace_cbarg_t;
224
225 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,0.0,NULL}
226
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;
230   const char *trace;
231   const char *element;
232 } s_sg_platf_trace_connect_cbarg_t;
233
234 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {SURF_TRACE_CONNECT_KIND_LATENCY,NULL,NULL}
235
236 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
237 typedef struct s_sg_platf_process_cbarg {
238   const char **argv;
239   int argc;
240   xbt_dict_t properties;
241   const char *host;
242   const char *function;
243   double start_time;
244   double kill_time;
245   e_surf_process_on_failure_t on_failure;
246 } s_sg_platf_process_cbarg_t;
247
248 #define SG_PLATF_PROCESS_INITIALIZER {NULL,0,NULL,NULL,NULL,-1.0,-1.0,SURF_PROCESS_ON_FAILURE_DIE}
249
250 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
251 typedef struct s_sg_platf_AS_cbarg {
252   const char *id;
253   int routing;
254 } s_sg_platf_AS_cbarg_t;
255
256 #define SG_PLATF_AS_INITIALIZER {NULL,0}
257
258 /** opaque structure defining a event generator for availability based on a probability distribution */
259 typedef struct probabilist_event_generator *probabilist_event_generator_t;
260
261 /*** END of the parsing cruft ***/
262
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
265
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
268
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
276
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
281
282 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
283
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);
288
289 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
290
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
294
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
297
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
300
301 SG_END_DECL()
302
303 #endif                          /* SG_PLATF_H */