Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f600b16612bc0cb7f2a47c3b312c015955f7683a
[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                                           
33 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(double min,
34                                                                            double max);
35 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(double rate);
36 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(double scale,
37                                                                            double shape);
38
39 /** Defines whether a given resource is working or not */
40 typedef enum {
41   SURF_RESOURCE_ON = 1,                   /**< Up & ready        */
42   SURF_RESOURCE_OFF = 0                   /**< Down & broken     */
43 } e_surf_resource_state_t;
44
45 typedef enum {
46   SURF_LINK_FULLDUPLEX = 2,
47   SURF_LINK_SHARED = 1,
48   SURF_LINK_FATPIPE = 0
49 } e_surf_link_sharing_policy_t;
50
51 /*
52  * Platform creation functions. Instead of passing 123 arguments to the creation functions
53  * (one for each possible XML attribute), we pass structures containing them all. It removes the
54  * chances of switching arguments by error, and reduce the burden when we add a new attribute:
55  * old models can just continue to ignore it without having to update their headers.
56  *
57  * It shouldn't be too costly at runtime, provided that structures living on the stack are
58  * used, instead of malloced structures.
59  */
60
61 typedef struct {
62   const char* id;
63   double power_peak;
64   int core_amount;
65   double power_scale;
66   tmgr_trace_t power_trace;
67   e_surf_resource_state_t initial_state;
68   tmgr_trace_t state_trace;
69   const char* coord;
70   xbt_dict_t properties;
71 } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
72
73 typedef struct {
74   const char* id;
75   const char* coord;
76 } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
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   e_surf_resource_state_t state;
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 typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
91 typedef struct s_sg_platf_peer_cbarg {
92   const char* id;
93   double power;
94   double bw_in;
95   double bw_out;
96   double lat;
97   const char* coord;
98   tmgr_trace_t availability_trace;
99   tmgr_trace_t state_trace;
100 } s_sg_platf_peer_cbarg_t;
101
102 typedef struct s_sg_platf_linkctn_cbarg *sg_platf_linkctn_cbarg_t;
103 typedef struct s_sg_platf_linkctn_cbarg {
104   const char *id;
105   const char *direction;
106 } s_sg_platf_linkctn_cbarg_t;
107
108 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
109 typedef struct s_sg_platf_cluster_cbarg {
110   const char* id;
111   const char* prefix;
112   const char* suffix;
113   const char* radical;
114   double power;
115   int core_amount;
116   double bw;
117   double lat;
118   double bb_bw;
119   double bb_lat;
120   const char* router_id;
121   e_surf_link_sharing_policy_t sharing_policy;
122   e_surf_link_sharing_policy_t bb_sharing_policy;
123   const char* availability_trace; //don't convert to tmgr_trace_t since there is a trace per host and some rewriting is needed
124   const char* state_trace;
125 } s_sg_platf_cluster_cbarg_t;
126
127 typedef struct {
128   const char* id;
129   const char* type_id;
130   const char* content;
131 } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
132
133 typedef struct {
134   const char* id;
135   const char* model;
136   const char* content;
137   xbt_dict_t properties;
138   unsigned long size; /* size in Gbytes */
139 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
140
141 typedef struct {
142   const char* type_id;
143   const char* name;
144 } s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
145
146 typedef struct {
147   const char* id;
148   const char* name;
149 } s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
150
151
152 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
153 XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform
154
155 XBT_PUBLIC(void) sg_platf_new_AS_begin(const char *id, int mode); // Begin description of new AS
156 XBT_PUBLIC(void) sg_platf_new_AS_end(void);                            // That AS is fully described
157
158 XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
159 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
160 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
161 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
162 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
163 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
164 XBT_PUBLIC(void) sg_platf_new_storage(sg_platf_storage_cbarg_t storage); // Add a storage to the currently described AS
165 XBT_PUBLIC(void) sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage);
166 XBT_PUBLIC(void) sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type);
167 XBT_PUBLIC(void) sg_platf_new_mount(sg_platf_mount_cbarg_t mount);
168
169 #endif                          /* SG_PLATF_H */