Logo AND Algorithmique Numérique Distribuée

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