Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The code deal with <ASroute> in the exact same way than <route>. Disturbing
[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 /*
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.
40  *
41  * It shouldn't be too costly at runtime, provided that structures living on the stack are
42  * used, instead of malloced structures.
43  */
44
45 typedef struct {
46   const char* id;
47   xbt_dynar_t speed_peak;
48   int pstate;
49   int core_amount;
50   double speed_scale;
51   tmgr_trace_t speed_trace;
52   int initiallyOn;
53   tmgr_trace_t state_trace;
54   const char* coord;
55   xbt_dict_t properties;
56 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
57
58 #define SG_PLATF_HOST_INITIALIZER { \
59     NULL, 0, 1, 1, 1., NULL, 1/*ON*/, NULL, \
60     NULL, NULL \
61 }
62
63 typedef struct {
64   const char* id;
65   const char* link_up;
66   const char* link_down;
67 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
68
69 #define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
70
71 typedef struct {
72   const char* id;
73   const char* coord;
74 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
75
76 #define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
77
78 typedef struct {
79   const char* id;
80   double bandwidth;
81   tmgr_trace_t bandwidth_trace;
82   double latency;
83   tmgr_trace_t latency_trace;
84   int initiallyOn;
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;
89
90 #define SG_PLATF_LINK_INITIALIZER {\
91   NULL, 0., NULL, 0., NULL, 1/*ON*/, \
92   NULL, SURF_LINK_SHARED, NULL \
93 }
94
95 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
96 typedef struct s_sg_platf_peer_cbarg {
97   const char* id;
98   double speed;
99   double bw_in;
100   double bw_out;
101   double lat;
102   const char* coord;
103   tmgr_trace_t availability_trace;
104   tmgr_trace_t state_trace;
105 } s_sg_platf_peer_cbarg_t;
106
107 #define SG_PLATF_PEER_INITIALIZER {NULL,0.0,0.0,0.0,0.0,NULL,NULL,NULL}
108
109 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
110 typedef struct s_sg_platf_route_cbarg {
111   int symmetrical;
112   const char *src;
113   const char *dst;
114   sg_netcard_t gw_src;
115   sg_netcard_t gw_dst;
116   xbt_dynar_t link_list;
117 } s_sg_platf_route_cbarg_t;
118
119 #define SG_PLATF_ROUTE_INITIALIZER {1,NULL,NULL,NULL,NULL,NULL}
120
121 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
122 typedef struct s_sg_platf_cluster_cbarg {
123   const char* id;
124   const char* prefix;
125   const char* suffix;
126   const char* radical;
127   double speed;
128   int core_amount;
129   double bw;
130   double lat;
131   double bb_bw;
132   double bb_lat;
133   double loopback_bw;
134   double loopback_lat;
135   double limiter_link;
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;
145
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 \
150   ,NULL}
151
152 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
153 typedef struct s_sg_platf_cabinet_cbarg {
154   const char* id;
155   const char* prefix;
156   const char* suffix;
157   const char* radical;
158   double speed;
159   double bw;
160   double lat;
161 } s_sg_platf_cabinet_cbarg_t;
162
163 #define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,0.0,0.0,0.0}
164
165 typedef struct {
166   const char* id;
167   const char* type_id;
168   const char* content;
169   const char* content_type;
170   xbt_dict_t properties;
171   const char* attach;
172 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
173
174 #define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL}
175
176 typedef struct {
177   const char* id;
178   const char* model;
179   const char* content;
180   const char* content_type;
181   xbt_dict_t properties;
182   xbt_dict_t model_properties;
183   sg_size_t size;
184 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
185
186 #define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,0}
187
188 typedef struct {
189   const char* type_id;
190   const char* name;
191 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
192
193 #define SG_PLATF_MSTORAGE_INITIALIZER {NULL,NULL}
194
195 typedef struct {
196   const char* storageId;
197   const char* name;
198 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
199
200 #define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
201
202 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
203 typedef struct s_sg_platf_prop_cbarg {
204   const char *id;
205   const char *value;
206 } s_sg_platf_prop_cbarg_t;
207
208 #define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
209
210 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
211 typedef struct s_sg_platf_trace_cbarg {
212   const char *id;
213   const char *file;
214   double periodicity;
215   const char *pc_data;
216 } s_sg_platf_trace_cbarg_t;
217
218 #define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,0.0,NULL}
219
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;
223   const char *trace;
224   const char *element;
225 } s_sg_platf_trace_connect_cbarg_t;
226
227 #define SG_PLATF_TRACE_CONNECT_INITIALIZER {SURF_TRACE_CONNECT_KIND_LATENCY,NULL,NULL}
228
229 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
230 typedef struct s_sg_platf_process_cbarg {
231   const char **argv;
232   int argc;
233   xbt_dict_t properties;
234   const char *host;
235   const char *function;
236   double start_time;
237   double kill_time;
238   e_surf_process_on_failure_t on_failure;
239 } s_sg_platf_process_cbarg_t;
240
241 #define SG_PLATF_PROCESS_INITIALIZER {NULL,0,NULL,NULL,NULL,-1.0,-1.0,SURF_PROCESS_ON_FAILURE_DIE}
242
243 typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
244 typedef struct s_sg_platf_AS_cbarg {
245   const char *id;
246   int routing;
247 } s_sg_platf_AS_cbarg_t;
248
249 #define SG_PLATF_AS_INITIALIZER {NULL,0}
250
251 /** opaque structure defining a event generator for availability based on a probability distribution */
252 typedef struct probabilist_event_generator *probabilist_event_generator_t;
253
254 /*** END of the parsing cruft ***/
255
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
258
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
261
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
269
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
272
273 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
274
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);
279
280 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
281
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
285
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
288
289 SG_END_DECL()
290
291 #endif                          /* SG_PLATF_H */