Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill ALL trailing whitespace (and deprecate a function in Link)
[simgrid.git] / src / include / surf / surf.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_SURF_H
7 #define SURF_SURF_H
8
9 #include "simgrid/forward.h"
10 #include "xbt/graph.h"
11
12 namespace simgrid {
13 namespace surf {
14 class CpuModel;
15 class HostModel;
16 class NetworkModel;
17 class StorageModel;
18 class NetworkCm02Link;
19 }
20 }
21
22 /** \brief Resource model description
23  */
24 struct surf_model_description {
25   const char* name;
26   const char* description;
27   void_f_void_t model_init_preparse;
28 };
29 typedef struct surf_model_description s_surf_model_description_t;
30
31 XBT_PUBLIC int find_model_description(s_surf_model_description_t* table, std::string name);
32 XBT_PUBLIC void model_help(const char* category, s_surf_model_description_t* table);
33
34 /***************************/
35 /* Generic model object */
36 /***************************/
37
38 /** @{ @ingroup SURF_c_bindings */
39
40 /**
41  * @brief Pop an action from the done actions set
42  *
43  * @param model The model from which the action is extracted
44  * @return An action in done state
45  */
46 XBT_PUBLIC simgrid::kernel::resource::Action*
47 surf_model_extract_done_action_set(simgrid::kernel::resource::Model* model);
48
49 /**
50  * @brief Pop an action from the failed actions set
51  *
52  * @param model The model from which the action is extracted
53  * @return An action in failed state
54  */
55 XBT_PUBLIC simgrid::kernel::resource::Action*
56 surf_model_extract_failed_action_set(simgrid::kernel::resource::Model* model);
57
58 /**
59  * @brief Get the size of the running action set of a model
60  *
61  * @param model The model
62  * @return The size of the running action set
63  */
64 XBT_PUBLIC int surf_model_running_action_set_size(simgrid::kernel::resource::Model* model);
65
66 /**
67  * @brief [brief description]
68  * @details [long description]
69  *
70  * @param action The surf cpu action
71  * @param bound [description]
72  */
73 XBT_PUBLIC void surf_cpu_action_set_bound(simgrid::kernel::resource::Action* action, double bound);
74
75 /** @} */
76
77 /**************************************/
78 /* Implementations of model object */
79 /**************************************/
80
81 /** \ingroup SURF_models
82  *  \brief The CPU model object for the physical machine layer
83  */
84 XBT_PUBLIC_DATA simgrid::surf::CpuModel* surf_cpu_model_pm;
85
86 /** \ingroup SURF_models
87  *  \brief The CPU model object for the virtual machine layer
88  */
89 XBT_PUBLIC_DATA simgrid::surf::CpuModel* surf_cpu_model_vm;
90
91 /** \ingroup SURF_models
92  *  \brief Initializes the CPU model with the model Cas01
93  *
94  *  By default, this model uses the lazy optimization mechanism that relies on partial invalidation in LMM and a heap
95  *  for lazy action update.
96  *  You can change this behavior by setting the cpu/optim configuration variable to a different value.
97  *
98  *  You shouldn't have to call it by yourself.
99  */
100 XBT_PUBLIC void surf_cpu_model_init_Cas01();
101
102 /** \ingroup SURF_models
103  *  \brief Initializes the CPU model with trace integration [Deprecated]
104  *
105  *  You shouldn't have to call it by yourself.
106  */
107 XBT_PUBLIC void surf_cpu_model_init_ti();
108
109 /** \ingroup SURF_models
110  *  \brief The list of all available optimization modes (both for cpu and networks).
111  *  These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:...
112  */
113 XBT_PUBLIC_DATA s_surf_model_description_t surf_optimization_mode_description[];
114
115 /** \ingroup SURF_plugins
116  *  \brief The list of all available surf plugins
117  */
118 XBT_PUBLIC_DATA s_surf_model_description_t surf_plugin_description[];
119
120 /** \ingroup SURF_models
121  *  \brief The list of all available cpu model models
122  */
123 XBT_PUBLIC_DATA s_surf_model_description_t surf_cpu_model_description[];
124
125 /** \ingroup SURF_models
126  *  \brief Same as network model 'LagrangeVelho', only with different correction factors.
127  *
128  * This model is proposed by Pierre-Nicolas Clauss and Martin Quinson and Stéphane Génaud based on the model 'LV08' and
129  * different correction factors depending on the communication size (< 1KiB, < 64KiB, >= 64KiB).
130  * See comments in the code for more information.
131  *
132  *  \see surf_host_model_init_SMPI()
133  */
134 XBT_PUBLIC void surf_network_model_init_SMPI();
135
136 /** \ingroup SURF_models
137  *  \brief Same as network model 'LagrangeVelho', only with different correction factors.
138  *
139  * This model impelments a variant of the contention model on Infinband networks based on
140  * the works of Jérôme Vienne : http://mescal.imag.fr/membres/jean-marc.vincent/index.html/PhD/Vienne.pdf
141  *
142  *  \see surf_host_model_init_IB()
143  */
144 XBT_PUBLIC void surf_network_model_init_IB();
145
146 /** \ingroup SURF_models
147  *  \brief Initializes the platform with the network model 'LegrandVelho'
148  *
149  * This model is proposed by Arnaud Legrand and Pedro Velho based on the results obtained with the GTNets simulator for
150  * onelink and dogbone sharing scenarios. See comments in the code for more information.
151  *
152  *  \see surf_host_model_init_LegrandVelho()
153  */
154 XBT_PUBLIC void surf_network_model_init_LegrandVelho();
155
156 /** \ingroup SURF_models
157  *  \brief Initializes the platform with the network model 'Constant'
158  *
159  *  In this model, the communication time between two network cards is constant, hence no need for a routing table.
160  *  This is particularly useful when simulating huge distributed algorithms where scalability is really an issue. This
161  *  function is called in conjunction with surf_host_model_init_compound.
162  *
163  *  \see surf_host_model_init_compound()
164  */
165 XBT_PUBLIC void surf_network_model_init_Constant();
166
167 /** \ingroup SURF_models
168  *  \brief Initializes the platform with the network model CM02
169  *
170  *  You sould call this function by yourself only if you plan using surf_host_model_init_compound.
171  *  See comments in the code for more information.
172  */
173 XBT_PUBLIC void surf_network_model_init_CM02();
174
175 /** \ingroup SURF_models
176  *  \brief Initializes the platform with the network model NS3
177  *
178  *  This function is called by surf_host_model_init_NS3 or by yourself only if you plan using
179  *  surf_host_model_init_compound
180  *
181  *  \see surf_host_model_init_NS3()
182  */
183 XBT_PUBLIC void surf_network_model_init_NS3();
184
185 /** \ingroup SURF_models
186  *  \brief Initializes the platform with the network model Reno
187  *
188  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
189  *
190  *  Reference:
191  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
192  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
193  *
194  *  Call this function only if you plan using surf_host_model_init_compound.
195  */
196 XBT_PUBLIC void surf_network_model_init_Reno();
197
198 /** \ingroup SURF_models
199  *  \brief Initializes the platform with the network model Reno2
200  *
201  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
202  *
203  *  Reference:
204  *  [LOW01] S. H. Low. A duality model of TCP and queue management algorithms.
205  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
206  *
207  *  Call this function only if you plan using surf_host_model_init_compound.
208  */
209 XBT_PUBLIC void surf_network_model_init_Reno2();
210
211 /** \ingroup SURF_models
212  *  \brief Initializes the platform with the network model Vegas
213  *
214  *  This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent  to the proportional fairness.
215  *
216  *  Reference:
217  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
218  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
219  *
220  *  Call this function only if you plan using surf_host_model_init_compound.
221  */
222 XBT_PUBLIC void surf_network_model_init_Vegas();
223
224 /** \ingroup SURF_models
225  *  \brief The list of all available network model models
226  */
227 XBT_PUBLIC_DATA s_surf_model_description_t surf_network_model_description[];
228
229 /** \ingroup SURF_models
230  *  \brief The storage model
231  */
232 XBT_PUBLIC void surf_storage_model_init_default();
233
234 /** \ingroup SURF_models
235  *  \brief The list of all available storage modes.
236  *  This storage mode can be set using --cfg=storage/model:...
237  */
238 XBT_PUBLIC_DATA s_surf_model_description_t surf_storage_model_description[];
239
240 XBT_PUBLIC_DATA simgrid::surf::StorageModel* surf_storage_model;
241
242 /** \ingroup SURF_models
243  *  \brief The host model
244  *
245  *  Note that when you create an API on top of SURF, the host model should be the only one you use
246  *  because depending on the platform model, the network model and the CPU model may not exist.
247  */
248 XBT_PUBLIC_DATA simgrid::surf::HostModel* surf_host_model;
249
250 /** \ingroup SURF_models
251  *  \brief Initializes the platform with a compound host model
252  *
253  *  This function should be called after a cpu_model and a network_model have been set up.
254  */
255 XBT_PUBLIC void surf_host_model_init_compound();
256
257 /** \ingroup SURF_models
258  *  \brief Initializes the platform with the current best network and cpu models at hand
259  *
260  *  This platform model separates the host model and the network model.
261  *  The host model will be initialized with the model compound, the network model with the model LV08 (with cross
262  *  traffic support) and the CPU model with the model Cas01.
263  *  Such model is subject to modification with warning in the ChangeLog so monitor it!
264  */
265 XBT_PUBLIC void surf_host_model_init_current_default();
266
267 /** \ingroup SURF_models
268  *  \brief Initializes the platform with the model L07
269  *
270  *  With this model, only parallel tasks can be used. Resource sharing is done by identifying bottlenecks and giving an
271  *  equal share of the model to each action.
272  */
273 XBT_PUBLIC void surf_host_model_init_ptask_L07();
274
275 /** \ingroup SURF_models
276  *  \brief The list of all available host model models
277  */
278 XBT_PUBLIC_DATA s_surf_model_description_t surf_host_model_description[];
279
280 /** \ingroup SURF_models
281  *  \brief Initializes the platform with the current best network and cpu models at hand
282  *
283  *  This platform model seperates the host model and the network model.
284  *  The host model will be initialized with the model compound, the network model with the model LV08 (with cross
285  *  traffic support) and the CPU model with the model Cas01.
286  *  Such model is subject to modification with warning in the ChangeLog so monitor it!
287  */
288 XBT_PUBLIC void surf_vm_model_init_HL13();
289
290 /*** SURF Globals **************************/
291
292 /** \ingroup SURF_simulation
293  *  \brief Initialize SURF
294  *  \param argc argument number
295  *  \param argv arguments
296  *
297  *  This function has to be called to initialize the common structures. Then you will have to create the environment by
298  *  calling  e.g. surf_host_model_init_CM02()
299  *
300  *  \see surf_host_model_init_CM02(), surf_host_model_init_compound(), surf_exit()
301  */
302 XBT_PUBLIC void surf_init(int* argc, char** argv); /* initialize common structures */
303
304 /** \ingroup SURF_simulation
305  *  \brief Finish simulation initialization
306  *
307  *  This function must be called before the first call to surf_solve()
308  */
309 XBT_PUBLIC void surf_presolve();
310
311 /** \ingroup SURF_simulation
312  *  \brief Performs a part of the simulation
313  *  \param max_date Maximum date to update the simulation to, or -1
314  *  \return the elapsed time, or -1.0 if no event could be executed
315  *
316  *  This function execute all possible events, update the action states  and returns the time elapsed.
317  *  When you call execute or communicate on a model, the corresponding actions are not executed immediately but only
318  *  when you call surf_solve.
319  *  Note that the returned elapsed time can be zero.
320  */
321 XBT_PUBLIC double surf_solve(double max_date);
322
323 /** \ingroup SURF_simulation
324  *  \brief Return the current time
325  *
326  *  Return the current time in millisecond.
327  */
328 XBT_PUBLIC double surf_get_clock();
329
330 /** \ingroup SURF_simulation
331  *  \brief Exit SURF
332  *
333  *  Clean everything.
334  *
335  *  \see surf_init()
336  */
337 XBT_PUBLIC void surf_exit();
338
339 /* surf parse file related (public because called from a test suite) */
340 XBT_PUBLIC void parse_platform_file(const char* file);
341
342 /********** Tracing **********/
343
344 /* instr_routing.c */
345 void instr_routing_define_callbacks();
346 xbt_graph_t instr_routing_platform_graph();
347 void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename);
348
349 #endif