1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
2 * All rights reserved. */
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
10 #include "surf/maxmin.h"
11 #include "surf/trace_mgr.h"
13 #include "surf/surfxml_parse_private.h"
14 #include "surf/random_mgr.h"
15 #include "instr/instr_private.h"
17 #define NO_MAX_DURATION -1.0
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;
28 extern double sg_gtnets_jitter;
29 extern int sg_gtnets_jitter_seed;
33 extern const char *surf_action_state_names[6];
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;
47 double generic_maxmin_share_resources(xbt_swag_t running_actions,
50 void (*solve) (lmm_system_t));
52 /* Generic functions common to all models */
53 void surf_action_init(void);
54 void surf_action_exit(void);
55 e_surf_action_state_t surf_action_state_get(surf_action_t action); /* cannot declare inline since we use a pointer to it */
56 double surf_action_get_start_time(surf_action_t action); /* cannot declare inline since we use a pointer to it */
57 double surf_action_get_finish_time(surf_action_t action); /* cannot declare inline since we use a pointer to it */
58 void surf_action_free(surf_action_t * action);
59 void surf_action_state_set(surf_action_t action,
60 e_surf_action_state_t state);
61 void surf_action_data_set(surf_action_t action, void *data); /* cannot declare inline since we use a pointer to it */
62 FILE *surf_fopen(const char *name, const char *mode);
64 extern tmgr_history_t history;
65 extern xbt_dynar_t surf_path;
67 void surf_config_init(int *argc, char **argv);
68 void surf_config_finalize(void);
69 void surf_config(const char *name, va_list pa);
71 void net_action_recycle(surf_action_t action);
72 double net_action_get_remains(surf_action_t action);
73 #ifdef HAVE_LATENCY_BOUND_TRACKING
74 int net_get_link_latency_limited(surf_action_t action);
76 void net_action_set_max_duration(surf_action_t action, double duration);
78 * Returns the initial path. On Windows the initial path is
79 * the current directory for the current process in the other
80 * case the function returns "./" that represents the current
81 * directory on Unix/Linux platforms.
83 const char *__surf_get_initial_path(void);
85 /* The __surf_is_absolute_file_path() returns 1 if
86 * file_path is a absolute file path, in the other
87 * case the function returns 0.
89 int __surf_is_absolute_file_path(const char *file_path);
92 * One link routing list
94 typedef struct s_onelink {
98 } s_onelink_t, *onelink_t;
104 typedef struct s_model_type {
111 } s_model_type_t, *model_type_t;
113 typedef struct s_route {
114 xbt_dynar_t link_list;
115 } s_route_t, *route_t;
117 typedef struct s_name_route {
118 xbt_dynar_t link_name_list;
119 } s_name_route_t, *name_route_t;
121 typedef struct s_name_route_extended {
122 s_route_t generic_route;
125 } s_name_route_extended_t, *name_route_extended_t;
127 typedef struct s_route_limits {
130 } s_route_limits_t, *route_limits_t;
132 typedef struct s_route_extended {
133 s_route_t generic_route;
136 } s_route_extended_t, *route_extended_t;
138 /* This enum used in the routing structure helps knowing in which situation we are. */
140 SURF_ROUTING_NULL = 0, /**< Indefined type */
141 SURF_ROUTING_BASE, /**< Base case: use simple link lists for routing */
142 SURF_ROUTING_RECURSIVE /**< Recursive case: also return gateway informations */
143 } e_surf_routing_hierarchy_t;
145 typedef struct s_routing_component *routing_component_t;
146 typedef struct s_routing_component {
147 xbt_dict_t to_index; /* char* -> network_element_t */
148 xbt_dict_t bypassRoutes; /* store bypass routes */
149 model_type_t routing;
150 e_surf_routing_hierarchy_t hierarchy;
152 struct s_routing_component *routing_father;
153 xbt_dict_t routing_sons;
154 route_extended_t(*get_route) (routing_component_t rc, const char *src,
156 double(*get_latency) (routing_component_t rc, const char *src,
157 const char *dst, route_extended_t e_route);
158 xbt_dynar_t(*get_onelink_routes) (routing_component_t rc);
159 e_surf_network_element_type_t(*get_network_element_type) (const char
161 route_extended_t(*get_bypass_route) (routing_component_t rc,
162 const char *src, const char *dst);
163 void (*finalize) (routing_component_t rc);
164 void (*set_processing_unit) (routing_component_t rc, const char *name);
165 void (*set_autonomous_system) (routing_component_t rc, const char *name);
166 void (*set_route) (routing_component_t rc, const char *src,
167 const char *dst, name_route_extended_t route);
168 void (*set_ASroute) (routing_component_t rc, const char *src,
169 const char *dst, name_route_extended_t route);
170 void (*set_bypassroute) (routing_component_t rc, const char *src,
171 const char *dst, route_extended_t e_route);
172 } s_routing_component_t;
174 typedef struct s_network_element_info {
175 routing_component_t rc_component;
176 e_surf_network_element_type_t rc_type;
177 } s_network_element_info_t, *network_element_info_t;
179 typedef int *network_element_t;
181 struct s_routing_global {
182 routing_component_t root;
185 xbt_dynar_t(*get_route) (const char *src, const char *dst);
186 xbt_dynar_t(*get_route_no_cleanup) (const char *src, const char *dst);
187 xbt_dynar_t(*get_onelink_routes) (void);
188 double (*get_latency) (const char *src, const char *dst);
189 void (*get_route_latency)(const char *src, const char *dst,
190 xbt_dynar_t *route, double *latency, int cleanup);
191 e_surf_network_element_type_t(*get_network_element_type) (const char *name);
192 void (*finalize) (void);
193 xbt_dynar_t last_route;
196 XBT_PUBLIC(void) routing_model_create(size_t size_of_link, void *loopback, double_f_cpvoid_t get_link_latency_fun);
198 XBT_PUBLIC(void) routing_parse_Scluster(void); /* cluster bypass */
201 * Resource protected methods
203 xbt_dict_t surf_resource_properties(const void *resource);
205 XBT_PUBLIC(void) surfxml_bufferstack_push(int new);
206 XBT_PUBLIC(void) surfxml_bufferstack_pop(int new);
208 XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
210 #endif /* _SURF_SURF_PRIVATE_H */