Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dfcc808b3cba1cc12bcd2aed67a832f130d8c021
[simgrid.git] / src / include / surf / surf.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
7 #ifndef _SURF_SURF_H
8 #define _SURF_SURF_H
9
10 #include "xbt/swag.h"
11 #include "xbt/dynar.h"
12 #include "xbt/dict.h"
13 #include "xbt/graph.h"
14 #include "xbt/misc.h"
15 #include "portable.h"
16 #include "xbt/config.h"
17 #include "surf/datatypes.h"
18 #include "xbt/lib.h"
19 #include "surf/surf_routing.h"
20 #include "simgrid/platf_interface.h"
21 #include "simgrid/datatypes.h"
22
23 SG_BEGIN_DECL()
24 /* Actions and models are highly connected structures... */
25
26 /* user-visible parameters */
27 extern double sg_tcp_gamma;
28 extern double sg_sender_gap;
29 extern double sg_latency_factor;
30 extern double sg_bandwidth_factor;
31 extern double sg_weight_S_parameter;
32 extern int sg_network_crosstraffic;
33 #ifdef HAVE_GTNETS
34 extern double sg_gtnets_jitter;
35 extern int sg_gtnets_jitter_seed;
36 #endif
37 extern xbt_dynar_t surf_path;
38
39 typedef enum {
40   SURF_NETWORK_ELEMENT_NULL = 0,        /* NULL */
41   SURF_NETWORK_ELEMENT_HOST,    /* host type */
42   SURF_NETWORK_ELEMENT_ROUTER,  /* router type */
43   SURF_NETWORK_ELEMENT_AS       /* AS type */
44 } e_surf_network_element_type_t;
45
46 #ifdef __cplusplus
47 class Model;
48 class CpuModel;
49 class WorkstationModel;
50 class WorkstationVMModel;
51 class NetworkCm02Model;
52 class StorageModel;
53 class Resource;
54 class ResourceLmm;
55 class WorkstationCLM03;
56 class NetworkCm02Link;
57 class Cpu;
58 class Action;
59 class ActionLmm;
60 class StorageActionLmm;
61 struct As;
62 struct RoutingEdge;
63 class RoutingPlatf;
64 #else
65 typedef struct Model Model;
66 typedef struct CpuModel CpuModel;
67 typedef struct WorkstationModel WorkstationModel;
68 typedef struct WorkstationVMModel WorkstationVMModel;
69 typedef struct NetworkCm02Model NetworkCm02Model;
70 typedef struct StorageModel StorageModel;
71 typedef struct Resource Resource;
72 typedef struct ResourceLmm ResourceLmm;
73 typedef struct WorkstationCLM03 WorkstationCLM03;
74 typedef struct NetworkCm02Link NetworkCm02Link;
75 typedef struct Cpu Cpu;
76 typedef struct Action Action;
77 typedef struct ActionLmm ActionLmm;
78 typedef struct StorageActionLmm StorageActionLmm;
79 typedef struct As As;
80 typedef struct RoutingEdge RoutingEdge;
81 typedef struct RoutingPlatf RoutingPlatf;
82 #endif
83
84 /** \ingroup SURF_models
85  *  \brief Model datatype
86  *
87  *  Generic data structure for a model. The workstations,
88  *  the CPUs and the network links are examples of models.
89  */
90 typedef Model *surf_model_t;
91 typedef CpuModel *surf_cpu_model_t;
92 typedef WorkstationModel *surf_workstation_model_t;
93 typedef WorkstationVMModel *surf_vm_workstation_model_t;
94
95 typedef NetworkCm02Model *surf_network_model_t;
96 typedef StorageModel *surf_storage_model_t;
97
98 typedef xbt_dictelm_t surf_resource_t;
99 typedef Resource *surf_cpp_resource_t;
100 typedef WorkstationCLM03 *surf_workstation_CLM03_t;
101 typedef NetworkCm02Link *surf_network_link_t;
102 typedef Cpu *surf_cpu_t;
103
104 /** \ingroup SURF_actions
105  *  \brief Action structure
106  *
107  *  Never create s_surf_action_t by yourself ! The actions are created
108  *  on the fly when you call execute or communicate on a model.
109  *
110  *  \see e_surf_action_state_t
111  */
112 typedef Action *surf_action_t;
113 typedef ActionLmm *surf_action_lmm_t;
114 typedef StorageActionLmm *surf_storage_action_lmm_t;
115
116 typedef As *AS_t;
117 typedef RoutingEdge *routing_edge_t;
118 typedef RoutingPlatf *routing_platf_t;
119
120 typedef struct surf_file *surf_file_t;
121
122 XBT_PUBLIC(e_surf_network_element_type_t)
123   routing_get_network_element_type(const char* name);
124
125 /** @Brief Specify that we use that action */
126 XBT_PUBLIC(void) surf_action_ref(surf_action_t action);
127
128 /** @brief Creates a new action.
129  *
130  * @param size The size is the one of the subtype you want to create
131  * @param cost initial value
132  * @param model to which model we should attach this action
133  * @param failed whether we should start this action in failed mode
134  */
135 XBT_PUBLIC(void *) surf_action_new(size_t size, double cost,
136                                    surf_model_t model, int failed);
137
138 /** \brief Resource model description
139  */
140 typedef struct surf_model_description {
141   const char *name;
142   const char *description;
143   void_f_void_t model_init_preparse;
144 } s_surf_model_description_t, *surf_model_description_t;
145
146 XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
147                                        const char *name);
148 XBT_PUBLIC(void) model_help(const char *category,
149                             s_surf_model_description_t * table);
150
151 /** \ingroup SURF_actions
152  *  \brief Action states
153  *
154  *  Action states.
155  *
156  *  \see surf_action_t, surf_action_state_t
157  */
158
159 typedef enum {
160   SURF_ACTION_READY = 0,        /**< Ready        */
161   SURF_ACTION_RUNNING,          /**< Running      */
162   SURF_ACTION_FAILED,           /**< Task Failure */
163   SURF_ACTION_DONE,             /**< Completed    */
164   SURF_ACTION_TO_FREE,          /**< Action to free in next cleanup */
165   SURF_ACTION_NOT_IN_THE_SYSTEM
166                                 /**< Not in the system anymore. Why did you ask ? */
167 } e_surf_action_state_t;
168
169 /* FIXME: Where should the VM state be defined? */
170 typedef enum {
171   /* created, but not yet started */
172   SURF_VM_STATE_CREATED,
173
174   SURF_VM_STATE_RUNNING,
175   SURF_VM_STATE_MIGRATING,
176
177   /* Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
178   SURF_VM_STATE_SUSPENDED,
179
180   /* Save/restore involves disk I/O, so there should be transition states. */
181   SURF_VM_STATE_SAVING,
182   SURF_VM_STATE_SAVED,
183   SURF_VM_STATE_RESTORING,
184
185 } e_surf_vm_state_t;
186
187 /***************************/
188 /* Generic model object */
189 /***************************/
190 //FIXME:REMOVE typedef struct s_routing_platf s_routing_platf_t, *routing_platf_t;
191 XBT_PUBLIC_DATA(routing_platf_t) routing_platf;
192
193 static inline void *surf_cpu_resource_priv(const void *host) {
194   return xbt_lib_get_level((xbt_dictelm_t)host, SURF_CPU_LEVEL);
195 }
196 static inline void *surf_workstation_resource_priv(const void *host){
197   return (void*)xbt_lib_get_level((xbt_dictelm_t)host, SURF_WKS_LEVEL);
198 }
199 static inline void *surf_storage_resource_priv(const void *storage){
200   return (void*)xbt_lib_get_level((xbt_dictelm_t)storage, SURF_STORAGE_LEVEL);
201 }
202
203 static inline void *surf_cpu_resource_by_name(const char *name) {
204   return xbt_lib_get_elm_or_null(host_lib, name);
205 }
206 static inline void *surf_workstation_resource_by_name(const char *name){
207   return xbt_lib_get_elm_or_null(host_lib, name);
208 }
209 static inline void *surf_storage_resource_by_name(const char *name){
210   return xbt_lib_get_elm_or_null(storage_lib, name);
211 }
212
213 #ifdef __cplusplus
214 extern "C" {
215 #endif
216 char *surf_routing_edge_name(sg_routing_edge_t edge);
217 void *surf_as_cluster_get_backbone(AS_t as);
218 void surf_as_cluster_set_backbone(AS_t as, void* backbone);
219 const char *surf_model_name(surf_model_t model);
220 xbt_swag_t surf_model_done_action_set(surf_model_t model);
221 xbt_swag_t surf_model_failed_action_set(surf_model_t model);
222 xbt_swag_t surf_model_ready_action_set(surf_model_t model);
223 xbt_swag_t surf_model_running_action_set(surf_model_t model);
224 surf_action_t surf_workstation_model_execute_parallel_task(surf_workstation_model_t model,
225                                                     int workstation_nb,
226                                             void **workstation_list,
227                                             double *computation_amount,
228                                             double *communication_amount,
229                                             double rate);
230 surf_action_t surf_workstation_model_communicate(surf_workstation_model_t model, surf_resource_t src, surf_resource_t dst, double size, double rate);
231 xbt_dynar_t surf_workstation_model_get_route(surf_workstation_model_t model, surf_resource_t src, surf_resource_t dst);
232 void surf_vm_workstation_model_create(const char *name, surf_resource_t ind_phys_host);
233 surf_action_t surf_network_model_communicate(surf_network_model_t model, sg_routing_edge_t src, sg_routing_edge_t dst, double size, double rate);
234 const char *surf_resource_name(surf_cpp_resource_t resource);
235 xbt_dict_t surf_resource_get_properties(surf_cpp_resource_t resource);
236 e_surf_resource_state_t surf_resource_get_state(surf_cpp_resource_t resource);
237 void surf_resource_set_state(surf_cpp_resource_t resource, e_surf_resource_state_t state);
238 double surf_workstation_get_speed(surf_resource_t resource, double load);
239 double surf_workstation_get_available_speed(surf_resource_t resource);
240 int surf_workstation_get_core(surf_resource_t resource);
241 surf_action_t surf_workstation_execute(surf_resource_t resource, double size);
242 surf_action_t surf_workstation_sleep(surf_resource_t resource, double duration);
243 surf_action_t surf_workstation_open(surf_resource_t workstation, const char* mount, const char* path);
244 surf_action_t surf_workstation_close(surf_resource_t workstation, surf_file_t fd);
245 surf_action_t surf_workstation_read(surf_resource_t resource, surf_file_t fd, sg_size_t size);
246 surf_action_t surf_workstation_write(surf_resource_t resource, surf_file_t fd, sg_size_t size);
247 xbt_dynar_t surf_workstation_get_info(surf_resource_t resource, surf_file_t fd);
248 sg_size_t surf_workstation_get_free_size(surf_resource_t resource, const char* name);
249 sg_size_t surf_workstation_get_used_size(surf_resource_t resource, const char* name);
250 xbt_dynar_t surf_workstation_get_vms(surf_resource_t resource);
251 void surf_workstation_get_params(surf_resource_t resource, ws_params_t params);
252 void surf_workstation_set_params(surf_resource_t resource, ws_params_t params);
253 void surf_vm_workstation_destroy(surf_resource_t resource);
254 void surf_vm_workstation_suspend(surf_resource_t resource);
255 void surf_vm_workstation_resume(surf_resource_t resource);
256 void surf_vm_workstation_save(surf_resource_t resource);
257 void surf_vm_workstation_restore(surf_resource_t resource);
258 void surf_vm_workstation_migrate(surf_resource_t resource, surf_resource_t ind_vm_ws_dest);
259 surf_resource_t surf_vm_workstation_get_pm(surf_resource_t resource);
260 void surf_vm_workstation_set_bound(surf_resource_t resource, double bound);
261 void surf_vm_workstation_set_affinity(surf_resource_t resource, surf_resource_t cpu, unsigned long mask);
262 surf_action_t surf_cpu_execute(surf_resource_t cpu, double size);
263 surf_action_t surf_cpu_sleep(surf_resource_t cpu, double duration);
264 double surf_workstation_get_current_power_peak(surf_resource_t host);
265 double surf_workstation_get_power_peak_at(surf_resource_t host, int pstate_index);
266 int surf_workstation_get_nb_pstates(surf_resource_t host);
267 void surf_workstation_set_power_peak_at(surf_resource_t host, int pstate_index);
268 double surf_workstation_get_consumed_energy(surf_resource_t host);
269 xbt_dict_t surf_workstation_get_storage_list(surf_resource_t workstation);
270 int surf_workstation_unlink(surf_resource_t workstation, surf_file_t fd);
271 surf_action_t surf_workstation_ls(surf_resource_t workstation, const char* mount, const char *path);
272 size_t surf_workstation_get_size(surf_resource_t workstation, surf_file_t fd);
273 int surf_network_link_is_shared(surf_cpp_resource_t link);
274 double surf_network_link_get_bandwidth(surf_cpp_resource_t link);
275 double surf_network_link_get_latency(surf_cpp_resource_t link);
276 xbt_dict_t surf_storage_get_content(surf_resource_t resource);
277 sg_size_t surf_storage_get_size(surf_resource_t resource);
278 void surf_storage_rename(surf_resource_t resource, const char* src, const char* dest);
279 void *surf_action_get_data(surf_action_t action);
280 void surf_action_set_data(surf_action_t action, void *data);
281 void surf_action_unref(surf_action_t action);
282 double surf_action_get_start_time(surf_action_t action);
283 double surf_action_get_finish_time(surf_action_t action);
284 double surf_action_get_remains(surf_action_t action);
285 void surf_action_suspend(surf_action_t action);
286 void surf_action_resume(surf_action_t action);
287 void surf_action_cancel(surf_action_t action);
288 void surf_action_set_priority(surf_action_t action, double priority);
289 void surf_action_set_category(surf_action_t action, const char *category);
290 e_surf_action_state_t surf_action_get_state(surf_action_t action);
291 int surf_action_get_cost(surf_action_t action);
292 void surf_cpu_action_set_affinity(surf_action_t action, surf_resource_t cpu, unsigned long mask);
293 void surf_cpu_action_set_bound(surf_action_t action, double bound);
294 surf_file_t surf_storage_action_get_file(surf_action_t action);
295 xbt_dict_t surf_storage_action_get_ls_dict(surf_action_t action);
296 surf_model_t surf_resource_model(const void *host, int level);
297 #ifdef __cplusplus
298 }
299 #endif
300
301 /**************************************/
302 /* Implementations of model object */
303 /**************************************/
304
305
306 /** \ingroup SURF_models
307  *  \brief The CPU model object for the physical machine layer
308  */
309 XBT_PUBLIC_DATA(surf_cpu_model_t) surf_cpu_model_pm;
310
311 /** \ingroup SURF_models
312  *  \brief The CPU model object for the virtual machine layer
313  */
314 XBT_PUBLIC_DATA(surf_cpu_model_t) surf_cpu_model_vm;
315
316
317 /** \ingroup SURF_models
318  *  \brief Initializes the CPU model with the model Cas01
319  *
320  *  By default, this model uses the lazy optimization mechanism that
321  *  relies on partial invalidation in LMM and a heap for lazy action update.
322  *  You can change this behavior by setting the cpu/optim configuration
323  *  variable to a different value.
324  *
325  *  You shouldn't have to call it by yourself.
326  */
327 XBT_PUBLIC(void) surf_cpu_model_init_Cas01(void);
328
329 /** \ingroup SURF_models
330  *  \brief Initializes the CPU model with trace integration [Deprecated]
331  *
332  *  You shouldn't have to call it by yourself.
333  */
334 XBT_PUBLIC(void) surf_cpu_model_init_ti(void);
335
336 /** \ingroup SURF_models
337  *  \brief The list of all available optimization modes (both for cpu and networks).
338  *  These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:...
339  */
340 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_optimization_mode_description[];
341
342 /** \ingroup SURF_models
343  *  \brief The list of all available cpu model models
344  */
345 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_cpu_model_description[];
346
347 /**\brief create new host bypass the parser
348  *
349  */
350
351
352 /** \ingroup SURF_models
353  *  \brief The network model
354  *
355  *  When creating a new API on top on SURF, you shouldn't use the
356  *  network model unless you know what you are doing. Only the workstation
357  *  model should be accessed because depending on the platform model,
358  *  the network model can be NULL.
359  */
360 XBT_PUBLIC_DATA(surf_network_model_t) surf_network_model;
361
362 /** \ingroup SURF_models
363  *  \brief Same as network model 'LagrangeVelho', only with different correction factors.
364  *
365  * This model is proposed by Pierre-Nicolas Clauss and Martin Quinson and Stéphane Génaud
366  * based on the model 'LV08' and different correction factors depending on the communication
367  * size (< 1KiB, < 64KiB, >= 64KiB).
368  * See comments in the code for more information.
369  *
370  *  \see surf_workstation_model_init_SMPI()
371  */
372 XBT_PUBLIC(void) surf_network_model_init_SMPI(void);
373
374 /** \ingroup SURF_models
375  *  \brief Initializes the platform with the network model 'LegrandVelho'
376  *
377  * This model is proposed by Arnaud Legrand and Pedro Velho based on
378  * the results obtained with the GTNets simulator for onelink and
379  * dogbone sharing scenarios. See comments in the code for more information.
380  *
381  *  \see surf_workstation_model_init_LegrandVelho()
382  */
383 XBT_PUBLIC(void) surf_network_model_init_LegrandVelho(void);
384
385 /** \ingroup SURF_models
386  *  \brief Initializes the platform with the network model 'Constant'
387  *
388  *  In this model, the communication time between two network cards is
389  *  constant, hence no need for a routing table. This is particularly
390  *  usefull when simulating huge distributed algorithms where
391  *  scalability is really an issue. This function is called in
392  *  conjunction with surf_workstation_model_init_compound.
393  *
394  *  \see surf_workstation_model_init_compound()
395  */
396 XBT_PUBLIC(void) surf_network_model_init_Constant(void);
397
398 /** \ingroup SURF_models
399  *  \brief Initializes the platform with the network model CM02
400  *
401  *  You sould call this function by yourself only if you plan using
402  *  surf_workstation_model_init_compound.
403  *  See comments in the code for more information.
404  */
405 XBT_PUBLIC(void) surf_network_model_init_CM02(void);
406
407 #ifdef HAVE_GTNETS
408 /** \ingroup SURF_models
409  *  \brief Initializes the platform with the network model GTNETS
410  *  \param filename XML platform file name
411  *
412  *  This function is called by surf_workstation_model_init_GTNETS
413  *  or by yourself only if you plan using surf_workstation_model_init_compound
414  *
415  *  \see surf_workstation_model_init_GTNETS()
416  */
417 XBT_PUBLIC(void) surf_network_model_init_GTNETS(void);
418 #endif
419
420 #ifdef HAVE_NS3
421 /** \ingroup SURF_models
422  *  \brief Initializes the platform with the network model NS3
423  *  \param filename XML platform file name
424  *
425  *  This function is called by surf_workstation_model_init_NS3
426  *  or by yourself only if you plan using surf_workstation_model_init_compound
427  *
428  *  \see surf_workstation_model_init_NS3()
429  */
430 XBT_PUBLIC(void) surf_network_model_init_NS3(void);
431 #endif
432
433 /** \ingroup SURF_models
434  *  \brief Initializes the platform with the network model Reno
435  *  \param filename XML platform file name
436  *
437  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
438  *
439  *  Reference:
440  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
441  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
442  *
443  *  Call this function only if you plan using surf_workstation_model_init_compound.
444  *
445  */
446 XBT_PUBLIC(void) surf_network_model_init_Reno(void);
447
448 /** \ingroup SURF_models
449  *  \brief Initializes the platform with the network model Reno2
450  *  \param filename XML platform file name
451  *
452  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
453  *
454  *  Reference:
455  *  [LOW01] S. H. Low. A duality model of TCP and queue management algorithms.
456  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
457  *
458  *  Call this function only if you plan using surf_workstation_model_init_compound.
459  *
460  */
461 XBT_PUBLIC(void) surf_network_model_init_Reno2(void);
462
463 /** \ingroup SURF_models
464  *  \brief Initializes the platform with the network model Vegas
465  *  \param filename XML platform file name
466  *
467  *  This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent
468  *  to the proportional fairness.
469  *
470  *  Reference:
471  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
472  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
473  *
474  *  Call this function only if you plan using surf_workstation_model_init_compound.
475  *
476  */
477 XBT_PUBLIC(void) surf_network_model_init_Vegas(void);
478
479 /** \ingroup SURF_models
480  *  \brief The list of all available network model models
481  */
482 XBT_PUBLIC_DATA(s_surf_model_description_t)
483     surf_network_model_description[];
484
485 /** \ingroup SURF_models
486  *  \brief The storage model
487  */
488 XBT_PUBLIC(void) surf_storage_model_init_default(void);
489
490 /** \ingroup SURF_models
491  *  \brief The list of all available storage modes.
492  *  This storage mode can be set using --cfg=storage/model:...
493  */
494 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_storage_model_description[];
495
496 XBT_PUBLIC_DATA(surf_storage_model_t) surf_storage_model;
497
498 /** \ingroup SURF_models
499  *  \brief The workstation model
500  *
501  *  Note that when you create an API on top of SURF,
502  *  the workstation model should be the only one you use
503  *  because depending on the platform model, the network model and the CPU model
504  *  may not exist.
505  */
506 XBT_PUBLIC_DATA(surf_workstation_model_t) surf_workstation_model;
507
508 /** \ingroup SURF_models
509  *  \brief The vm_workstation model
510  *
511  *  Note that when you create an API on top of SURF,
512  *  the vm_workstation model should be the only one you use
513  *  because depending on the platform model, the network model and the CPU model
514  *  may not exist.
515  */
516 XBT_PUBLIC_DATA(surf_vm_workstation_model_t) surf_vm_workstation_model;
517
518 /** \ingroup SURF_models
519  *  \brief Initializes the platform with a compound workstation model
520  *
521  *  This function should be called after a cpu_model and a
522  *  network_model have been set up.
523  *
524  */
525 XBT_PUBLIC(void) surf_workstation_model_init_compound(void);
526
527 /** \ingroup SURF_models
528  *  \brief Initializes the platform with the current best network and cpu models at hand
529  *
530  *  This platform model seperates the workstation model and the network model.
531  *  The workstation model will be initialized with the model compound, the network
532  *  model with the model LV08 (with cross traffic support) and the CPU model with
533  *  the model Cas01.
534  *  Such model is subject to modification with warning in the ChangeLog so monitor it!
535  *
536  */
537 XBT_PUBLIC(void) surf_workstation_model_init_current_default(void);
538
539 /** \ingroup SURF_models
540  *  \brief Initializes the platform with the model KCCFLN05
541  *
542  *  With this model, only parallel tasks can be used. Resource sharing
543  *  is done by identifying bottlenecks and giving an equal share of
544  *  the model to each action.
545  *
546  */
547 XBT_PUBLIC(void) surf_workstation_model_init_ptask_L07(void);
548
549 /** \ingroup SURF_models
550  *  \brief The list of all available workstation model models
551  */
552 XBT_PUBLIC_DATA(s_surf_model_description_t)
553     surf_workstation_model_description[];
554
555 /** \ingroup SURF_models
556  *  \brief Initializes the platform with the current best network and cpu models at hand
557  *
558  *  This platform model seperates the workstation model and the network model.
559  *  The workstation model will be initialized with the model compound, the network
560  *  model with the model LV08 (with cross traffic support) and the CPU model with
561  *  the model Cas01.
562  *  Such model is subject to modification with warning in the ChangeLog so monitor it!
563  *
564  */
565 XBT_PUBLIC(void) surf_vm_workstation_model_init_current_default(void);
566
567 /** \ingroup SURF_models
568  *  \brief The list of all available vm workstation model models
569  */
570 XBT_PUBLIC_DATA(s_surf_model_description_t)
571     surf_vm_workstation_model_description[];
572
573 /*******************************************/
574
575 /** \ingroup SURF_models
576  *  \brief List of initialized models
577  */
578 XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
579 XBT_PUBLIC_DATA(xbt_dynar_t) model_list_invoke;
580
581 /** \ingroup SURF_simulation
582  *  \brief List of hosts that have juste restarted and whose autorestart process should be restarted.
583  */
584 XBT_PUBLIC_DATA(xbt_dynar_t) host_that_restart;
585
586 /** \ingroup SURF_simulation
587  *  \brief List of hosts for which one want to be notified if they ever restart.
588  */
589 XBT_PUBLIC(xbt_dict_t) watched_hosts_lib;
590
591 /*******************************************/
592 /*** SURF Platform *************************/
593 /*******************************************/
594 #ifdef __cplusplus
595 extern "C" {
596 #endif
597 XBT_PUBLIC_DATA(AS_t) surf_AS_get_routing_root(void); 
598 XBT_PUBLIC_DATA(const char *) surf_AS_get_name(AS_t as);
599 XBT_PUBLIC_DATA(xbt_dict_t) surf_AS_get_routing_sons(AS_t as);
600 XBT_PUBLIC_DATA(const char *) surf_AS_get_model(AS_t as);
601 XBT_PUBLIC_DATA(xbt_dynar_t) surf_AS_get_hosts(AS_t as);
602 XBT_PUBLIC_DATA(void) surf_AS_get_graph(AS_t as, xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
603 XBT_PUBLIC_DATA(AS_t) surf_platf_get_root(routing_platf_t platf);
604 XBT_PUBLIC_DATA(e_surf_network_element_type_t) surf_routing_edge_get_rc_type(sg_routing_edge_t edge);
605 #ifdef __cplusplus
606 }
607 #endif
608
609 /*******************************************/
610 /*** SURF Globals **************************/
611 /*******************************************/
612
613 /** \ingroup SURF_simulation
614  *  \brief Initialize SURF
615  *  \param argc argument number
616  *  \param argv arguments
617  *
618  *  This function has to be called to initialize the common
619  *  structures.  Then you will have to create the environment by
620  *  calling 
621  *  e.g. surf_workstation_model_init_CM02()
622  *
623  *  \see surf_workstation_model_init_CM02(), surf_workstation_model_init_compound(), surf_exit()
624  */
625 XBT_PUBLIC(void) surf_init(int *argc, char **argv);     /* initialize common structures */
626
627 /** \ingroup SURF_simulation
628  *  \brief Finish simulation initialization
629  *
630  *  This function must be called before the first call to surf_solve()
631  */
632 XBT_PUBLIC(void) surf_presolve(void);
633
634 /** \ingroup SURF_simulation
635  *  \brief Performs a part of the simulation
636  *  \param max_date Maximum date to update the simulation to, or -1
637  *  \return the elapsed time, or -1.0 if no event could be executed
638  *
639  *  This function execute all possible events, update the action states
640  *  and returns the time elapsed.
641  *  When you call execute or communicate on a model, the corresponding actions
642  *  are not executed immediately but only when you call surf_solve.
643  *  Note that the returned elapsed time can be zero.
644  */
645 XBT_PUBLIC(double) surf_solve(double max_date);
646
647 /** \ingroup SURF_simulation
648  *  \brief Return the current time
649  *
650  *  Return the current time in millisecond.
651  */
652 XBT_PUBLIC(double) surf_get_clock(void);
653
654 /** \ingroup SURF_simulation
655  *  \brief Exit SURF
656  *
657  *  Clean everything.
658  *
659  *  \see surf_init()
660  */
661 XBT_PUBLIC(void) surf_exit(void);
662
663 /* Prototypes of the functions that handle the properties */
664 XBT_PUBLIC_DATA(xbt_dict_t) current_property_set;       /* the prop set for the currently parsed element (also used in SIMIX) */
665
666 /* surf parse file related (public because called from a test suite) */
667 XBT_PUBLIC(void) parse_platform_file(const char *file);
668
669 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
670 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
671 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail;
672 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_power;
673 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail;
674 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth;
675 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
676
677
678 XBT_PUBLIC(double) get_cpu_power(const char *power);
679
680 XBT_PUBLIC(xbt_dict_t) get_as_router_properties(const char* name);
681
682 int surf_get_nthreads(void);
683 void surf_set_nthreads(int nthreads);
684
685 /*
686  * Returns the initial path. On Windows the initial path is
687  * the current directory for the current process in the other
688  * case the function returns "./" that represents the current
689  * directory on Unix/Linux platforms.
690  */
691 const char *__surf_get_initial_path(void);
692
693 /********** Tracing **********/
694 /* from surf_instr.c */
695 void TRACE_surf_action(surf_action_t surf_action, const char *category);
696 void TRACE_surf_alloc(void);
697 void TRACE_surf_release(void);
698
699 /* instr_routing.c */
700 void instr_routing_define_callbacks (void);
701 void instr_new_variable_type (const char *new_typename, const char *color);
702 void instr_new_user_variable_type  (const char *father_type, const char *new_typename, const char *color);
703 void instr_new_user_state_type (const char *father_type, const char *new_typename);
704 void instr_new_value_for_user_state_type (const char *_typename, const char *value, const char *color);
705 int instr_platform_traced (void);
706 xbt_graph_t instr_routing_platform_graph (void);
707 void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename);
708
709 SG_END_DECL()
710 #endif                          /* _SURF_SURF_H */