Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
564f1416bbc6ae84918432d12ae6a401fd07ab09
[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
7 #ifndef _SURF_SURF_PRIVATE_H
8 #define _SURF_SURF_PRIVATE_H
9
10 #include "surf/surf.h"
11 #include "surf/maxmin.h"
12 #include "surf/trace_mgr.h"
13 #include "xbt/log.h"
14 #include "surf/surfxml_parse_private.h"
15 #include "surf/random_mgr.h"
16 #include "instr/private.h"
17
18 #define NO_MAX_DURATION -1.0
19
20 /* user-visible parameters */
21 extern double sg_tcp_gamma;
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 #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 enum {
35   SURF_LINK_SHARED = 1,
36   SURF_LINK_FATPIPE = 0
37 } e_surf_link_sharing_policy_t;
38
39 typedef struct surf_model_private {
40   int (*resource_used) (void *resource_id);
41   /* Share the resources to the actions and return in how much time
42      the next action may terminate */
43   double (*share_resources) (double now);
44   /* Update the actions' state */
45   void (*update_actions_state) (double now, double delta);
46   void (*update_resource_state) (void *id, tmgr_trace_event_t event_type,
47                                  double value, double time);
48   void (*finalize) (void);
49 } s_surf_model_private_t;
50
51 double generic_maxmin_share_resources(xbt_swag_t running_actions,
52                                       size_t offset,
53                                       lmm_system_t sys,
54                                       void (*solve) (lmm_system_t));
55
56 /* Generic functions common to all models */
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
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 {
92         int src_id;
93         int dst_id;
94         void *link_ptr;
95 }s_onelink, *s_onelink_t;
96
97
98 /*
99  * Routing logic
100  */
101 struct s_routing {
102   const char *name;
103   xbt_dict_t host_id; /* char* -> int* */
104   xbt_dynar_t (*get_route)(int src, int dst);
105   xbt_dict_t (*get_onelink_routes)(void);
106   int (*is_router)(int id);
107   void (*finalize)(void);
108   int host_count;
109   int router_count;
110 };
111 XBT_PUBLIC(void) routing_model_create(size_t size_of_link,void *loopback);
112
113 /*
114  * generic methods to create resources bypassing the parser
115  * FIXME : better if added to the routing model instead
116  */
117 XBT_PUBLIC(void) routing_set_route(char *source_id,char *destination_id,xbt_dynar_t links_id,int action);
118 XBT_PUBLIC(void) routing_add_host(char* host_id);
119
120 /*
121  * Resource protected methods
122  */
123 xbt_dict_t surf_resource_properties(const void *resource);
124
125 XBT_PUBLIC(void) surfxml_bufferstack_push(int new);
126 XBT_PUBLIC(void) surfxml_bufferstack_pop(int new);
127 XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
128
129
130 #endif /* _SURF_SURF_PRIVATE_H */