Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
2359872f7af61042324e43c5f4ef3adb010528ac
[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
19
20 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
21
22 /** opaque structure defining a event generator for availability based on a probability distribution */
23 typedef struct probabilist_event_generator *probabilist_event_generator_t;
24
25 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename);
26 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id,
27                                                     const char *input,
28                                                     double periodicity);
29 XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_generator(const char *id,
30                                                   probabilist_event_generator_t generator1,
31                                                   probabilist_event_generator_t generator2,
32                                                   int is_state_trace);
33
34 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id,
35                                                                            double min,
36                                                                            double max);
37 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id,
38                                                                            double rate);
39 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
40                                                                            double scale,
41                                                                            double shape);
42
43 /** Defines whether a given resource is working or not */
44 typedef enum {
45   SURF_RESOURCE_ON = 1,                   /**< Up & ready        */
46   SURF_RESOURCE_OFF = 0                   /**< Down & broken     */
47 } e_surf_resource_state_t;
48
49 typedef enum {
50   SURF_LINK_FULLDUPLEX = 2,
51   SURF_LINK_SHARED = 1,
52   SURF_LINK_FATPIPE = 0
53 } e_surf_link_sharing_policy_t;
54
55 typedef enum {
56   SURF_LINK_DIRECTION_NONE = 2,
57   SURF_LINK_DIRECTION_UP = 1,
58   SURF_LINK_DIRECTION_DOWN = 0
59 } e_surf_link_ctn_direction_t;
60
61 /*
62  * Platform creation functions. Instead of passing 123 arguments to the creation functions
63  * (one for each possible XML attribute), we pass structures containing them all. It removes the
64  * chances of switching arguments by error, and reduce the burden when we add a new attribute:
65  * old models can just continue to ignore it without having to update their headers.
66  *
67  * It shouldn't be too costly at runtime, provided that structures living on the stack are
68  * used, instead of malloced structures.
69  */
70
71 typedef struct {
72   const char* id;
73   double power_peak;
74   int core_amount;
75   double power_scale;
76   tmgr_trace_t power_trace;
77   e_surf_resource_state_t initial_state;
78   tmgr_trace_t state_trace;
79   const char* coord;
80   xbt_dict_t properties;
81 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
82
83 typedef struct {
84   const char* id;
85   const char* link_up;
86   const char* link_down;
87 } s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
88
89
90 typedef struct {
91   const char* id;
92   const char* coord;
93 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
94
95 typedef struct {
96   const char* id;
97   double bandwidth;
98   tmgr_trace_t bandwidth_trace;
99   double latency;
100   tmgr_trace_t latency_trace;
101   e_surf_resource_state_t state;
102   tmgr_trace_t state_trace;
103   e_surf_link_sharing_policy_t policy;
104   xbt_dict_t properties;
105 } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
106
107 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
108 typedef struct s_sg_platf_peer_cbarg {
109   const char* id;
110   double power;
111   double bw_in;
112   double bw_out;
113   double lat;
114   const char* coord;
115   tmgr_trace_t availability_trace;
116   tmgr_trace_t state_trace;
117 } s_sg_platf_peer_cbarg_t;
118
119 typedef struct s_sg_platf_linkctn_cbarg *sg_platf_linkctn_cbarg_t;
120 typedef struct s_sg_platf_linkctn_cbarg {
121   const char *id;
122   e_surf_link_ctn_direction_t direction;
123 } s_sg_platf_linkctn_cbarg_t;
124
125 typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
126 typedef struct s_sg_platf_route_cbarg {
127   int symmetrical;
128   const char *src;
129   const char *dst;
130 } s_sg_platf_route_cbarg_t;
131
132 typedef struct s_sg_platf_ASroute_cbarg *sg_platf_ASroute_cbarg_t;
133 typedef struct s_sg_platf_ASroute_cbarg {
134   int symmetrical;
135   const char *src;
136   const char *dst;
137   const char *gw_src;
138   const char *gw_dst;
139 } s_sg_platf_ASroute_cbarg_t;
140
141 typedef struct s_sg_platf_bypassRoute_cbarg *sg_platf_bypassRoute_cbarg_t;
142 typedef struct s_sg_platf_bypassRoute_cbarg {
143   const char *src;
144   const char *dst;
145 } s_sg_platf_bypassRoute_cbarg_t;
146
147 typedef struct s_sg_platf_bypassASroute_cbarg *sg_platf_bypassASroute_cbarg_t;
148 typedef struct s_sg_platf_bypassASroute_cbarg {
149   const char *src;
150   const char *dst;
151   const char *gw_src;
152   const char *gw_dst;
153 } s_sg_platf_bypassASroute_cbarg_t;
154
155 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
156 typedef struct s_sg_platf_cluster_cbarg {
157   const char* id;
158   const char* prefix;
159   const char* suffix;
160   const char* radical;
161   double power;
162   int core_amount;
163   double bw;
164   double lat;
165   double bb_bw;
166   double bb_lat;
167   const char* router_id;
168   e_surf_link_sharing_policy_t sharing_policy;
169   e_surf_link_sharing_policy_t bb_sharing_policy;
170   const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
171   const char* state_trace;
172 } s_sg_platf_cluster_cbarg_t;
173
174 typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
175 typedef struct s_sg_platf_cabinet_cbarg {
176   const char* id;
177   const char* prefix;
178   const char* suffix;
179   const char* radical;
180   double power;
181   double bw;
182   double lat;
183 } s_sg_platf_cabinet_cbarg_t;
184
185 typedef struct {
186   const char* id;
187   const char* type_id;
188   const char* content;
189 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
190
191 typedef struct {
192   const char* id;
193   const char* model;
194   const char* content;
195   xbt_dict_t properties;
196   unsigned long size; /* size in Gbytes */
197 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
198
199 typedef struct {
200   const char* type_id;
201   const char* name;
202 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
203
204 typedef struct {
205   const char* id;
206   const char* name;
207 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
208
209
210 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
211 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
212
213 XBT_PUBLIC(void) sg_platf_new_AS_begin(const char *id, int mode); // Begin description of new AS
214 XBT_PUBLIC(void) sg_platf_new_AS_end(void);                            // That AS is fully described
215
216 XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
217 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
218 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
219 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
220 XBT_PUBLIC(void) sg_platf_new_linkctn   (sg_platf_linkctn_cbarg_t linkctn);     // Add a linkctn
221 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
222 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
223 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
224
225 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
226 XBT_PUBLIC(void) sg_platf_new_ASroute (sg_platf_ASroute_cbarg_t ASroute); // Add an ASroute
227 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_bypassRoute_cbarg_t bypassroute); // Add a bypassRoute
228 XBT_PUBLIC(void) sg_platf_new_bypassASroute (sg_platf_bypassASroute_cbarg_t bypassASroute); // Add an bypassASroute
229
230 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
231 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
232 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
233 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
234 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
235
236 #endif                          /* SG_PLATF_H */