Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9f60ac92e242496298286eef61786ea4ec501623
[simgrid.git] / src / surf / surf_private.h
1 /* Copyright (c) 2004-2013. 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.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 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 extern xbt_dict_t watched_hosts_lib;
25
26 extern const char *surf_action_state_names[6];
27
28 typedef enum {
29   UM_FULL,
30   UM_LAZY,
31   UM_UNDEFINED
32 } e_UM_t;
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
45   lmm_system_t maxmin_system;
46   e_UM_t update_mechanism;
47   xbt_swag_t modified_set;
48   xbt_heap_t action_heap;
49   int selective_update;
50
51 } s_surf_model_private_t;
52
53 /*FIXME:REMOVEdouble generic_maxmin_share_resources(xbt_swag_t running_actions,
54                                       size_t offset,
55                                       lmm_system_t sys,
56                                       void (*solve) (lmm_system_t));*/
57 double generic_share_resources_lazy(double now, surf_model_t model);
58
59 /* Generic functions common to all models */
60 void surf_action_init(void);
61 void surf_action_exit(void);
62 e_surf_action_state_t surf_action_state_get(surf_action_t action);      /* cannot declare inline since we use a pointer to it */
63 //FIXME:DELETEdouble surf_action_get_start_time(surf_action_t action);        /* cannot declare inline since we use a pointer to it */
64 double surf_action_get_finish_time(surf_action_t action);       /* cannot declare inline since we use a pointer to it */
65 void surf_action_free(surf_action_t * action);
66 /*FIXME:void surf_action_state_set(surf_action_t action,
67                            e_surf_action_state_t state);*/
68 //FIXME:void surf_action_data_set(surf_action_t action, void *data);    /* cannot declare inline since we use a pointer to it */
69
70 void surf_action_lmm_update_index_heap(void *action, int i); /* callback for heap management shared by cpu and net models */
71 /*FIXME:void surf_action_lmm_heap_insert(xbt_heap_t heap, surf_action_lmm_t action,
72     double key, enum heap_action_type hat);*/
73 void surf_action_lmm_heap_remove(xbt_heap_t heap,surf_action_lmm_t action);
74
75 void surf_action_cancel(surf_action_t action);
76 //FIXME:removeint surf_action_unref(surf_action_t action);
77 void surf_action_suspend(surf_action_t action);
78 void surf_action_resume(surf_action_t action);
79 int surf_action_is_suspended(surf_action_t action);
80 void surf_action_set_max_duration(surf_action_t action, double duration);
81 void surf_action_set_priority(surf_action_t action, double priority);
82 #ifdef HAVE_TRACING
83 void surf_action_set_category(surf_action_t action,
84                                     const char *category);
85 #endif
86 double surf_action_get_remains(surf_action_t action);
87 void update_resource_energy(surf_model_t model, surf_action_lmm_t action);
88 void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now);
89 void generic_update_actions_state_lazy(double now, double delta, surf_model_t model);
90 void generic_update_actions_state_full(double now, double delta, surf_model_t model);
91
92 FILE *surf_fopen(const char *name, const char *mode);
93
94 extern tmgr_history_t history;
95
96 //void surf_config_init(int *argc, char **argv);
97 //void surf_config_finalize(void);
98 //void surf_config(const char *name, va_list pa);
99
100 void net_action_recycle(surf_action_t action);
101 #ifdef HAVE_LATENCY_BOUND_TRACKING
102 int net_get_link_latency_limited(surf_action_t action);
103 #endif
104
105 /* The __surf_is_absolute_file_path() returns 1 if
106  * file_path is a absolute file path, in the other
107  * case the function returns 0.
108  */
109 int __surf_is_absolute_file_path(const char *file_path);
110
111 typedef struct s_routing_edge {
112   AS_t rc_component;
113   e_surf_network_element_type_t rc_type;
114   int id;
115   char *name;
116 } s_routing_edge_t;
117
118 /*
119  * Link of lenght 1, alongside with its source and destination. This is mainly usefull in the bindings to gtnets and ns3
120  */
121 typedef struct s_onelink {
122   sg_routing_edge_t src;
123   sg_routing_edge_t dst;
124   void *link_ptr;
125 } s_onelink_t, *onelink_t;
126
127 /**
128  * Routing logic
129  */
130
131 typedef struct s_model_type {
132   const char *name;
133   const char *desc;
134   AS_t (*create) ();
135   void (*end) (AS_t as);
136 } s_routing_model_description_t, *routing_model_description_t;
137
138 /* This enum used in the routing structure helps knowing in which situation we are. */
139 typedef enum {
140   SURF_ROUTING_NULL = 0,   /**< Undefined 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;
144
145 typedef struct s_as {
146   xbt_dynar_t index_network_elm;
147   xbt_dict_t bypassRoutes;    /* store bypass routes */
148   routing_model_description_t model_desc;
149   e_surf_routing_hierarchy_t hierarchy;
150   char *name;
151   struct s_as *routing_father;
152   xbt_dict_t routing_sons;
153   sg_routing_edge_t net_elem;
154   xbt_dynar_t link_up_down_list;
155
156   void (*get_route_and_latency) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, sg_platf_route_cbarg_t into, double *latency);
157
158   xbt_dynar_t(*get_onelink_routes) (AS_t as);
159   void (*get_graph) (xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, AS_t rc);
160   sg_platf_route_cbarg_t(*get_bypass_route) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat);
161   void (*finalize) (AS_t as);
162
163
164   /* The parser calls the following functions to inform the routing models
165    * that a new element is added to the AS currently built.
166    *
167    * Of course, only the routing model of this AS is informed, not every ones */
168   int (*parse_PU) (AS_t as, sg_routing_edge_t elm); /* A host or a router, whatever */
169   int (*parse_AS) (AS_t as, sg_routing_edge_t elm);
170   void (*parse_route) (AS_t as, sg_platf_route_cbarg_t route);
171   void (*parse_ASroute) (AS_t as, sg_platf_route_cbarg_t route);
172   void (*parse_bypassroute) (AS_t as, sg_platf_route_cbarg_t e_route);
173
174 } s_as_t;
175
176 struct s_routing_platf {
177   AS_t root;
178   void *loopback;
179   xbt_dynar_t last_route;
180   xbt_dynar_t(*get_onelink_routes) (void);
181 };
182
183 XBT_PUBLIC(void) routing_model_create(void *loopback);
184 XBT_PUBLIC(void) routing_exit(void);
185 XBT_PUBLIC(void) storage_register_callbacks(void);
186 /* ***************************************** */
187 /* TUTORIAL: New TAG                         */
188 XBT_PUBLIC(void) gpu_register_callbacks(void);
189 /* ***************************************** */
190
191 XBT_PUBLIC(void) routing_register_callbacks(void);
192 XBT_PUBLIC(void) generic_free_route(sg_platf_route_cbarg_t route); // FIXME rename to routing_route_free
193  // FIXME: make previous function private to routing again?
194
195
196 XBT_PUBLIC(void) routing_get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst,
197                               xbt_dynar_t * route, double *latency);
198
199 XBT_PUBLIC(void) generic_get_graph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, AS_t rc);
200 /**
201  * Resource protected methods
202  */
203 XBT_PUBLIC(void) surfxml_bufferstack_push(int _new);
204 XBT_PUBLIC(void) surfxml_bufferstack_pop(int _new);
205
206 XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
207
208 /********** Tracing **********/
209 /* from surf_instr.c */
210 void TRACE_surf_host_set_power(double date, const char *resource, double power);
211 void TRACE_surf_link_set_bandwidth(double date, const char *resource, double bandwidth);
212
213 #ifdef __cplusplus
214 }
215 #endif
216
217 #endif                          /* _SURF_SURF_PRIVATE_H */