1 /* Copyright (c) 2004-2018. The SimGrid Team. All rights reserved. */
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. */
9 #include "simgrid/forward.h"
10 #include "src/internal_config.h"
11 #include "xbt/config.h"
13 #include "xbt/dynar.h"
14 #include "xbt/graph.h"
18 #error This is a C++ only file, now
27 class NetworkCm02Link;
31 /** @ingroup SURF_c_bindings
32 * \brief Model datatype
34 * Generic data structure for a model. The hosts,
35 * the CPUs and the network links are examples of models.
37 typedef simgrid::surf::CpuModel* surf_cpu_model_t;
38 typedef simgrid::surf::HostModel* surf_host_model_t;
39 typedef simgrid::surf::NetworkModel* surf_network_model_t;
40 typedef simgrid::surf::StorageModel* surf_storage_model_t;
42 /* Actions and models are highly connected structures... */
44 /* user-visible parameters */
45 extern XBT_PRIVATE double sg_tcp_gamma;
46 extern XBT_PRIVATE double sg_latency_factor;
47 extern XBT_PRIVATE double sg_bandwidth_factor;
48 extern XBT_PRIVATE double sg_weight_S_parameter;
49 extern XBT_PRIVATE int sg_network_crosstraffic;
51 /** \brief Resource model description
53 struct surf_model_description {
55 const char* description;
56 void_f_void_t model_init_preparse;
58 typedef struct surf_model_description s_surf_model_description_t;
60 XBT_PUBLIC int find_model_description(s_surf_model_description_t* table, std::string name);
61 XBT_PUBLIC void model_help(const char* category, s_surf_model_description_t* table);
63 /***************************/
64 /* Generic model object */
65 /***************************/
67 /** @{ @ingroup SURF_c_bindings */
70 * @brief Pop an action from the done actions set
72 * @param model The model from which the action is extracted
73 * @return An action in done state
75 XBT_PUBLIC simgrid::kernel::resource::Action*
76 surf_model_extract_done_action_set(simgrid::kernel::resource::Model* model);
79 * @brief Pop an action from the failed actions set
81 * @param model The model from which the action is extracted
82 * @return An action in failed state
84 XBT_PUBLIC simgrid::kernel::resource::Action*
85 surf_model_extract_failed_action_set(simgrid::kernel::resource::Model* model);
88 * @brief Get the size of the running action set of a model
90 * @param model The model
91 * @return The size of the running action set
93 XBT_PUBLIC int surf_model_running_action_set_size(simgrid::kernel::resource::Model* model);
96 * @brief [brief description]
97 * @details [long description]
99 * @param action The surf cpu action
100 * @param bound [description]
102 XBT_PUBLIC void surf_cpu_action_set_bound(simgrid::kernel::resource::Action* action, double bound);
106 /**************************************/
107 /* Implementations of model object */
108 /**************************************/
110 /** \ingroup SURF_models
111 * \brief The CPU model object for the physical machine layer
113 XBT_PUBLIC_DATA surf_cpu_model_t surf_cpu_model_pm;
115 /** \ingroup SURF_models
116 * \brief The CPU model object for the virtual machine layer
118 XBT_PUBLIC_DATA surf_cpu_model_t surf_cpu_model_vm;
120 /** \ingroup SURF_models
121 * \brief Initializes the CPU model with the model Cas01
123 * By default, this model uses the lazy optimization mechanism that relies on partial invalidation in LMM and a heap
124 * for lazy action update.
125 * You can change this behavior by setting the cpu/optim configuration variable to a different value.
127 * You shouldn't have to call it by yourself.
129 XBT_PUBLIC void surf_cpu_model_init_Cas01();
131 /** \ingroup SURF_models
132 * \brief Initializes the CPU model with trace integration [Deprecated]
134 * You shouldn't have to call it by yourself.
136 XBT_PUBLIC void surf_cpu_model_init_ti();
138 /** \ingroup SURF_models
139 * \brief The list of all available optimization modes (both for cpu and networks).
140 * These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:...
142 XBT_PUBLIC_DATA s_surf_model_description_t surf_optimization_mode_description[];
144 /** \ingroup SURF_plugins
145 * \brief The list of all available surf plugins
147 XBT_PUBLIC_DATA s_surf_model_description_t surf_plugin_description[];
149 /** \ingroup SURF_models
150 * \brief The list of all available cpu model models
152 XBT_PUBLIC_DATA s_surf_model_description_t surf_cpu_model_description[];
154 /** \ingroup SURF_models
155 * \brief The network model
157 * When creating a new API on top on SURF, you shouldn't use the network model unless you know what you are doing.
158 * Only the host model should be accessed because depending on the platform model, the network model can be NULL.
160 XBT_PUBLIC_DATA surf_network_model_t surf_network_model;
162 /** \ingroup SURF_models
163 * \brief Same as network model 'LagrangeVelho', only with different correction factors.
165 * This model is proposed by Pierre-Nicolas Clauss and Martin Quinson and Stéphane Génaud based on the model 'LV08' and
166 * different correction factors depending on the communication size (< 1KiB, < 64KiB, >= 64KiB).
167 * See comments in the code for more information.
169 * \see surf_host_model_init_SMPI()
171 XBT_PUBLIC void surf_network_model_init_SMPI();
173 /** \ingroup SURF_models
174 * \brief Same as network model 'LagrangeVelho', only with different correction factors.
176 * This model impelments a variant of the contention model on Infinband networks based on
177 * the works of Jérôme Vienne : http://mescal.imag.fr/membres/jean-marc.vincent/index.html/PhD/Vienne.pdf
179 * \see surf_host_model_init_IB()
181 XBT_PUBLIC void surf_network_model_init_IB();
183 /** \ingroup SURF_models
184 * \brief Initializes the platform with the network model 'LegrandVelho'
186 * This model is proposed by Arnaud Legrand and Pedro Velho based on the results obtained with the GTNets simulator for
187 * onelink and dogbone sharing scenarios. See comments in the code for more information.
189 * \see surf_host_model_init_LegrandVelho()
191 XBT_PUBLIC void surf_network_model_init_LegrandVelho();
193 /** \ingroup SURF_models
194 * \brief Initializes the platform with the network model 'Constant'
196 * In this model, the communication time between two network cards is constant, hence no need for a routing table.
197 * This is particularly useful when simulating huge distributed algorithms where scalability is really an issue. This
198 * function is called in conjunction with surf_host_model_init_compound.
200 * \see surf_host_model_init_compound()
202 XBT_PUBLIC void surf_network_model_init_Constant();
204 /** \ingroup SURF_models
205 * \brief Initializes the platform with the network model CM02
207 * You sould call this function by yourself only if you plan using surf_host_model_init_compound.
208 * See comments in the code for more information.
210 XBT_PUBLIC void surf_network_model_init_CM02();
212 /** \ingroup SURF_models
213 * \brief Initializes the platform with the network model NS3
215 * This function is called by surf_host_model_init_NS3 or by yourself only if you plan using
216 * surf_host_model_init_compound
218 * \see surf_host_model_init_NS3()
220 XBT_PUBLIC void surf_network_model_init_NS3();
222 /** \ingroup SURF_models
223 * \brief Initializes the platform with the network model Reno
225 * The problem is related to max( sum( arctan(C * Df * xi) ) ).
228 * [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
229 * IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
231 * Call this function only if you plan using surf_host_model_init_compound.
233 XBT_PUBLIC void surf_network_model_init_Reno();
235 /** \ingroup SURF_models
236 * \brief Initializes the platform with the network model Reno2
238 * The problem is related to max( sum( arctan(C * Df * xi) ) ).
241 * [LOW01] S. H. Low. A duality model of TCP and queue management algorithms.
242 * IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
244 * Call this function only if you plan using surf_host_model_init_compound.
246 XBT_PUBLIC void surf_network_model_init_Reno2();
248 /** \ingroup SURF_models
249 * \brief Initializes the platform with the network model Vegas
251 * This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent to the proportional fairness.
254 * [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
255 * IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
257 * Call this function only if you plan using surf_host_model_init_compound.
259 XBT_PUBLIC void surf_network_model_init_Vegas();
261 /** \ingroup SURF_models
262 * \brief The list of all available network model models
264 XBT_PUBLIC_DATA s_surf_model_description_t surf_network_model_description[];
266 /** \ingroup SURF_models
267 * \brief The storage model
269 XBT_PUBLIC void surf_storage_model_init_default();
271 /** \ingroup SURF_models
272 * \brief The list of all available storage modes.
273 * This storage mode can be set using --cfg=storage/model:...
275 XBT_PUBLIC_DATA s_surf_model_description_t surf_storage_model_description[];
277 XBT_PUBLIC_DATA surf_storage_model_t surf_storage_model;
279 /** \ingroup SURF_models
280 * \brief The host model
282 * Note that when you create an API on top of SURF, the host model should be the only one you use
283 * because depending on the platform model, the network model and the CPU model may not exist.
285 XBT_PUBLIC_DATA surf_host_model_t surf_host_model;
287 /** \ingroup SURF_models
288 * \brief Initializes the platform with a compound host model
290 * This function should be called after a cpu_model and a network_model have been set up.
292 XBT_PUBLIC void surf_host_model_init_compound();
294 /** \ingroup SURF_models
295 * \brief Initializes the platform with the current best network and cpu models at hand
297 * This platform model separates the host model and the network model.
298 * The host model will be initialized with the model compound, the network model with the model LV08 (with cross
299 * traffic support) and the CPU model with the model Cas01.
300 * Such model is subject to modification with warning in the ChangeLog so monitor it!
302 XBT_PUBLIC void surf_host_model_init_current_default();
304 /** \ingroup SURF_models
305 * \brief Initializes the platform with the model L07
307 * With this model, only parallel tasks can be used. Resource sharing is done by identifying bottlenecks and giving an
308 * equal share of the model to each action.
310 XBT_PUBLIC void surf_host_model_init_ptask_L07();
312 /** \ingroup SURF_models
313 * \brief The list of all available host model models
315 XBT_PUBLIC_DATA s_surf_model_description_t surf_host_model_description[];
317 /** \ingroup SURF_models
318 * \brief Initializes the platform with the current best network and cpu models at hand
320 * This platform model seperates the host model and the network model.
321 * The host model will be initialized with the model compound, the network model with the model LV08 (with cross
322 * traffic support) and the CPU model with the model Cas01.
323 * Such model is subject to modification with warning in the ChangeLog so monitor it!
325 XBT_PUBLIC void surf_vm_model_init_HL13();
327 /*** SURF Globals **************************/
329 /** \ingroup SURF_simulation
330 * \brief Initialize SURF
331 * \param argc argument number
332 * \param argv arguments
334 * This function has to be called to initialize the common structures. Then you will have to create the environment by
335 * calling e.g. surf_host_model_init_CM02()
337 * \see surf_host_model_init_CM02(), surf_host_model_init_compound(), surf_exit()
339 XBT_PUBLIC void surf_init(int* argc, char** argv); /* initialize common structures */
341 /** \ingroup SURF_simulation
342 * \brief Finish simulation initialization
344 * This function must be called before the first call to surf_solve()
346 XBT_PUBLIC void surf_presolve();
348 /** \ingroup SURF_simulation
349 * \brief Performs a part of the simulation
350 * \param max_date Maximum date to update the simulation to, or -1
351 * \return the elapsed time, or -1.0 if no event could be executed
353 * This function execute all possible events, update the action states and returns the time elapsed.
354 * When you call execute or communicate on a model, the corresponding actions are not executed immediately but only
355 * when you call surf_solve.
356 * Note that the returned elapsed time can be zero.
358 XBT_PUBLIC double surf_solve(double max_date);
360 /** \ingroup SURF_simulation
361 * \brief Return the current time
363 * Return the current time in millisecond.
365 XBT_PUBLIC double surf_get_clock();
367 /** \ingroup SURF_simulation
374 XBT_PUBLIC void surf_exit();
376 /* surf parse file related (public because called from a test suite) */
377 XBT_PUBLIC void parse_platform_file(const char* file);
379 /********** Tracing **********/
381 /* instr_routing.c */
382 void instr_routing_define_callbacks();
383 xbt_graph_t instr_routing_platform_graph();
384 void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename);