Logo AND Algorithmique Numérique Distribuée

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