Logo AND Algorithmique Numérique Distribuée

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