Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Added the lazy management improvement for network models.
[simgrid.git] / src / surf / surf_private.h
1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef _SURF_SURF_PRIVATE_H
7 #define _SURF_SURF_PRIVATE_H
8
9 #include "surf/surf.h"
10 #include "surf/maxmin.h"
11 #include "surf/trace_mgr.h"
12 #include "xbt/log.h"
13 #include "surf/surfxml_parse_private.h"
14 #include "surf/random_mgr.h"
15 #include "instr/instr_private.h"
16
17 #define NO_MAX_DURATION -1.0
18
19 /* user-visible parameters */
20 extern double sg_tcp_gamma;
21 extern double sg_sender_gap;
22 extern double sg_latency_factor;
23 extern double sg_bandwidth_factor;
24 extern double sg_weight_S_parameter;
25 extern int sg_maxmin_selective_update;
26 extern int sg_network_fullduplex;
27 #ifdef HAVE_GTNETS
28 extern double sg_gtnets_jitter;
29 extern int sg_gtnets_jitter_seed;
30 #endif
31
32
33 extern const char *surf_action_state_names[6];
34
35 typedef struct surf_model_private {
36   int (*resource_used) (void *resource_id);
37   /* Share the resources to the actions and return in how much time
38      the next action may terminate */
39   double (*share_resources) (double now);
40   /* Update the actions' state */
41   void (*update_actions_state) (double now, double delta);
42   void (*update_resource_state) (void *id, tmgr_trace_event_t event_type,
43                                  double value, double time);
44   void (*finalize) (void);
45 } s_surf_model_private_t;
46
47 double generic_maxmin_share_resources(xbt_swag_t running_actions,
48                                       size_t offset,
49                                       lmm_system_t sys,
50                                       void (*solve) (lmm_system_t));
51
52 /* Generic functions common to all models */
53 e_surf_action_state_t surf_action_state_get(surf_action_t action);      /* cannot declare inline since we use a pointer to it */
54 double surf_action_get_start_time(surf_action_t action);        /* cannot declare inline since we use a pointer to it */
55 double surf_action_get_finish_time(surf_action_t action);       /* cannot declare inline since we use a pointer to it */
56 void surf_action_free(surf_action_t * action);
57 void surf_action_state_set(surf_action_t action,
58                            e_surf_action_state_t state);
59 void surf_action_data_set(surf_action_t action, void *data);    /* cannot declare inline since we use a pointer to it */
60 FILE *surf_fopen(const char *name, const char *mode);
61
62 extern tmgr_history_t history;
63 extern xbt_dynar_t surf_path;
64
65 void surf_config_init(int *argc, char **argv);
66 void surf_config_finalize(void);
67 void surf_config(const char *name, va_list pa);
68
69 void net_action_recycle(surf_action_t action);
70 double net_action_get_remains(surf_action_t action);
71 #ifdef HAVE_LATENCY_BOUND_TRACKING
72 int net_get_link_latency_limited(surf_action_t action);
73 #endif
74 void net_action_set_max_duration(surf_action_t action, double duration);
75 /*
76  * Returns the initial path. On Windows the initial path is
77  * the current directory for the current process in the other
78  * case the function returns "./" that represents the current
79  * directory on Unix/Linux platforms.
80  */
81 const char *__surf_get_initial_path(void);
82
83 /* The __surf_is_absolute_file_path() returns 1 if
84  * file_path is a absolute file path, in the other
85  * case the function returns 0.
86  */
87 int __surf_is_absolute_file_path(const char *file_path);
88
89 /*
90  * One link routing list
91  */
92 typedef struct s_onelink {
93   char *src;
94   char *dst;
95   void *link_ptr;
96 } s_onelink_t, *onelink_t;
97
98 /**
99  * Routing logic
100  */
101
102 typedef struct s_model_type {
103   const char *name;
104   const char *desc;
105   void *(*create) ();
106   void (*load) ();
107   void (*unload) ();
108   void (*end) ();
109 } s_model_type_t, *model_type_t;
110
111 typedef struct s_route {
112   xbt_dynar_t link_list;
113 } s_route_t, *route_t;
114
115 typedef struct s_name_route {
116   xbt_dynar_t link_name_list;
117 } s_name_route_t, *name_route_t;
118
119 typedef struct s_name_route_extended {
120   s_route_t generic_route;
121   char *src_gateway;
122   char *dst_gateway;
123 } s_name_route_extended_t, *name_route_extended_t;
124
125 typedef struct s_route_limits {
126   char *src_gateway;
127   char *dst_gateway;
128 } s_route_limits_t, *route_limits_t;
129
130 typedef struct s_route_extended {
131   s_route_t generic_route;
132   char *src_gateway;
133   char *dst_gateway;
134 } s_route_extended_t, *route_extended_t;
135
136 /* This enum used in the routing structure helps knowing in which situation we are. */
137 typedef enum {
138   SURF_ROUTING_NULL = 0,   /**< Indefined type                                   */
139   SURF_ROUTING_BASE,       /**< Base case: use simple link lists for routing     */
140   SURF_ROUTING_RECURSIVE   /**< Recursive case: also return gateway informations */
141 } e_surf_routing_hierarchy_t;
142
143 typedef enum {
144   SURF_NETWORK_ELEMENT_NULL = 0,        /* NULL */
145   SURF_NETWORK_ELEMENT_HOST,    /* host type */
146   SURF_NETWORK_ELEMENT_ROUTER,  /* router type */
147   SURF_NETWORK_ELEMENT_AS,      /* AS type */
148 } e_surf_network_element_type_t;
149
150 typedef struct s_routing_component *routing_component_t;
151 typedef struct s_routing_component {
152   xbt_dict_t to_index;                  /* char* -> network_element_t */
153   xbt_dict_t bypassRoutes;              /* store bypass routes */
154   model_type_t routing;
155   e_surf_routing_hierarchy_t hierarchy;
156   char *name;
157   struct s_routing_component *routing_father;
158   xbt_dict_t routing_sons;
159    route_extended_t(*get_route) (routing_component_t rc, const char *src,
160                                  const char *dst);
161    double(*get_latency) (routing_component_t rc, const char *src,
162                                  const char *dst);
163    xbt_dynar_t(*get_onelink_routes) (routing_component_t rc);
164    e_surf_network_element_type_t(*get_network_element_type) (const char
165                                                              *name);
166    route_extended_t(*get_bypass_route) (routing_component_t rc,
167                                         const char *src, const char *dst);
168   void (*finalize) (routing_component_t rc);
169   void (*set_processing_unit) (routing_component_t rc, const char *name);
170   void (*set_autonomous_system) (routing_component_t rc, const char *name);
171   void (*set_route) (routing_component_t rc, const char *src,
172                      const char *dst, name_route_extended_t route);
173   void (*set_ASroute) (routing_component_t rc, const char *src,
174                        const char *dst, name_route_extended_t route);
175   void (*set_bypassroute) (routing_component_t rc, const char *src,
176                            const char *dst, route_extended_t e_route);
177 } s_routing_component_t;
178
179 typedef struct s_network_element_info {
180   routing_component_t rc_component;
181   e_surf_network_element_type_t rc_type;
182 } s_network_element_info_t, *network_element_info_t;
183
184 typedef int *network_element_t;
185
186 struct s_routing_global {
187   routing_component_t root;
188   xbt_dict_t where_network_elements;    /* char* -> network_element_info_t */
189   void *loopback;
190   size_t size_of_link;
191    xbt_dynar_t(*get_route) (const char *src, const char *dst);
192    xbt_dynar_t(*get_route_no_cleanup) (const char *src, const char *dst);
193    xbt_dynar_t(*get_onelink_routes) (void);
194    double (*get_latency) (const char *src, const char *dst);
195    e_surf_network_element_type_t(*get_network_element_type) (const char
196                                                              *name);
197   void (*finalize) (void);
198   xbt_dynar_t last_route;
199 };
200
201 XBT_PUBLIC(void) routing_model_create(size_t size_of_link, void *loopback, double_f_cpvoid_t get_link_latency_fun);
202
203 /**
204  * Resource protected methods
205  */
206 xbt_dict_t surf_resource_properties(const void *resource);
207
208 XBT_PUBLIC(void) surfxml_bufferstack_push(int new);
209 XBT_PUBLIC(void) surfxml_bufferstack_pop(int new);
210
211 XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
212
213 #endif                          /* _SURF_SURF_PRIVATE_H */