Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanup __surf_is_absolute_file_path + empty a bit surf.hpp
[simgrid.git] / src / surf / surf_interface.hpp
1 /* Copyright (c) 2004-2018. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SURF_MODEL_H_
7 #define SURF_MODEL_H_
8
9 #include "src/surf/surf_private.hpp"
10
11 #include <cmath>
12 #include <set>
13 #include <string>
14 #include <unordered_map>
15 #include <vector>
16
17 /*********
18  * Utils *
19  *********/
20
21 /* user-visible parameters */
22 XBT_PUBLIC_DATA double sg_maxmin_precision;
23 XBT_PUBLIC_DATA double sg_surf_precision;
24 XBT_PUBLIC_DATA int sg_concurrency_limit;
25
26 extern XBT_PRIVATE double sg_latency_factor;
27 extern XBT_PRIVATE double sg_bandwidth_factor;
28 extern XBT_PRIVATE double sg_weight_S_parameter;
29 extern XBT_PRIVATE std::vector<std::string> surf_path;
30 extern XBT_PRIVATE std::unordered_map<std::string, tmgr_trace_t> traces_set_list;
31 extern XBT_PRIVATE std::set<std::string> watched_hosts;
32
33 static inline void double_update(double* variable, double value, double precision)
34 {
35   // printf("Updating %g -= %g +- %g\n",*variable,value,precision);
36   // xbt_assert(value==0  || value>precision);
37   // Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding  may
38   // happen, and the precision mechanism is not active...
39   // xbt_assert(*variable< (2<<DBL_MANT_DIG)*precision && FLT_RADIX==2);
40   *variable -= value;
41   if (*variable < precision)
42     *variable = 0.0;
43 }
44
45 static inline int double_positive(double value, double precision)
46 {
47   return (value > precision);
48 }
49
50 static inline int double_equals(double value1, double value2, double precision)
51 {
52   return (fabs(value1 - value2) < precision);
53 }
54
55 /** \ingroup SURF_simulation
56  *  \brief List of hosts that have just restarted and whose autorestart process should be restarted.
57  */
58 XBT_PUBLIC_DATA std::vector<sg_host_t> host_that_restart;
59
60 /** \ingroup SURF_models
61  *  \brief Initializes the CPU model with the model Cas01
62  *
63  *  By default, this model uses the lazy optimization mechanism that relies on partial invalidation in LMM and a heap
64  *  for lazy action update.
65  *  You can change this behavior by setting the cpu/optim configuration variable to a different value.
66  *
67  *  You shouldn't have to call it by yourself.
68  */
69 XBT_PUBLIC void surf_cpu_model_init_Cas01();
70
71 /** \ingroup SURF_models
72  *  \brief Same as network model 'LagrangeVelho', only with different correction factors.
73  *
74  * This model is proposed by Pierre-Nicolas Clauss and Martin Quinson and Stéphane Génaud based on the model 'LV08' and
75  * different correction factors depending on the communication size (< 1KiB, < 64KiB, >= 64KiB).
76  * See comments in the code for more information.
77  *
78  *  \see surf_host_model_init_SMPI()
79  */
80 XBT_PUBLIC void surf_network_model_init_SMPI();
81
82 /** \ingroup SURF_models
83  *  \brief Same as network model 'LagrangeVelho', only with different correction factors.
84  *
85  * This model impelments a variant of the contention model on Infinband networks based on
86  * the works of Jérôme Vienne : http://mescal.imag.fr/membres/jean-marc.vincent/index.html/PhD/Vienne.pdf
87  *
88  *  \see surf_host_model_init_IB()
89  */
90 XBT_PUBLIC void surf_network_model_init_IB();
91
92 /** \ingroup SURF_models
93  *  \brief Initializes the platform with the network model 'LegrandVelho'
94  *
95  * This model is proposed by Arnaud Legrand and Pedro Velho based on the results obtained with the GTNets simulator for
96  * onelink and dogbone sharing scenarios. See comments in the code for more information.
97  *
98  *  \see surf_host_model_init_LegrandVelho()
99  */
100 XBT_PUBLIC void surf_network_model_init_LegrandVelho();
101
102 /** \ingroup SURF_models
103  *  \brief Initializes the platform with the network model 'Constant'
104  *
105  *  In this model, the communication time between two network cards is constant, hence no need for a routing table.
106  *  This is particularly useful when simulating huge distributed algorithms where scalability is really an issue. This
107  *  function is called in conjunction with surf_host_model_init_compound.
108  *
109  *  \see surf_host_model_init_compound()
110  */
111 XBT_PUBLIC void surf_network_model_init_Constant();
112
113 /** \ingroup SURF_models
114  *  \brief Initializes the platform with the network model CM02
115  *
116  *  You sould call this function by yourself only if you plan using surf_host_model_init_compound.
117  *  See comments in the code for more information.
118  */
119 XBT_PUBLIC void surf_network_model_init_CM02();
120
121 /** \ingroup SURF_models
122  *  \brief Initializes the platform with the network model NS3
123  *
124  *  This function is called by surf_host_model_init_NS3 or by yourself only if you plan using
125  *  surf_host_model_init_compound
126  *
127  *  \see surf_host_model_init_NS3()
128  */
129 XBT_PUBLIC void surf_network_model_init_NS3();
130
131 /** \ingroup SURF_models
132  *  \brief Initializes the platform with the network model Reno
133  *
134  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
135  *
136  *  Reference:
137  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
138  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
139  *
140  *  Call this function only if you plan using surf_host_model_init_compound.
141  */
142 XBT_PUBLIC void surf_network_model_init_Reno();
143
144 /** \ingroup SURF_models
145  *  \brief Initializes the platform with the network model Reno2
146  *
147  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
148  *
149  *  Reference:
150  *  [LOW01] S. H. Low. A duality model of TCP and queue management algorithms.
151  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
152  *
153  *  Call this function only if you plan using surf_host_model_init_compound.
154  */
155 XBT_PUBLIC void surf_network_model_init_Reno2();
156
157 /** \ingroup SURF_models
158  *  \brief Initializes the platform with the network model Vegas
159  *
160  *  This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent  to the proportional fairness.
161  *
162  *  Reference:
163  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
164  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
165  *
166  *  Call this function only if you plan using surf_host_model_init_compound.
167  */
168 XBT_PUBLIC void surf_network_model_init_Vegas();
169
170 /** \ingroup SURF_models
171  *  \brief Initializes the platform with the current best network and cpu models at hand
172  *
173  *  This platform model seperates the host model and the network model.
174  *  The host model will be initialized with the model compound, the network model with the model LV08 (with cross
175  *  traffic support) and the CPU model with the model Cas01.
176  *  Such model is subject to modification with warning in the ChangeLog so monitor it!
177  */
178 XBT_PUBLIC void surf_vm_model_init_HL13();
179
180 /** \ingroup SURF_models
181  *  \brief Initializes the platform with a compound host model
182  *
183  *  This function should be called after a cpu_model and a network_model have been set up.
184  */
185 XBT_PUBLIC void surf_host_model_init_compound();
186
187 /** \ingroup SURF_models
188  *  \brief Initializes the platform with the current best network and cpu models at hand
189  *
190  *  This platform model separates the host model and the network model.
191  *  The host model will be initialized with the model compound, the network model with the model LV08 (with cross
192  *  traffic support) and the CPU model with the model Cas01.
193  *  Such model is subject to modification with warning in the ChangeLog so monitor it!
194  */
195 XBT_PUBLIC void surf_host_model_init_current_default();
196
197 /** \ingroup SURF_models
198  *  \brief Initializes the platform with the model L07
199  *
200  *  With this model, only parallel tasks can be used. Resource sharing is done by identifying bottlenecks and giving an
201  *  equal share of the model to each action.
202  */
203 XBT_PUBLIC void surf_host_model_init_ptask_L07();
204
205 /** \ingroup SURF_models
206  *  \brief The storage model
207  */
208 XBT_PUBLIC void surf_storage_model_init_default();
209
210 /**********
211  * Action *
212  **********/
213
214 #endif /* SURF_MODEL_H_ */