Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Event trace generation: Change interface of constructors
[simgrid.git] / include / simgrid / platf.h
1 /* platf.h - Public interface to the SimGrid platforms                      */
2
3 /* Copyright (c) 2004-2012. The SimGrid Team. All rights reserved.          */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #ifndef SG_PLATF_H
9 #define SG_PLATF_H
10
11 #include <xbt.h>
12
13 typedef void *sg_routing_link_t; /* The actual type is model-dependent so use void* instead*/
14 typedef struct s_routing_edge *sg_routing_edge_t;
15
16 XBT_PUBLIC(sg_routing_edge_t) sg_routing_edge_by_name_or_null(const char *name);
17
18 /** Defines whether a given resource is working or not */
19 typedef enum {
20   SURF_RESOURCE_ON = 1,                   /**< Up & ready        */
21   SURF_RESOURCE_OFF = 0                   /**< Down & broken     */
22 } e_surf_resource_state_t;
23
24 typedef enum {
25   SURF_LINK_FULLDUPLEX = 2,
26   SURF_LINK_SHARED = 1,
27   SURF_LINK_FATPIPE = 0
28 } e_surf_link_sharing_policy_t;
29
30 typedef enum {
31   SURF_TRACE_CONNECT_KIND_HOST_AVAIL = 4,
32   SURF_TRACE_CONNECT_KIND_POWER = 3,
33   SURF_TRACE_CONNECT_KIND_LINK_AVAIL = 2,
34   SURF_TRACE_CONNECT_KIND_BANDWIDTH = 1,
35   SURF_TRACE_CONNECT_KIND_LATENCY = 0
36 } e_surf_trace_connect_kin_t;
37
38 typedef enum {
39   SURF_PROCESS_ON_FAILURE_DIE = 1,
40   SURF_PROCESS_ON_FAILURE_RESTART = 0
41 } e_surf_process_on_failure_t;
42
43
44 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
45
46 /** opaque structure defining a event generator for availability based on a probability distribution */
47 typedef struct probabilist_event_generator *probabilist_event_generator_t;
48
49 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename);
50 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
51                                                     const char *input,
52                                                     double periodicity);
53
54 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_value(const char *id,
55                                               probabilist_event_generator_t date_generator,
56                                               probabilist_event_generator_t value_generator);
57 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_state(const char *id,
58                                               probabilist_event_generator_t date_generator,
59                                               e_surf_resource_state_t first_event_value);
60 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_avail_unavail(const char *id,
61                                               probabilist_event_generator_t avail_duration_generator,
62                                               probabilist_event_generator_t unavail_duration_generator,
63                                               e_surf_resource_state_t first_event_value);
64
65 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id,
66                                                                            double min,
67                                                                            double max);
68 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id,
69                                                                            double rate);
70 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
71                                                                            double scale,
72                                                                            double shape);
73
74 /*
75  * Platform creation functions. Instead of passing 123 arguments to the creation functions
76  * (one for each possible XML attribute), we pass structures containing them all. It removes the
77  * chances of switching arguments by error, and reduce the burden when we add a new attribute:
78  * old models can just continue to ignore it without having to update their headers.
79  *
80  * It shouldn't be too costly at runtime, provided that structures living on the stack are
81  * used, instead of malloced structures.
82  */
83
84 typedef struct {
85   const char* id;
86   double power_peak;
87   int core_amount;
88   double power_scale;
89   tmgr_trace_t power_trace;
90   e_surf_resource_state_t initial_state;
91   tmgr_trace_t state_trace;
92   const char* coord;
93   xbt_dict_t properties;
94 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
95
96 typedef struct {
97   const char* id;
98   const char* link_up;
99   const char* link_down;
100 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
101
102
103 typedef struct {
104   const char* id;
105   const char* coord;
106 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
107
108 typedef struct {
109   const char* id;
110   double bandwidth;
111   tmgr_trace_t bandwidth_trace;
112   double latency;
113   tmgr_trace_t latency_trace;
114   e_surf_resource_state_t state;
115   tmgr_trace_t state_trace;
116   e_surf_link_sharing_policy_t policy;
117   xbt_dict_t properties;
118 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
119
120 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
121 typedef struct s_sg_platf_peer_cbarg {
122   const char* id;
123   double power;
124   double bw_in;
125   double bw_out;
126   double lat;
127   const char* coord;
128   tmgr_trace_t availability_trace;
129   tmgr_trace_t state_trace;
130 } s_sg_platf_peer_cbarg_t;
131
132 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
133 typedef struct s_sg_platf_route_cbarg {
134   int symmetrical;
135   const char *src;
136   const char *dst;
137   sg_routing_edge_t gw_src;
138   sg_routing_edge_t gw_dst;
139   xbt_dynar_t link_list;
140 } s_sg_platf_route_cbarg_t;
141
142 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
143 typedef struct s_sg_platf_cluster_cbarg {
144   const char* id;
145   const char* prefix;
146   const char* suffix;
147   const char* radical;
148   double power;
149   int core_amount;
150   double bw;
151   double lat;
152   double bb_bw;
153   double bb_lat;
154   const char* router_id;
155   e_surf_link_sharing_policy_t sharing_policy;
156   e_surf_link_sharing_policy_t bb_sharing_policy;
157   const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
158   const char* state_trace;
159 } s_sg_platf_cluster_cbarg_t;
160
161 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
162 typedef struct s_sg_platf_cabinet_cbarg {
163   const char* id;
164   const char* prefix;
165   const char* suffix;
166   const char* radical;
167   double power;
168   double bw;
169   double lat;
170 } s_sg_platf_cabinet_cbarg_t;
171
172 typedef struct {
173   const char* id;
174   const char* type_id;
175   const char* content;
176 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
177
178 typedef struct {
179   const char* id;
180   const char* model;
181   const char* content;
182   xbt_dict_t properties;
183   unsigned long size; /* size in Gbytes */
184 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
185
186 typedef struct {
187   const char* type_id;
188   const char* name;
189 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
190
191 typedef struct {
192   const char* id;
193   const char* name;
194 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
195
196 typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
197 typedef struct s_sg_platf_prop_cbarg {
198   const char *id;
199   const char *value;
200 } s_sg_platf_prop_cbarg_t;
201
202 typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
203 typedef struct s_sg_platf_trace_cbarg {
204   const char *id;
205   const char *file;
206   double periodicity;
207   const char *pc_data;
208 } s_sg_platf_trace_cbarg_t;
209
210 typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
211 typedef struct s_sg_platf_trace_connect_cbarg {
212   e_surf_trace_connect_kin_t kind;
213   const char *trace;
214   const char *element;
215 } s_sg_platf_trace_connect_cbarg_t;
216
217 typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
218 typedef struct s_sg_platf_process_cbarg {
219   const char **argv;
220   int argc;
221   xbt_dict_t properties;
222   const char *host;
223   const char *function;
224   double start_time;
225   double kill_time;
226   e_surf_process_on_failure_t on_failure;
227 } s_sg_platf_process_cbarg_t;
228
229 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
230 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
231
232 XBT_PUBLIC(void) sg_platf_new_AS_begin(const char *id, int mode); // Begin description of new AS
233 XBT_PUBLIC(void) sg_platf_new_AS_end(void);                            // That AS is fully described
234
235 XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
236 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
237 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
238 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
239 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
240 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
241 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
242
243 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
244 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_route_cbarg_t ASroute); // Add an ASroute
245 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
246 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_route_cbarg_t bypassASroute); // Add an bypassASroute
247 XBT_PUBLIC(void) sg_platf_new_prop (sg_platf_prop_cbarg_t prop); // Add a prop
248
249 XBT_PUBLIC(void) sg_platf_new_trace(sg_platf_trace_cbarg_t trace);
250 XBT_PUBLIC(void) sg_platf_new_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect);
251
252 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
253 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
254 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
255 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
256 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
257
258 XBT_PUBLIC(void) sg_platf_new_process(sg_platf_process_cbarg_t process);
259
260 // Add route and Asroute without xml file with those functions
261 XBT_PUBLIC(void) sg_platf_route_begin (sg_platf_route_cbarg_t route); // Initialize route
262 XBT_PUBLIC(void) sg_platf_route_end (sg_platf_route_cbarg_t route); // Finalize and add a route
263
264 XBT_PUBLIC(void) sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute); // Initialize ASroute
265 XBT_PUBLIC(void) sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute); // Finalize and add a ASroute
266
267 XBT_PUBLIC(void) sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route); // Add a link to link list
268 XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute); // Add a link to link list
269
270 #endif                          /* SG_PLATF_H */